Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaPlayer - use ringtone volume instead of media volume

How can I set volume level from ringtone instead of media volume level on MediaPlayer?

like image 620
Mateusz Kaflowski Avatar asked Oct 10 '12 19:10

Mateusz Kaflowski


People also ask

How to change notification volume on Android?

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.


1 Answers

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().

like image 134
Tim Avatar answered Nov 15 '22 12:11

Tim