Need help on controlling audio in ipad using javascript(mute/unmute)..any solution or thought will be helpful..
-
are you talk about of PhoneGAp - JqueryMobile/ – Akshay Joy May 06 '13 at 10:39
-
do we have access to controll audio ie mute/umute using phonegap – codebreaker May 06 '13 at 10:42
-
check this Post http://stackoverflow.com/questions/6322218/android-is-therey-anyway-to-volume-control-by-javasript – Akshay Joy May 06 '13 at 10:45
-
thanks its related to android i will see it.. is there any post regarding ipad..pls help – codebreaker May 06 '13 at 10:47
4 Answers
Try this is the OpenSource Library try it out

- 1,765
- 1
- 14
- 23
-
-
then how do you use html5 in Ipad application ? without PhoneGap how you able to communicate with IPad apis – Akshay Joy May 06 '13 at 10:59
-
S ur right my friend our app is just based on jquery and html5 not a phonegap based,anyway thanks for the help, i got it phonegap is only way to this... – codebreaker May 06 '13 at 11:03
-
phone-gap is the only way to achieve this task, none of the html5 api supports the ipad mute functionality
I wanted our app to don't play sounds when the iPhone is muted. After hours of searching I decided to try with the following parameter and works as expected:
myMedia.play({ playAudioWhenScreenIsLocked : false });
The documentation doesn't say anything that this parameter will make the sound to not play when the iPhone is muted, but it behaves like that.
I'm using PhoneGap 2.6.0 and the docs says:
Pass in this option to the play method to specify whether you want to play the audio of the media file when the screen is locked (this defaults to true if not set). If this is set to true, it will ignore the state of the hardware mute button.
Bad documented?

- 2,065
- 1
- 22
- 26
This is old, but as we were just solving this issue, I thought I'd put it up here.
iOS doesn't give you an explicit way to set your device's volume, but there is a way around this. To get around this, you can create an audio slider for your specific audio stream, hide it, and then programmatically set the slider's volume. This was figured out for ios and explained here iOS 7: MPMusicPlayerController volume deprecated. How to change device volume now?
However, that is not in javascript, and we use phonegap, so we forked the devgeeks library to create a way to programmatically control the device's playback volume from your app. This won't give you complete mute/unmute control, but you can at least set it to volume of 0 (muted) or something non-zero. We've ported it to iOS and Android, and our fork can be found here - https://github.com/shibbs/VolumeSlider We've created a pull request, but it's not yet in the main repo.
Below is some code showing how to use the library -
my_media = new Media(soundFile, onSuccess, onError); //create the media object
my_media.setVolume(1.0); //set your volume to w/e you want, we maxed it
volumeSlider = plugins.volumeSlider; //create the volume slider object
volumeSlider.createVolumeSlider(10,350,300,30); // origin x, origin y, width, height
volumeSlider.setVolumeSlider(1.0); //set your volume slider value to between 0 and 1
volumeSlider.resetVolumeSlider(); //this will reset the device volume to whatever it was set to when you created the volumeSlider.