Skip to content

Commit cdc252c

Browse files
authored
fix(Record): clear media element source when no URL is provided (#4113)
1 parent 2fb97db commit cdc252c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/player.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Player<T extends GeneralEventTypes> extends EventEmitter<T> {
7575

7676
// Reset the media element, otherwise it keeps the previous source
7777
if (src) {
78-
this.media.src = ''
78+
this.media.removeAttribute('src')
7979
}
8080

8181
try {
@@ -90,7 +90,7 @@ class Player<T extends GeneralEventTypes> extends EventEmitter<T> {
9090
this.media.pause()
9191
this.media.remove()
9292
this.revokeSrc()
93-
this.media.src = ''
93+
this.media.removeAttribute('src')
9494
// Load resets the media element to its initial state
9595
this.media.load()
9696
}

src/wavesurfer.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,13 @@ class WaveSurfer extends Player<WaveSurferEvents> {
451451
}
452452
}
453453

454-
// Set the mediaelement source
455-
this.setSrc(url, blob)
454+
if (url == '') {
455+
// If no URL is provided, clear the mediaelement source
456+
this.getMediaElement().removeAttribute('src')
457+
} else {
458+
// Set the mediaelement source
459+
this.setSrc(url, blob)
460+
}
456461

457462
// Wait for the audio duration
458463
const audioDuration = await new Promise<number>((resolve) => {

0 commit comments

Comments
 (0)