3

There seem to be a few threads floating around this topic but no definitive answer: if a user loads the app with sound enabled but later mutes his/her iPhone, how can we detect this in PhoneGap? Is there a callback for this event? The docs don't seem to list anything.

A second, related question: how to detect the status of the mute button? If someone has mute enabled, how do you detect this to avoid playing audio? The media.play() method only seems to have an option concerning whether to play audio when the screen is locked.

Thanks!

1

1 Answer 1

5

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
  • 1
    This worked for me. It would be nice to see the documentation updated to reflect this.
    – Joe
    Jun 14, 2013 at 18:15
  • Anyone knows if a similar flag is available for Android? I try to add it be it doesn't work and looking at the java code, I don't see it is being read (unlike in iOS code). Jun 3, 2015 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.