Browse Source

视频修改提交

wangqin
Joe 1 year ago
parent
commit
ad1d435370
  1. 35
      ruoyi-ui/src/views/JiHeExpressway/components/Video/videoStream.js

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

@ -108,34 +108,13 @@ export class HttpLivePlayer {
return Message.error("浏览器不支持播放 flv 视频流"); return Message.error("浏览器不支持播放 flv 视频流");
this.initLiveVideo(); this.initLiveVideo();
getUrl(options).then((url) => { getUrl(options).then((url) => {
this.url = url; this.url = url;
this.initLiveVideo(); this.initLiveVideo();
}); });
} }
// async getUrl({ camId, url, pileNum } = {}) {
// this.url = url;
// if (pileNum) {
// const { code, data } = await getNearCamera(pileNum).catch(() => ({}));
// if (code != 200 || !data?.length) return;
// camId = data[0].camId;
// }
// if (camId) {
// const { code, data } = await getCameraStream(camId).catch(() => ({}));
// if (code != 200) return;
// url = data.liveUrl;
// }
// if (!url) return Promise.reject("获取 url 失败!");
// this.url = url;
// }
destroy() { destroy() {
if (!this.player) return; if (!this.player) return;
@ -148,11 +127,9 @@ export class HttpLivePlayer {
initLiveVideo() { initLiveVideo() {
this.destroy(); this.destroy();
this.player = null;
this.lastDecodedFrames = null; this.lastDecodedFrames = null;
console.log(this.url);
if (!this.url) return; if (!this.url) return;
this.player = flvJs.createPlayer( this.player = flvJs.createPlayer(
@ -160,8 +137,6 @@ export class HttpLivePlayer {
type: "flv", type: "flv",
url: this.url, url: this.url,
isLive: true, isLive: true,
hasVideo: true,
hasAudio: false,
}, },
{ {
autoCleanupSourceBuffer: true, autoCleanupSourceBuffer: true,
@ -200,12 +175,6 @@ export class HttpLivePlayer {
console.log("errorType", errorType); console.log("errorType", errorType);
console.log("errorDetail", errorDetail); console.log("errorDetail", errorDetail);
console.log("errorInfo", errorInfo); console.log("errorInfo", errorInfo);
// 视频出错后销毁重建
this.player.pause();
this.player.unload();
this.player.detachMediaElement();
this.destroy();
this.player = null;
this.initLiveVideo(); this.initLiveVideo();
}); });

Loading…
Cancel
Save