diff --git a/src/player.ts b/src/player.ts index 4c8310ff8..7b9f82b81 100644 --- a/src/player.ts +++ b/src/player.ts @@ -75,7 +75,7 @@ class Player extends EventEmitter { // Reset the media element, otherwise it keeps the previous source if (src) { - this.media.src = '' + this.media.removeAttribute('src') } try { @@ -90,7 +90,7 @@ class Player extends EventEmitter { this.media.pause() this.media.remove() this.revokeSrc() - this.media.src = '' + this.media.removeAttribute('src') // Load resets the media element to its initial state this.media.load() } diff --git a/src/wavesurfer.ts b/src/wavesurfer.ts index 5643b86ac..20fb5086b 100644 --- a/src/wavesurfer.ts +++ b/src/wavesurfer.ts @@ -451,8 +451,13 @@ class WaveSurfer extends Player { } } - // Set the mediaelement source - this.setSrc(url, blob) + if (url == '') { + // If no URL is provided, clear the mediaelement source + this.getMediaElement().removeAttribute('src') + } else { + // Set the mediaelement source + this.setSrc(url, blob) + } // Wait for the audio duration const audioDuration = await new Promise((resolve) => {