From 2c4bbc084e2a77b0d6fd37cf2c5287feee3ca14d Mon Sep 17 00:00:00 2001 From: wangfukang Date: Mon, 8 Apr 2024 13:38:47 +0800 Subject: [PATCH] Fix: DOMException in destroy --- src/wavesurfer.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wavesurfer.ts b/src/wavesurfer.ts index 2091ba666..b0b372ef5 100644 --- a/src/wavesurfer.ts +++ b/src/wavesurfer.ts @@ -171,7 +171,6 @@ class WaveSurfer extends Player { playbackRate: options.audioRate, }) - this.abortController = new AbortController() this.options = Object.assign({}, defaultOptions, options) this.timer = new Timer() @@ -403,8 +402,12 @@ class WaveSurfer extends Player { // 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) }