Skip to content

Commit

Permalink
Fix: DOMException in destroy (#3641)
Browse files Browse the repository at this point in the history
Co-authored-by: wangfukang <[email protected]>
  • Loading branch information
wfk007 and wfk007 authored Apr 8, 2024
1 parent 3f10c5a commit 1a97615
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/wavesurfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class WaveSurfer extends Player<WaveSurferEvents> {
playbackRate: options.audioRate,
})

this.abortController = new AbortController()
this.options = Object.assign({}, defaultOptions, options)
this.timer = new Timer()

Expand Down Expand Up @@ -403,8 +402,12 @@ class WaveSurfer extends Player<WaveSurferEvents> {

// Fetch the entire audio as a blob if pre-decoded data is not provided
if (!blob && !channelData) {
const fetchParams = this.options.fetchParams || {}
if (window.AbortController && !fetchParams.signal) {
this.abortController = new AbortController()
fetchParams.signal = this.abortController?.signal;
}
const onProgress = (percentage: number) => this.emit('loading', percentage)
const fetchParams = { signal: this.abortController?.signal, ...(this.options.fetchParams || {}) }
blob = await Fetcher.fetchBlob(url, onProgress, fetchParams)
}

Expand Down

0 comments on commit 1a97615

Please sign in to comment.