Hmm, I created global flags for muting sound effects and music. I also added helper methods for playing sound effects and music. These helper methods decide if they should play the sound on volume 0 or volume 1 or different. So now I call these helper methods with sound key and they return Phaser.Sound object as per muted or not muted sound effects or music flag. Something like this:
var
soundEffectsMuted = false,
musicMuted = false,
muteSoundEffects = function () {
soundEffectsMuted = true;
},
unMuteSoundEffects = function () {
soundEffectsMuted = false;
},
areSoundEffectsMuted = function () {
return soundEffectsMuted;
},
muteMusic = function () {
musicMuted = true;
},
unMuteMusic = function () {
musicMuted = false;
},
isMusicMuted = function () {
return musicMuted;
},
playSoundEffect = function (soundKey, volume) {
var soundEffect = null;
if(!soundEffectsMuted)
soundEffect = gameObject.sound.play(soundKey, volume, false);
else
soundEffect = gameObject.sound.play(soundKey, 0, false);
return soundEffect;
},
playMusic = function (musicKey, volume) {
var musicSound = null;
if(!musicMuted)
musicSound = gameObject.sound.play(musicKey, volume, true);
else
musicSound = gameObject.sound.play(musicKey, 0, true);
return musicSound;
}