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

SimpleExoPlayer.getAudioSessionId is Zero after change MediaItem (setMediaItem and prepare()) #8585

Closed
farzadno opened this issue Feb 14, 2021 · 2 comments
Assignees
Labels

Comments

@farzadno
Copy link

Hello. I use exoplayer 2.13.1 in my app. after changes on 2.13.0 (2021-02-04) Audio, SimpleExoPlayer.getAudioSessionId is fix and return true SessionId. But after after change MediaItem, getAudioSessionId return 0.

SimpleExoPlayer simpleExoPlayer = new SimpleExoPlayer.Builder(this).setMediaSourceFactory(new DefaultMediaSourceFactory(cacheDataSourceFactory)).build();
simpleExoPlayer.setWakeMode(PowerManager.PARTIAL_WAKE_LOCK);

simpleExoPlayer.addAnalyticsListener(new AnalyticsListener() {
    @Override
    public void onAudioSessionIdChanged(@NonNull EventTime eventTime, int audioSessionId) {
	    Log.e("FLAG", "sessionId: " + audioSessionId); // not called
    }
});

// on first time prepare: sessionId is true. on second time prepare: sessionId is 0
public void prepare(String audioUrl) {
    MediaItem mediaItem = MediaItem.fromUri(audioUrl);
    simpleExoPlayer.setMediaItem(mediaItem);
    simpleExoPlayer.prepare();
    simpleExoPlayer.setPlayWhenReady(true);
}
@ojw28
Copy link
Contributor

ojw28 commented Feb 14, 2021

Thanks for reporting this! There is indeed a problem where 0 is incorrectly, and we will fix this in a future release. In the meantime, you can rely on the (true) audio session ID not changing unless application code calls SimpleExoPlayer.setAudioSessionId. Hence you can work around the issue by querying it once immediately after the player has been create.

kim-vde pushed a commit that referenced this issue Feb 19, 2021
Issue: #8585
#minor-release
PiperOrigin-RevId: 357553237
@ojw28
Copy link
Contributor

ojw28 commented Feb 19, 2021

This is fixed in dev-v2, and will be included in 2.13.2. Thanks for reporting!

@ojw28 ojw28 closed this as completed Feb 19, 2021
marcbaechinger pushed a commit that referenced this issue Feb 25, 2021
Issue: #8585
PiperOrigin-RevId: 357553237
@google google locked and limited conversation to collaborators Apr 21, 2021
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

2 participants