0

To my surprise, my Cordova app (I'm using Icenium) happily plays its background music and gameplay sounds even when my iPhone's sound switch is turned off and on. I believe that the switch is rigged to control "ringer off" and "ringer on," but all other commercial game apps appear to respect the switch and they don't play music when it's turned off.

What's the best way for me to make my Cordova app respect this physical switch and behave consistently with other applications? Thanks!

blaster
  • 8,876
  • 11
  • 48
  • 77

1 Answers1

0

If you are using the Cordova Media plugin to play sounds, you can use the following workaround for iOS:

oSound = new Media("sound.mp3");
oSound.play(
{
    playAudioWhenScreenIsLocked: false
});

It is designed to prevent sounds playing when the phone is locked, but also prevents them playing when the hardware mute switch is off, thus working around the problem.

j0ffe
  • 621
  • 8
  • 13