123 lines
3.8 KiB
JavaScript
123 lines
3.8 KiB
JavaScript
let layer, form, util, dtree, videoTree;
|
|
//默认播放窗口
|
|
let winDom = 'videoPlayer1';
|
|
let videoDom="windowbox1";
|
|
let nowDmoScree=1;
|
|
let playList=[];
|
|
layui.config({
|
|
base: "../../plugin/layui-v2.9.7/layui/dtree/", //此处路径请自行处理, 可以使用绝对路径
|
|
}).extend({
|
|
dtree: 'dtree'
|
|
}).use(['layer', 'form', 'dtree', 'util'], function () {
|
|
form = layui.form;
|
|
layer = layui.layer;
|
|
dtree = layui.dtree;
|
|
util = layui.util;
|
|
initVideo();
|
|
loadVideoTree();
|
|
$("body").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
|
|
$("#voi-photo").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
|
|
$("#video-tree").niceScroll({ cursorborder: "", cursorcolor: "#c0c4cc", boxzoom: true });
|
|
dtree.on("node('video-tree')", function (obj) {
|
|
if (obj.param.level === '1') {
|
|
return parent.layer.msg('请选择球机', { icon: 7 });
|
|
}
|
|
const nodeId = obj.param.nodeId;
|
|
let puid = nodeId.replace('QJ', '');
|
|
let online = puid.substring(puid.length - 1, puid.length);
|
|
if(online === '0'){
|
|
return parent.layer.msg("设备离线",{icon:7});
|
|
}
|
|
puid = puid.substring(0, puid.length - 2);
|
|
if (puid) {
|
|
parent.layer.msg("视频加载中,请稍候...", { icon: 16, scrollbar: false, time: 1000, });
|
|
let puidCz=true;
|
|
for (let i = 0; i < playList.length; i++) {
|
|
if( playList[i].puid==puid){
|
|
puidCz=false;
|
|
}
|
|
}
|
|
if(puidCz){
|
|
let newobj=getPlay(puid,getWindBox(),0);
|
|
playList.push(newobj);
|
|
playVideList();
|
|
}
|
|
console.log("4444");
|
|
console.log(playList);
|
|
videoObject.devCode = puid;
|
|
} else {
|
|
return parent.layer.msg('请选择球机', { icon: 7 });
|
|
}
|
|
});
|
|
|
|
util.event('lay-active', {
|
|
// 本地抓拍
|
|
photoLocal: function () {
|
|
screenshot();
|
|
},
|
|
// 远程录像
|
|
videoRemote: function () {
|
|
if (videoObject.playState) {
|
|
if (isEmpty(videoObject.remoteId)) {
|
|
// $(this).attr("src", "../../img/video/videoRemote-select.png");
|
|
remoteVideo(videoObject.devCode, 0);
|
|
} else {
|
|
// $(this).attr("src", "../../img/video/videoRemote.png");
|
|
stopRemote(videoObject.remoteId, 0)
|
|
}
|
|
} else {
|
|
parent.layer.msg("请先播放视频。。。", { icon: 7 });
|
|
}
|
|
},
|
|
// 远程抓拍
|
|
photoRemote: function () {
|
|
if (videoObject.playState) {
|
|
remoteVideo(videoObject.devCode, 1);
|
|
} else {
|
|
parent.layer.msg("请先播放视频。。。", { icon: 7 });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
/**
|
|
* 获取播放对象
|
|
* @param puid
|
|
* @param widBox
|
|
* @param state
|
|
*/
|
|
function getPlay(puid,widBox,state){
|
|
let playData={};
|
|
playData.puid=puid;
|
|
playData.windBox=widBox;
|
|
playData.state=state;
|
|
return playData;
|
|
}
|
|
|
|
//否则返回 最后一个box 进行替换
|
|
function getWindBox(){
|
|
for (let j = 1; j <= nowDmoScree; j++) {
|
|
let noCz=true;
|
|
let winBox2="videoPlayer"+j;
|
|
for (let i = 0; i < playList.length; i++) {
|
|
var widBox=playList[i].windBox;
|
|
if(widBox==winBox2){
|
|
noCz=false;
|
|
}
|
|
}
|
|
if(noCz){
|
|
return winBox2;
|
|
}
|
|
}
|
|
if(playList.length>nowDmoScree){
|
|
console.log(playList[0].windBox)
|
|
if(playList[0].flvPlayer){
|
|
destoryVideo(playList[0].flvPlayer)
|
|
}
|
|
playList.pop();
|
|
}
|
|
let obj=playList[0]
|
|
playList.pop();
|
|
return obj.windBox;
|
|
|
|
} |