How can I set volume level from ringtone instead of media volume level on MediaPlayer?
Go to Settings. Depending on your phone's Android version, do one of the following: Tap Sound > Advanced > Default notification sound. Tap Sound & notification > Notification sound.
Use setAudioStreamType(int)
to set the media type to type STREAM_RING
, then it should use the ringer volume instead of the default STREAM_MUSIC
.
Note that you must do this before the media is prepared, so you'll have to prepare it manually with setDataSource
instead of using MediaPlayer.create()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With