Browse Source

Merge branch 'develop' of http://39.106.31.193:9211/mengff/jihe-hs into develop

wangqin
刘朋 1 year ago
parent
commit
210a873141
  1. 19
      ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js

19
ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js

@ -56,21 +56,25 @@ export class HttpLivePlayer {
constructor(container, options) { constructor(container, options) {
this.container = container; this.container = container;
console.log("--- 视频 1 ---");
this.getUrl(options).then(() => { this.getUrl(options).then(() => {
console.log("--- 视频 3 ---");
this.initLiveVideo(); this.initLiveVideo();
}); });
} }
async getUrl({ camId, url } = {}) { async getUrl({ camId, url } = {}) {
console.log("--- 视频 2 ---");
if (camId) { if (camId) {
const { code, data } = await getCameraStream(camId).catch(() => ({})); const { code, data } = await getCameraStream(camId).catch(() => ({}));
console.log("--- 视频 2.4 ---");
if (code != 200) return; if (code != 200) return;
url = data.liveUrl; url = data.liveUrl;
} }
console.log("--- 视频 2.7 ---");
if (!url) return Promise.reject("获取 url 失败!"); if (!url) return Promise.reject("获取 url 失败!");
return (this.url = url); return (this.url = url);
@ -87,6 +91,8 @@ export class HttpLivePlayer {
} }
initLiveVideo() { initLiveVideo() {
console.log("--- 视频 4 ---");
this.destroy(); this.destroy();
this.lastDecodedFrames = null; 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) => { this.player.on(flvJs.Events.ERROR, (errorType, errorDetail, errorInfo) => {
console.log("errorType", errorType); console.log("errorType", errorType);
console.log("errorDetail", errorDetail); console.log("errorDetail", errorDetail);
@ -115,7 +126,7 @@ export class HttpLivePlayer {
// 视频出错后销毁重建 // 视频出错后销毁重建
this.destroy(); this.destroy();
this.init(); this.initLiveVideo();
}); });
// 视频断流 // 视频断流
@ -125,10 +136,8 @@ export class HttpLivePlayer {
} else { } else {
this.lastDecodedFrames = 0; this.lastDecodedFrames = 0;
this.destroy(); this.destroy();
this.init(); this.initLiveVideo();
} }
}); });
this.player.attachMediaElement(this.container);
} }
} }

Loading…
Cancel
Save