close
The Wayback Machine - https://web.archive.org/web/20210207133553/https://github.com/google/ExoPlayer/issues/7307
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media volume buttons won't work on ExoPlayer after exoPlayer.setVolume #7307

Closed
arangob opened this issue Apr 28, 2020 · 3 comments
Closed

Media volume buttons won't work on ExoPlayer after exoPlayer.setVolume #7307

arangob opened this issue Apr 28, 2020 · 3 comments

Comments

@arangob
Copy link

@arangob arangob commented Apr 28, 2020

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

@marcbaechinger
Copy link
Contributor

@marcbaechinger marcbaechinger commented Apr 30, 2020

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.

@google-oss-bot
Copy link
Collaborator

@google-oss-bot google-oss-bot commented May 20, 2020

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!

@google-oss-bot
Copy link
Collaborator

@google-oss-bot google-oss-bot commented May 28, 2020

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.

@google google locked and limited conversation to collaborators Jul 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants