Skip to content

Commit

Permalink
Check AC State (#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 Mar 8, 2017
1 parent a8a6a6f commit f6ce2c3
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 @@ -286,7 +286,7 @@ WaveSurfer.WebAudio = {
// 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 f6ce2c3

Please sign in to comment.