Milan Tejani
Milan Tejani

Reputation: 372

how to set volume of media player between 1 to 100% in android studio?

I am using video view, MediaPlayer and seek bar to control the volume of MediaPlayer but my question is how to give volume in percentage 1 to 100%?

Upvotes: 0

Views: 965

Answers (1)

Itamar Kerbel
Itamar Kerbel

Reputation: 2568

Use the MediaPlayer setVolume method. It gets 2 float values for left and right speakers and you can set the value for each between 0 to 1.0. This means that if you want the volume to be 70% just call:

mediaPlayer.setVolume(0.7, 0.7);

Upvotes: 1

Related Questions