I'm playing some music from a service with Androids MediaPlayer. When the music is playing, the music volume can be changed by the volume rocker keys. However I don't want that the user can change the music volume during playback.
How can this be done?
It is possible when getting the keydown event and returning true, but that only works when the app is on top. Since I play the music from a service, it is also played when the screen is off or the app in background, so the volume can still be changed.
Another idea I had is to call
setVolumeControlStream( AudioManager.STREAM_RING );
after having started playing the music, but I can't call this from a service but only from an activity...
Or is it possible to play the music on another stream (Ring or alarm), but let the volume rocker still change the music stream?
Any ideas?