|
|
@ -108,34 +108,13 @@ export class HttpLivePlayer { |
|
|
|
return Message.error("浏览器不支持播放 flv 视频流"); |
|
|
|
|
|
|
|
this.initLiveVideo(); |
|
|
|
|
|
|
|
getUrl(options).then((url) => { |
|
|
|
this.url = url; |
|
|
|
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() { |
|
|
|
if (!this.player) return; |
|
|
|
|
|
|
@ -148,11 +127,9 @@ export class HttpLivePlayer { |
|
|
|
|
|
|
|
initLiveVideo() { |
|
|
|
this.destroy(); |
|
|
|
|
|
|
|
this.player = null; |
|
|
|
this.lastDecodedFrames = null; |
|
|
|
|
|
|
|
console.log(this.url); |
|
|
|
|
|
|
|
if (!this.url) return; |
|
|
|
|
|
|
|
this.player = flvJs.createPlayer( |
|
|
@ -160,8 +137,6 @@ export class HttpLivePlayer { |
|
|
|
type: "flv", |
|
|
|
url: this.url, |
|
|
|
isLive: true, |
|
|
|
hasVideo: true, |
|
|
|
hasAudio: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
autoCleanupSourceBuffer: true, |
|
|
@ -200,12 +175,6 @@ export class HttpLivePlayer { |
|
|
|
console.log("errorType", errorType); |
|
|
|
console.log("errorDetail", errorDetail); |
|
|
|
console.log("errorInfo", errorInfo); |
|
|
|
// 视频出错后销毁重建
|
|
|
|
this.player.pause(); |
|
|
|
this.player.unload(); |
|
|
|
this.player.detachMediaElement(); |
|
|
|
this.destroy(); |
|
|
|
this.player = null; |
|
|
|
|
|
|
|
this.initLiveVideo(); |
|
|
|
}); |
|
|
|