androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.64k stars 389 forks source link

Audio focus handling with move than one ExoPlayer-instance/video-playing #1798

Open Ste-RH opened 1 week ago

Ste-RH commented 1 week ago

Version

Media3 1.4.1

More version details

Also tested and seen in v1.1.0

Devices that reproduce the issue

Seen on every device tested on, including:

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

1) Create two ExoPlayer instances 2) set: setAudioAttributes(new AudioAttributes.Builder().build(), true) on both instances 3) Play videos on both instances 4) One video will not be playing 5) Background the app and bring to foreground, videos will swap which one is playing and which one is not

NOTE: I generated the bug report after step (4) but before step (5), as I thought step (5) might cloud the logging.

Change the 'handleAudioFocus' parameter passed into 'setAudioAttributes' to false and both videos play correctly, but we lose functionality of playback being paused when a phone call comes into the device (and resumed afterwards).

I have also tried setting the following on 'AudioAttributes.Builder()': .setUsage(C.USAGE_MEDIA) .setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)

Expected result

Both videos play

Actual result

Only one video plays

Media

Any two MP4's - resolution, bitrate, codec are unimportant.

Tested with two h264 low resolution videos.

Bug Report

Ste-RH commented 1 week ago

Small update. We have implemented our own audio focus handling at 'manager' level (that knows about all the currently instantiated ExoPlayer objects). So we have a fix for the issue within our product.

Will leave the issue here for you to deem if it is actually an issue, or rather 'as designed system'.