From e56e64ee41d74d2f92479f2d53bd56e5c5082b31 Mon Sep 17 00:00:00 2001 From: lqzhgood <9134671+lqzhgood@users.noreply.github.com> Date: Thu, 25 Jul 2019 16:22:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=82=E8=BD=BD=204=E4=B8=AA=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/player.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/player.js b/src/js/player.js index 415159e..5b3205e 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -350,6 +350,7 @@ class DPlayer { hls.attachMedia(video); this.events.on('destroy', () => { hls.destroy(); + delete this.plugins.Hls; }); } else { @@ -369,12 +370,14 @@ class DPlayer { type: 'flv', url: video.src }); + this.plugins.flvjs = flvPlayer; flvPlayer.attachMediaElement(video); flvPlayer.load(); this.events.on('destroy', () => { flvPlayer.unload(); flvPlayer.detachMediaElement(); flvPlayer.destroy(); + delete this.plugins.flvjs; }); } else { @@ -389,9 +392,11 @@ class DPlayer { // https://github.com/Dash-Industry-Forum/dash.js case 'dash': if (dashjs) { - dashjs.MediaPlayer().create().initialize(video, video.src, false); + const dashjsPlayer = dashjs.MediaPlayer().create().initialize(video, video.src, false); + this.plugins.dash = dashjsPlayer; this.events.on('destroy', () => { dashjs.MediaPlayer().reset(); + delete this.plugins.dash; }); } else { @@ -401,10 +406,12 @@ class DPlayer { // https://github.com/webtorrent/webtorrent case 'webtorrent': - if (WebTorrent) { + if ( + ) { if (WebTorrent.WEBRTC_SUPPORT) { this.container.classList.add('dplayer-loading'); const client = new WebTorrent(); + this.plugins.webtorrent = client; const torrentId = video.src; client.add(torrentId, (torrent) => { const file = torrent.files.find((file) => file.name.endsWith('.mp4')); @@ -417,6 +424,7 @@ class DPlayer { this.events.on('destroy', () => { client.remove(torrentId); client.destroy(); + delete this.plugins.webtorrent; }); } else {