Skip to content
Snippets Groups Projects
Commit 85f2aeed authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Wrap buffer.stop in try catch because safari explodes on multiple stops

parent 82620765
Branches
Tags
No related merge requests found
......@@ -45,7 +45,13 @@ class AudioBufferPlayer {
stop () {
if (this.source) {
this.source.onended = null; // Do not call onEnded callback if manually stopped
this.source.stop();
try {
this.source.stop();
} catch (e) {
// This is probably Safari, which dies when you call stop more than once
// which the spec says is allowed: https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode
console.log('Caught error while stopping buffer source node.'); // eslint-disable-line no-console
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment