Can I set the volume?

210 views
Skip to first unread message

Sergio Tafoya

unread,
Oct 10, 2014, 12:55:23 PM10/10/14
to androi...@googlegroups.com
Hi everyone!

I wan to change the mediaplayer's volume, I did this:


    player = app.CreateMediaPlayer()
    player.SetFile("Snd/sonrisa.ogg");
    player.SetVolume(1.0,1.0)


In the debug console, I don't get any error, but it does not change the volume


Thanks!
Sergio

Jorge Ramirez

unread,
Oct 11, 2014, 4:27:56 PM10/11/14
to androi...@googlegroups.com
I answered Sergio on the Spanish thread. But basically as I understand it SetVolume(1,1) it's setting the volume to the maximum for both left and right audio channels.

Sergio Tafoya

unread,
Oct 13, 2014, 12:34:28 PM10/13/14
to androi...@googlegroups.com
Thanks again Jorge, it is that I saw in http://developer.android.com/reference/android/media/MediaPlayer.html#setVolume(float, float)

But I cant get more volume amount


:-/

Chris Hopkin

unread,
Oct 14, 2014, 12:29:15 PM10/14/14
to androi...@googlegroups.com
Hi Sergio

Jorge is right, the range of the SetVolume parameters are 0.0 to 1.0. Is the problem that the volume isn't changing at all whatever values you pass in?
If you run the Audio Player sample, the lower Seek Bar controls the volume, if you scroll this left and right, are you hearing the volume change?

Thanks

Chris

Preston Wilson

unread,
Apr 24, 2015, 3:31:50 AM4/24/15
to androi...@googlegroups.com
Hey -

It looks like this SetVolume function is setting a volume specific to the audio player itself... not the actual Android device's volume. So even if I set both channels to 1.0, if my device's Media Volume is all the way down I still can't hear the audio file. So to get maximum volume it's necessary to crank up the device's Media Volume (hardware volume buttons) and also player.SetVolume(1.0, 1.0).

I'm trying to build an alarm clock app, so this behavior is less than ideal. Is there a way with DroidScript to manipulate the actual master volume of the device's audio stream? And is there a way to play audio to a different audio stream, such as the Alarm stream (so that volume can be cranked to the max and I don't need to hear all the junk mail alerts overnight at full volume)?

Later...
P

Dave Smart

unread,
May 17, 2015, 5:07:27 AM5/17/15
to androi...@googlegroups.com
Hi Preston,

You can't currently control the master volume (I've added it to the todo list though) but you can control the ringer like this:-

app.SetRingerMode( "Silent" );  // also use "Vibrate" and "Normal"

also app.GetRingerMode() can be used.

Regards
David
Reply all
Reply to author
Forward
0 new messages