From ff47583e06dd1d9dff9bbf3a11efec8c53e88e88 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Sat, 12 Feb 2022 19:40:51 -0800 Subject: [PATCH] Add disposal to audio switcher --- www/js/vjs/videojs-audio-switcher.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/js/vjs/videojs-audio-switcher.js b/www/js/vjs/videojs-audio-switcher.js index 6e9f6263..4c06f315 100644 --- a/www/js/vjs/videojs-audio-switcher.js +++ b/www/js/vjs/videojs-audio-switcher.js @@ -477,7 +477,7 @@ audio.currentTime = time; }; function audioSwitchPlugin(options) { - const {audioElement, audioTracks, debugInterval, syncInterval, volume} = options; + const {audioElement, audioTracks, debugInterval, syncInterval, volume, handleDisposal} = options; const player = this; const checkAudioElement = () => { const videoElement = player.el_; @@ -533,6 +533,13 @@ audioTracks.forEach(track => audioTrackList.addTrack(new videojs.AudioTrack(track))); audio.setAttribute('src', audioTracks[0].url); } + player.on('dispose', () => { + this.audio.pause(); + if(this.isOurAudio || handleDisposal){ + this.audio.remove(); + this.audioParent.remove(); + } + }); player.on('play', () => { syncTime(player, audio); if (audio.paused)