Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioSessionId=0 always. The problem with getting an audio session. #6954

Closed
master255 opened this issue Feb 8, 2020 · 4 comments
Closed
Assignees
Labels

Comments

@master255
Copy link

master255 commented Feb 8, 2020

I have problem on the 2.11.1 release right now.
Sometimes, when switching different files, with different codecs, with codec cache enabled, onAudioSessionId events do not work at all! At this time mMediaPlayer.getAudioSessionId() produces 0.
Most often it happens when you switch from 4k movie to mp3 track.
Music is playing, but no audio session and no onAudioSessionId events.
Fix it, please.
What details are you interested in?

@master255
Copy link
Author

mMediaPlayer.setForegroundMode(false);
Temporarily helped. Can we make the audio session work properly with the codec cache enabled?

@master255
Copy link
Author

master255 commented Feb 9, 2020

I don't know if it's right anymore.
That's what the player start function looks like to me:

private void openVideo(boolean hls, String extension) {
        if (path == null) return;
        try {
            initPlayer();
            duration = 0;
            notifiedPrepared = false; //These are two variables for calculating where onPrepare will work.
            notifySessionId = false;
            mSeekWhenPrepared = 0;
            mOldCurrentState = 0;
            if (path.toLowerCase().startsWith("http") && Uri.decode(path).equals(path)) //To support all languages
                path = Uri.encode(path, Constants.ALLOW_STR);
            if (extension != null && extension.equals(lastExt))
                mMediaPlayer.setForegroundMode(true); //Is this how it's supposed to work? Surviving as much as I can.
            else
                mMediaPlayer.setForegroundMode(false);
            lastExt = extension;
            if (hls)  //We calculate HLS or not. The player can't do it on its own.
                mMediaPlayer.prepare(hlsSource.createMediaSource(Uri.parse(path)));
            else
                mMediaPlayer.prepare(progressiveSource.createMediaSource(Uri.parse(path)));
            mCurrentState = STATE_PREPARING;
        } catch (Exception e) {
            mCurrentState = STATE_ERROR;
            mErrorListener.onError(e);
        }
    }

Why is my code not formatted I don't know. It's Githab bug.
Google saves a lot of money on programmers.

@kim-vde kim-vde self-assigned this Feb 10, 2020
@kim-vde
Copy link
Contributor

kim-vde commented Feb 10, 2020

What is the type of mMediaPlayer? Did it work with a previous version of ExoPlayer? Could you please provide steps to reproduce the issue, together with the test contents, as described here?

@master255
Copy link
Author

Thank you for the answer. This bug is available if you call stop after a track with mMediaPlayer.setForegroundMode(true);
It took me a long time to figure out what was going on, but then I found an instruction in the depths of the code explaining that I don't need to call a stop in this case.
Now it works correctly.

@google google locked and limited conversation to collaborators Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants