Skip to content

Commit

Permalink
Check AC State (katspaugh#1033)
Browse files Browse the repository at this point in the history
Should not close audiocontext when it's already closed. Chrome throws a warning if done so.
  • Loading branch information
Stoyvo authored and mspae committed Aug 20, 2017
1 parent 74afa3d commit 24150db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/webaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ export default class WebAudio extends util.Observer {
// close the audioContext if closeAudioContext option is set to true
if (this.params.closeAudioContext) {
// check if browser supports AudioContext.close()
if (typeof this.ac.close === 'function') {
if (typeof this.ac.close === 'function' && this.ac.state != 'closed') {
this.ac.close();
}
// clear the reference to the audiocontext
Expand Down

0 comments on commit 24150db

Please sign in to comment.