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

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

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

Loading…
Cancel
Save