[go: nahoru, domu]

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

EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED and PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS are not being sent when audio focus is lost #1470

Closed
1 task done
aljohnston112 opened this issue Jun 18, 2024 · 2 comments
Assignees
Labels

Comments

@aljohnston112
Copy link

Version

Media3 main branch

More version details

implementation "androidx.media3:media3-common:1.2.0"
implementation "androidx.media3:media3-exoplayer:1.2.0"
implementation "androidx.media3:media3-session:1.2.0"

Devices that reproduce the issue

Pixel 8 Android 14

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

  1. Create a Player with setAudioAttributes' handleAudioFocus parameter to true.
  2. Set up a MediaSession and start playback.
  3. Have another app take audio focus.

Expected result

As described here: google/ExoPlayer#10293

When playback is stopped due to loss of audio focus, Player.Listener.onPlaybackSuppressionReasonChanged will be called with reason Player.PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS.

The event included in Player.Listener.onEvents() with key EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED.

Actual result

Neither of the two expected results happen.

Media

Not applicable

Bug Report

@aljohnston112
Copy link
Author

I did find that onPlayWhenReadyChanged is triggered with reason PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS when audio focus is lost. If that is what the intended behavior is, feel free to close this ticket.

@tonihei tonihei self-assigned this Jun 24, 2024
@tonihei
Copy link
Collaborator
tonihei commented Jun 24, 2024

Yes, this is the intended behavior. Note that there is a difference between onPlaybackSuppressionReasonChanged(PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS) (= transient, short-lived suppression with automatic resumption) and onPlayWhenReadyChanged(PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS) (=a permanent focus loss, no automatic resumption).

@tonihei tonihei closed this as completed Jun 24, 2024
@androidx androidx locked and limited conversation to collaborators Aug 24, 2024
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