Audio Focus Handling with Multiple Instance of ExoPlayer (Audio and Video)
@marcbaechinger is already working on this.
Since Feb 4, 2025.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
ExoPlayer 1.5.1
Description
This might be similar with https://github.com/androidx/media/issues/1798, but the issue here both player instance are playing.
In our case, the issue happen on a specific device.
We are able to reproduce the issue in this sample app that use ExoPlayer 1.5.1
https://github.com/esafirm/exoplayer-audiofocus-sample
Observing the log, we got some interesting finding.
Here's the log when we try to reproduce in the phone with the issue
2025-01-28T03:57:25.130Z
1421
MediaFocusControl
requestAudioFocus() from uid/pid 10281/29489 AA=USAGE_MEDIA/CONTENT_TYPE_MUSIC clientId=android.media.AudioManager@a536737A3.e@a7fe4a4 callingPack=com.ourapp req=1 flags=0x0 sdk=35
2025-01-28T03:57:31.729Z
1421
MediaFocusControl
requestAudioFocus() from uid/pid 10281/29489 AA=USAGE_MEDIA/CONTENT_TYPE_MOVIE clientId=android.media.AudioManager@a536737A3.e@7ab8a40 callingPack=com.ourapp req=1 flags=0x0 sdk=35
2025-01-28T03:57:40.878Z
1421
MediaFocusControl
abandonAudioFocus() from uid/pid 10281/29489 clientId=android.media.AudioManager@a536737A3.e@7ab8a40
Here's the log with the phone that does not have the issue:
2025-01-31T07:28:55.943Z
1391
MediaFocusControl
requestAudioFocus() from uid/pid 10323/15864 AA=USAGE_MEDIA/CONTENT_TYPE_MUSIC clientId=android.media.AudioManager@ece92f4androidx.media3.exoplayer.AudioFocusManager$AudioFocusListener@b731a1d callingPack=com.ourapp req=1 flags=0x0 sdk=35
2025-01-31T07:29:52.359Z
1391
MediaFocusControl
requestAudioFocus() from uid/pid 10323/15864 AA=USAGE_MEDIA/CONTENT_TYPE_MOVIE clientId=android.media.AudioManager@ece92f4androidx.media3.exoplayer.AudioFocusManager$AudioFocusListener@149df40 callingPack=com.ourapp req=1 flags=0x0 sdk=35
2025-01-31T07:29:52.398Z
15864
AudioManager
dispatching onAudioFocusChange(-1) to android.media.AudioManager@ece92f4androidx.media3.exoplayer.AudioFocusManager$AudioFocusListener@b731a1d
2025-01-31T07:29:52.424Z
1391
MediaFocusControl
abandonAudioFocus() from uid/pid 10323/15864 clientId=android.media.AudioManager@ece92f4androidx.media3.exoplayer.AudioFocusManager$AudioFocusListener@b731a1d
Devices that reproduce the issue
Xiaomi Redmi Note 12 Pro 5G with Android 14
Devices that do not reproduce the issue
- Samsung Galaxy S21 FE - Android 14
- Poco Phone F5 - Android 14
- Xiaomi 13 - Android 13
- Samsung A5 - Android 13
- Emulator - Android 11
Reproducible in the demo app?
Not tested
Reproduction steps
We are able to reproduce this on our sample
- Tap "Play Audio" button
- Tap "Play Video" button
Expected result
The player instance that playing is paused.
Actual result
Both player instances are playing
Media
Can be found in the sample app asset directory: https://github.com/esafirm/exoplayer-audiofocus-sample/tree/main/app/src/main/assets
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.