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

Sound.stop does not exist #95

Open
oberhamsi opened this issue Jul 22, 2015 · 2 comments
Open

Sound.stop does not exist #95

oberhamsi opened this issue Jul 22, 2015 · 2 comments

Comments

@oberhamsi
Copy link
Member

via https://groups.google.com/forum/#!topic/gamejs/wFmkvKyiC6g

The Sound.stop() doesn't work as described in API.

function muteSound(sound) {
sound.stop();
}

bgMusic = new gamejs.audio.Sound(document.getElementById("bgMusic"));
muteSound(bgMusic);

So, it cause an error "audio.stop is not a function".

The solution is to use standard JavaScript methods.
bgMusic = document.getElementById("bgMusic");
muteSound(bgMusic);

function muteSound(sound) {
sound.pause();
}

@oberhamsi
Copy link
Member Author

fixed 3c27943

@oberhamsi oberhamsi reopened this Jul 22, 2015
@ambeam
Copy link

ambeam commented Jul 24, 2015

Cool thanks, I got one more question. In my game I got multiple sounds played at almost the same time: fire and explosion (fast rocket launcher or machinegun). On ubuntu (using chrome) I got all the sounds queued so even if I stop firing, the sound of shot and of explode is still playing. On Firefox game crashes after Your last update (when stop() method is called, exaclty here: audio.currentTime = 0;) with:

InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable

EDIT: one more question - is there any way to figure out if sound is still playing?

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

2 participants