Media volume buttons won't work on ExoPlayer after exoPlayer.setVolume #7307
Comments
|
I'm wondering why you need to set the ExoPlayer volume to 0 in case 'the device is on silent or vibrate'. I think this should be handled by the OS, so that you do not have to take care yourself. Is there a specific reason this does not work for you? Besides the above the following may explain the issue you are seeing: There are two volumes which are relevant: ExoPlayer volume and OS volume. The hardware buttons do change the volume of audio streams on the OS level. Besides this, ExoPlayer itself can change the volume of the audio stream that is delivered to the OS by ExoPlayer. So the OS volume changes what is coming from ExoPlayer. If we assume a value between 0 and 1 for each volumes, the actual output is the multiplication of these two: ExoPlayerVolume x OSVolume = UserExperiencedVolume So if you set the ExoPalyerVolume to 0 (zero) the result will always be 0. This would explain the behaviour you are seeing, that changing the OS volume with the hardware buttons has not effect on the experienced volume, when ExoPlayerVolume is 0. To solve the problem you are describing you need to set the ExoPlayerVolume back to 1 when the user is operating the volume buttons. Again, please also check whether you can solve this without changing the ExoPlayer volume, but just relying on the OS feature. This would make it easier for you as it works out of the box and the user is not surprised of hearing audio even if the device is on silence. |
|
Hey @arangob. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
|
Since there haven't been any recent updates here, I am going to close this issue. @arangob if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Searched documentation and issues
I've looked on stackoverflow, ExoPlayer docs, Android developers responding to media buttons.
Question
I am developing an app that sets the exoPlayer's volume to 0 if the device is on silent or vibrate.
If the user interacts with the volume buttons, then I want to the exoPlayer's volume to be set to the AudioManager volume.
Issue: After setting the volume to 0, the device's volume buttons have no effect on the exoPlayer's volume level.
Prior to setting any volume, the exoPlayer responded to the device's volume buttons.
How to I get the exoPlayer to listen to the device's buttons again?
Version Info
ExoPlayer 2.11.3
Pixel 3 API level 29
The text was updated successfully, but these errors were encountered: