media icon indicating copy to clipboard operation
media copied to clipboard

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

Open Ste-RH opened this issue 1 year ago • 1 comments

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:

  • Google Pixel 7
  • Xiaomi Mi 10T
  • Samsung Galaxy S22 Ultra

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

  • [x] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

Ste-RH avatar Oct 10 '24 09:10 Ste-RH

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'.

Ste-RH avatar Oct 11 '24 15:10 Ste-RH

@Ste-RH Can you share about the solution?

maxrave-dev avatar Jul 31 '25 09:07 maxrave-dev