Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phaser.Sound.BaseSound resume() does not play the sound, unless play() was called prior to pause(). #6043

Closed
michalfialadev opened this issue Mar 14, 2022 · 2 comments

Comments

@michalfialadev
Copy link

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!

@samme
Copy link
Contributor

samme commented Mar 16, 2022

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.?

@photonstorm
Copy link
Collaborator

I've updated the docs to make this clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants