强制观摩404重新请求打开接口播放

master
吕天方 6 months ago
parent 09dcf07a4c
commit 1266f214ce

@ -4,7 +4,7 @@
* @Author: JC9527
* @Date: 2024-01-09 23:08:15
* @LastEditors: JC9527
* @LastEditTime: 2024-08-15 11:05:25
* @LastEditTime: 2024-08-15 16:35:22
-->
<template>
<div class="map-main">
@ -622,6 +622,7 @@ export default {
onIcon:null,
offIcon:null,
videoPoint:[],
videoUrl:"",
};
},
methods: {
@ -1366,24 +1367,28 @@ export default {
}
},
//
initVideoPlayer(videoUrl){
initVideoPlayer(){
this.$nextTick(()=>{
var videoDom = document.getElementById('flvvideo')
var player = flvjs.createPlayer({
this.player = flvjs.createPlayer({
type: 'flv', // flv,
isLive: true, //
hasAudio: true, //
hanVideo: true, //
url: videoUrl, //
url: this.videoUrl, //
},{
// api
autoCleanupMinBackwardDuration: true, // SourceBuffer
})
player.attachMediaElement(videoDom)
player.load()
player.play()
this.player = player;
this.player.attachMediaElement(videoDom)
try {
this.player.load();
this.player.play();
this.listenVideo();
} catch (error) {
console.log(error);
}
//
// this.player.on(flvjs.Events.ERROR,(errType, errDetail)=>{
// // console.log(errType,'errTypeerrTypeerrType');
@ -1393,7 +1398,6 @@ export default {
// this.initVideoPlayer(videoUrl)
// }
// })
this.instantaneity(this.player,videoUrl)
})
},
destroyVideos() {
@ -1404,29 +1408,61 @@ export default {
this.player.destroy();
this.player = null;
},
//
instantaneity(player,videoUrl){
this.timer = setInterval(() => {
if (player && player.buffered && player.buffered.length) {
let end = player.buffered.end(0); // buffered
let diff = end - player.currentTime; // bufferedcurrentTime
if (diff >= 3) {// 3s
//
player.currentTime = end;//
player.currentTime = player.buffered.end(0);//
//
clearInterval(this.timer)
// player.pause();
// player.unload();
// player.detachMediaElement();
// player.destroy();
// player= null;
//
this.initVideoPlayer(videoUrl)
}
}
}, 2000); //2000
//
listenVideo() {
const that = this;
if(this.player) {
this.player.on(
flvjs.Events.ERROR,
(errorType, errorDetail, errorInfo) => {
// console.log("errorType", errorType);
// console.log("errorDetail", errorDetail);
// console.log("errorInfo", errorInfo);
if(errorInfo.code == 404) {
setTimeout(()=>{
videoSurveillance({
...that.videoCondition,
destID:that.personInfo.info.userId,
imei:that.personInfo.info.imei
}).then((res) => {
if (res.code == 200 && res.data.msg == "操作成功") {
setTimeout(()=>{
that.videoUrl = `http://10.236.2.28:54567/bjh-admin-server/jn/live/9999_${that.personInfo.info.userId}.flv`
if(!that.showVideo) {
videoSurveillance({destId:that.personInfo.info.userId,imei:that.personInfo.info.imei,msgType:0}).then(res=>{
that.personInfo.info.userId = "";
that.personInfo.info.imei = "";
})
that.destroyVideos();
} else {
that.initVideoPlayer();
}
},3000);
}
});
},2000)
} else {
//
that.destroyVideos();
that.initVideoPlayer();
}
}
);
//
this.player.on("statistics_info", function (res) {
if(that.lastDecodedFrames === 0){
that.lastDecodedFrames = res.decodedFrames
return
}
if(that.lastDecodedFrames != res.decodedFrames){
that.lastDecodedFrames = res.decodedFrames
}else{
that.lastDecodedFrames = 0
that.destroyVideos()
that.initVideoPlayer()
}
});
}
},
//
watchClick(){
@ -1436,7 +1472,8 @@ export default {
if(res.code == 200 && res.data.msg == '操作成功') {
// http://121.229.2.163:9291/live/9999 http://120.27.25.166:9305/live/9999_
setTimeout(()=>{
this.initVideoPlayer(`http://10.236.2.28:54567/bjh-admin-server/jn/live/9999_${this.personInfo.info.userId}.flv`)
this.videoUrl = `http://10.236.2.28:54567/bjh-admin-server/jn/live/9999_${this.personInfo.info.userId}.flv`
this.initVideoPlayer()
},3000)
}
})

Loading…
Cancel
Save