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

Stopping a stopped sound throws #59

Closed
aeons opened this issue Aug 22, 2017 · 1 comment
Closed

Stopping a stopped sound throws #59

aeons opened this issue Aug 22, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@aeons
Copy link

aeons commented Aug 22, 2017

Expected behavior

Clicking the stop sign twice with a sound playing, should stop the sound with no errors.

Actual behavior

The first click stops the sound, the second click throws an exception and stuff stops working

Steps to reproduce

Add a click-flag-hat and a play-sound-until-done under it. Click the green flag, click the stop button twice.

Operating system and browser

macOS and Safari 11

Notes

This can be fixed by changing the check in https://github.com/LLK/scratch-audio/blob/develop/src/SoundPlayer.js#L51 to if (this.bufferSource && this.isPlaying).

If possible I guess it should check if the buffer source is playing, but I'm not sure that's possible.

@ericrosenbaum
Copy link
Collaborator

Thanks for the bug report! This seems to be another one of those ways in which Safari's support for webAudio is slightly different from Chrome (MDN says, for the stop method, "If the node has already stopped, this method has no effect" which makes it sound like no error should be thrown, but apparently it can be).

You're correct that the buffer source node does not provide a way to check if it is playing directly, so we need the flag. Your check for the flag seems to work- I'll make a PR. Thanks!

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

No branches or pull requests

3 participants