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

Volume ignored first time sound is played #13

Closed
initials opened this issue Apr 28, 2013 · 2 comments
Closed

Volume ignored first time sound is played #13

initials opened this issue Apr 28, 2013 · 2 comments

Comments

@initials
Copy link

The first time I call:
myGame.sound.play('gameOver', 0.1, false);

the volume is ignored and is played at volume=1. Subsequent times it is played, the volume param works.

@HackManiac
Copy link
Contributor

I ran into the same issue today and digged a bit deeper on this, although Rich already wrote in http://www.html5gamedevs.com/topic/445-sounds-in-phaser/#entry1993 that he is working on a rewrite of the SoundManager.

If you play a sound for the first time, it's loaded, but not yet decoded. So the SoundManager.prototype.play method will call SoundManager.prototype.decode, which then will perform two calls to Sound.prototype.play in short intervals:

  1. after decoding there is a call to Sound.prototype.setDecodedBuffer, which in turn calls the Sound.prototype.play function (with the correct volume configured).

  2. after step 1 the callback of SoundManager.prototype.decode is called which then calls SoundManager.prototype.play. Since only the key is given as an argument, the play function assumes a volume of 1.0.

I created a pull request for a possible interim solution until the new SoundManager is in place.

@photonstorm
Copy link
Collaborator

This is now in 0.9.5, will do well until new sound manager goes in.

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

No branches or pull requests

3 participants