Open deRonbrown opened 5 years ago
I've determined the issue, and the cause is not due to a bug in ExoPlayer or the Cast extension. This commit in the CastVolumeControlServiceTest fixes the issue.
After debugging and looking through the device's logs, I discovered that the volume key events were directed to the active MediaSession. By setting the MediaSession to inactive, the volume control stream will control the receiver device, so the solution is the toggle MediaSession to active/inactive depending on which Player is current.
This doesn't seem intuitive, so can you add this info to your Cast extension docs for future developers who may come across this issue?
I'll have a look. Thanks for doing the research!
Issue description
When playing content using the CastPlayer, the device's physical volume buttons should control the receiver device's volume. This behaves as expected when the CastPlayer is contained within an Activity. However, when the CastPlayer is contained within a Service (such as a MediaBrowserServiceCompat) the physical volume buttons change the sender device's media volume.
Reproduction steps
I've created 2 sample projects:
Link to test content
Test mp4 file is used in sample projects above.
Version of ExoPlayer being used
Core 2.8.4 and Cast Extension 2.8.4
Device(s) and version(s) of Android being used
Reproduces on 9.0 and 8.1.0.