phaser
phaser copied to clipboard
Phaser.Sound.BaseSound resume() does not play the sound, unless play() was called prior to pause().
The idea is to update documentation here: https://newdocs.phaser.io/docs/3.55.2/Phaser.Sound.BaseSound#resume
or provide this feature:
Lets say we have following sound:
this.curLoadedMusicTrack = this.audioScene.sound.add(trackData.key, trackData.soundConfig);
and the scene audio is unlocked (Phaser.Sound.Events.UNLOCKED).
Then if for example App music is set to 'muted' and we call:
this.curLoadedMusicTrack.pause()
and later we decide to unpause, and call:
this.curLoadedMusicTrack.resume()
Then the curLoadedMusicTrack
will not play any music. However, when we call play()
before we call pause()
, like this:
this.curLoadedMusicTrack.play(); this.curLoadedMusicTrack.pause() this.curLoadedMusicTrack.resume()
Then all works fine, the music plays.
The idea is to be able to play music by simply calling pause()
and resume()
on loaded track, not having to call play()
, or is there a simpler way to do this i'm missing? Please advise. Looking back, this might be a pointless thing to ask for (its so minute), however it took me a while to realize, what is going on - why my music is not playing in specific case of music muted on start.
Thank you!
Only playing sounds can be paused, and only paused sounds can be resumed. There's no need to pause a sound that's just been added.
If you want to control playback only through pause()
and resume()
then I guess you should do play().pause()
immediately after adding, as you've discovered.
Would it be clearer if the docs say
Pause a sound, only if it is playing
etc.?
I've updated the docs to make this clear.