From e3fa9e7028fc72e1f8b134a586c49efa89c48056 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 10 Sep 2025 16:56:03 +0800 Subject: [PATCH] bgufix --- bricks/videoplayer.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bricks/videoplayer.js b/bricks/videoplayer.js index 32a88cb..2017218 100644 --- a/bricks/videoplayer.js +++ b/bricks/videoplayer.js @@ -62,6 +62,17 @@ bricks.VideoPlayer = class extends bricks.VBox { this.bind('domoff', this.destroy.bind(this)); } + destroy(){ + if (this.hls) { + this.hls.destroy(); + this.hls = null; + } + if (this.dashPlayer) { + this.dashPlayer.reset(); + this.dashPlayer = null; + } + this.video.src = ''; // 清空 + } init() { this.loadVideo(this.opts.url); // 可替换为 mp4 / m3u8 / mpd this.bindEvents(); @@ -73,16 +84,7 @@ bricks.VideoPlayer = class extends bricks.VBox { loadVideo(src) { // 销毁旧播放器 - if (this.hls) { - this.hls.destroy(); - this.hls = null; - } - if (this.dashPlayer) { - this.dashPlayer.reset(); - this.dashPlayer = null; - } - - this.video.src = ''; // 清空 + this.destroy() if (src.endsWith('.m3u8') || src.includes('m3u8')) { if (Hls.isSupported()) {