From cd1a4b12f74c2804825071dfc7554aa856248f33 Mon Sep 17 00:00:00 2001 From: Joe <1712833832@qq.com> Date: Thu, 18 Jan 2024 10:16:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=86=85=E5=AE=B9=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Video/videoStream.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js b/ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js index 20e1a697..6c1b7e72 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js +++ b/ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js @@ -56,21 +56,25 @@ export class HttpLivePlayer { constructor(container, options) { this.container = container; + console.log("--- 视频 1 ---"); this.getUrl(options).then(() => { + console.log("--- 视频 3 ---"); this.initLiveVideo(); }); } async getUrl({ camId, url } = {}) { + console.log("--- 视频 2 ---"); if (camId) { const { code, data } = await getCameraStream(camId).catch(() => ({})); - + console.log("--- 视频 2.4 ---"); if (code != 200) return; url = data.liveUrl; } + console.log("--- 视频 2.7 ---"); if (!url) return Promise.reject("获取 url 失败!"); return (this.url = url); @@ -87,6 +91,8 @@ export class HttpLivePlayer { } initLiveVideo() { + console.log("--- 视频 4 ---"); + this.destroy(); this.lastDecodedFrames = null; @@ -108,6 +114,11 @@ export class HttpLivePlayer { } ); + this.player.attachMediaElement(this.container); + + this.player.load(); + this.player.play(); + this.player.on(flvJs.Events.ERROR, (errorType, errorDetail, errorInfo) => { console.log("errorType", errorType); console.log("errorDetail", errorDetail); @@ -115,7 +126,7 @@ export class HttpLivePlayer { // 视频出错后销毁重建 this.destroy(); - this.init(); + this.initLiveVideo(); }); // 视频断流 @@ -125,10 +136,8 @@ export class HttpLivePlayer { } else { this.lastDecodedFrames = 0; this.destroy(); - this.init(); + this.initLiveVideo(); } }); - - this.player.attachMediaElement(this.container); } }