1045 lines
34 KiB
Plaintext
1045 lines
34 KiB
Plaintext
|
|
'use strict';
|
|||
|
|
var token = "";
|
|||
|
|
var device_list = [];
|
|||
|
|
var myPlayer = "";
|
|||
|
|
var presetPos = new Array();
|
|||
|
|
var pictureId = "";
|
|||
|
|
var storageId = "";
|
|||
|
|
var videoelem = "";
|
|||
|
|
var flvPlayer = "";
|
|||
|
|
var flvPlayerList = [];
|
|||
|
|
var playsite = 1; //播放的第几窗口
|
|||
|
|
var replay = 0;
|
|||
|
|
var chooseplaysite = 0; //选中的第几窗口,默认为0代表没有选择
|
|||
|
|
var kk=0;
|
|||
|
|
getValue();
|
|||
|
|
let ids = ['34130100001310000002','34130100001310000004','34130100001310000008','34130100001310000005'] ;
|
|||
|
|
let ids1 = ['34130100001310000003','34130100001310000001','34130100001310000007','34130100001310000006'] ;
|
|||
|
|
function getData(id){
|
|||
|
|
//alert(id)
|
|||
|
|
var data;
|
|||
|
|
$.ajax({
|
|||
|
|
type:"POST",
|
|||
|
|
url:bonuspath +'/backstage/seat/getinfoBysxt',
|
|||
|
|
data:{id: id},
|
|||
|
|
async: false,
|
|||
|
|
success:function(data) {
|
|||
|
|
localStorage.setItem("dataobj", data);
|
|||
|
|
data = JSON.parse(data);
|
|||
|
|
var html;
|
|||
|
|
for(var i=0;i<data.obj.list.length;i++){
|
|||
|
|
if(data.obj.list !=null){
|
|||
|
|
|
|||
|
|
/*if(data.obj.list[i] !=null){
|
|||
|
|
html = "<div style='left:"+data.obj.list[i].longitude+";top:"+data.obj.list[i].latitude+"'>"+data.obj.list[i].seat+':'+data.obj.list[i].name+"</div>";
|
|||
|
|
// $("#overlay").append(html);
|
|||
|
|
}*/
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return data;
|
|||
|
|
},
|
|||
|
|
error:function(data){
|
|||
|
|
alert("服务器")
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
function canvasVideo(){
|
|||
|
|
var kc=$("#kc").val();
|
|||
|
|
var zw=$("#zw").val();
|
|||
|
|
if(kc !="" && zw !=""){
|
|||
|
|
var v = document.getElementById("video1");
|
|||
|
|
var c = document.getElementById("mycanvas");
|
|||
|
|
var height = c.height;
|
|||
|
|
var width = c.width;
|
|||
|
|
var ctx = c.getContext('2d');
|
|||
|
|
ctx.drawImage(v, 0, 0, width, height);
|
|||
|
|
var dataURL = c.toDataURL("image/png", 0.1);
|
|||
|
|
var imgData = dataURL.replace("data:image/png;base64,", "");
|
|||
|
|
$.ajax({
|
|||
|
|
url: bonuspath+"/backstage/camera/img_upload",
|
|||
|
|
data: {
|
|||
|
|
"imgBase64Data": imgData,
|
|||
|
|
kc:kc,
|
|||
|
|
zw:zw
|
|||
|
|
},
|
|||
|
|
dataType: 'json',
|
|||
|
|
type: 'post',
|
|||
|
|
timeout: 100000,
|
|||
|
|
success: function(data) {
|
|||
|
|
$("#jietuPicture").attr('src',data);
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
error: function(xhr, type, errorThrown) {
|
|||
|
|
console.log(errorThrown);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}else{
|
|||
|
|
alert("请输入给考生的考场号和座位号")
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//播放延迟处理
|
|||
|
|
function progress(e) {
|
|||
|
|
var bf = e.srcElement.buffered;
|
|||
|
|
var currentTime = e.srcElement.currentTime;
|
|||
|
|
if (bf.length > 0) {
|
|||
|
|
let end = bf.end(0);
|
|||
|
|
if (end - currentTime > 1.5) {
|
|||
|
|
e.srcElement.currentTime = end - 0.1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//post请求
|
|||
|
|
function requestPost(router, params,url, callback) {
|
|||
|
|
var self = this;
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: url + router,
|
|||
|
|
data: params,
|
|||
|
|
traditional: true,
|
|||
|
|
dataType: 'json',
|
|||
|
|
async: true,
|
|||
|
|
complete: function (rv) {
|
|||
|
|
if (typeof callback == 'function') callback(rv)
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
//get请求
|
|||
|
|
function requestGet(router, callback) {
|
|||
|
|
var self = this;
|
|||
|
|
var url = _cf.q2http_url + router;
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'get',
|
|||
|
|
url: url,
|
|||
|
|
dataType: 'json',
|
|||
|
|
async: true,
|
|||
|
|
complete: function (rv) {
|
|||
|
|
if (typeof callback == 'function') callback(rv)
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
//创建平台连接
|
|||
|
|
function connect() {
|
|||
|
|
var self = this;
|
|||
|
|
var params = {
|
|||
|
|
"address": _cf.connParams.address,
|
|||
|
|
"port": _cf.connParams.port,
|
|||
|
|
"user": _cf.connParams.user,
|
|||
|
|
"password": _cf.connParams.password,
|
|||
|
|
"epid": _cf.connParams.epid,
|
|||
|
|
"fixaddr": _cf.connParams.bfix
|
|||
|
|
}
|
|||
|
|
requestPost('login', params,_cf.q2http_url , function (rv) {
|
|||
|
|
let self = this;
|
|||
|
|
var result = {
|
|||
|
|
errcode: -1,
|
|||
|
|
token: ''
|
|||
|
|
}
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
if (respJSON.hasOwnProperty('errcode')) {
|
|||
|
|
result.errcode = respJSON.errcode;
|
|||
|
|
}
|
|||
|
|
if (respJSON.hasOwnProperty('token')) {
|
|||
|
|
result.token = respJSON.token;
|
|||
|
|
result.errcode = 0;
|
|||
|
|
token = result.token;
|
|||
|
|
fetch_device(0, 200);
|
|||
|
|
//存储设备列表
|
|||
|
|
device_resource_tree();
|
|||
|
|
}
|
|||
|
|
for(let i=0;i<ids.length;i++){
|
|||
|
|
playvideo(ids[i],'0',(i+1))
|
|||
|
|
}
|
|||
|
|
var url = _cf.websocket_url + "?token=" + token;
|
|||
|
|
if ("WebSocket" in window) {
|
|||
|
|
ws = new WebSocket(url);
|
|||
|
|
ws.onopen = function () {}
|
|||
|
|
ws.onmessage = function (evt) {
|
|||
|
|
if (typeof evt == "object" && evt.data) {
|
|||
|
|
var msg = $.xml2json(evt.data);
|
|||
|
|
|
|||
|
|
var event = msg.E || null;
|
|||
|
|
|
|||
|
|
if (event) {
|
|||
|
|
if (event.ID == "E_CU_Online") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '用户上线(' + (event.Desc.UserID + '@' + event.Desc.EPID) + ')',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else if (event.ID == "E_CU_Offline") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '用户下线(' + (event.Desc.UserID + '@' + event.Desc.EPID) + ')',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else if (event.ID == "E_PU_Online") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '设备上线.',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else if (event.ID == "E_PU_Offline") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '设备下线.',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
console.log(" no treatment event id " + (event["ID"] ? event["ID"] : ""));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
ws.onclose = function () {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
ws.onerror = function () {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
console.log("not support web socket.");
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//创建二平台连接
|
|||
|
|
function connect1() {
|
|||
|
|
var self = this;
|
|||
|
|
var params1 = {
|
|||
|
|
"address": _cf1.connParams.address,
|
|||
|
|
"port": _cf1.connParams.port,
|
|||
|
|
"user": _cf1.connParams.user,
|
|||
|
|
"password": _cf1.connParams.password,
|
|||
|
|
"epid": _cf1.connParams.epid,
|
|||
|
|
"fixaddr": _cf1.connParams.bfix
|
|||
|
|
}
|
|||
|
|
requestPost('login',params1,_cf1.q2http_url, function (rv) {
|
|||
|
|
let self = this;
|
|||
|
|
var result = {
|
|||
|
|
errcode: -1,
|
|||
|
|
token: ''
|
|||
|
|
}
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
if (respJSON.hasOwnProperty('errcode')) {
|
|||
|
|
result.errcode = respJSON.errcode;
|
|||
|
|
}
|
|||
|
|
if (respJSON.hasOwnProperty('token')) {
|
|||
|
|
result.token = respJSON.token;
|
|||
|
|
result.errcode = 0;
|
|||
|
|
token = result.token;
|
|||
|
|
fetch_device(0, 200);
|
|||
|
|
//存储设备列表
|
|||
|
|
device_resource_tree();
|
|||
|
|
}
|
|||
|
|
for(let i=0;i<ids1.length;i++){
|
|||
|
|
playvideo1(ids1[i],'0',(i+5))
|
|||
|
|
}
|
|||
|
|
var url = _cf1.websocket_url + "?token=" + token;
|
|||
|
|
if ("WebSocket" in window) {
|
|||
|
|
ws = new WebSocket(url);
|
|||
|
|
ws.onopen = function () {}
|
|||
|
|
ws.onmessage = function (evt) {
|
|||
|
|
if (typeof evt == "object" && evt.data) {
|
|||
|
|
var msg = $.xml2json(evt.data);
|
|||
|
|
|
|||
|
|
var event = msg.E || null;
|
|||
|
|
|
|||
|
|
if (event) {
|
|||
|
|
if (event.ID == "E_CU_Online") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '用户上线(' + (event.Desc.UserID + '@' + event.Desc.EPID) + ')',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else if (event.ID == "E_CU_Offline") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '用户下线(' + (event.Desc.UserID + '@' + event.Desc.EPID) + ')',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else if (event.ID == "E_PU_Online") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '设备上线.',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else if (event.ID == "E_PU_Offline") {
|
|||
|
|
$.messager.show({
|
|||
|
|
title: '消息',
|
|||
|
|
msg: '设备下线.',
|
|||
|
|
timeout: 3000,
|
|||
|
|
showType: 'slide'
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
console.log(" no treatment event id " + (event["ID"] ? event["ID"] : ""));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
ws.onclose = function () {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
ws.onerror = function () {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
console.log("not support web socket.");
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
function bonusRequest(router,callback){
|
|||
|
|
var self = this;
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: router,
|
|||
|
|
dataType: 'json',
|
|||
|
|
async: true,
|
|||
|
|
complete: function (rv) {
|
|||
|
|
if (typeof callback == 'function') callback(rv)
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取设备列表
|
|||
|
|
function fetch_device(offset, count) {
|
|||
|
|
var self = this;
|
|||
|
|
//获取设备列表的接口
|
|||
|
|
// var router = 'CAS/C_CAS_QueryPUIDSets?offset=' + offset + '&count=' + count + '&token=' + token;
|
|||
|
|
var url = bonuspath+"/mcu/getBallList";
|
|||
|
|
bonusRequest(url, rv => {
|
|||
|
|
//alert(JSON.stringify(rv));
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
device_list = respJSON.obj;
|
|||
|
|
//把设备加载到指定的位置
|
|||
|
|
render_device_nodes(device_list);
|
|||
|
|
|
|||
|
|
if (device_list.length == count) {
|
|||
|
|
offset += count;
|
|||
|
|
fetch_device(offset, count);
|
|||
|
|
} else {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function render_device_nodes(device_list) {
|
|||
|
|
let data = new Array();
|
|||
|
|
for (var i = 0; i < device_list.length; i++) {
|
|||
|
|
var list = device_list[i];
|
|||
|
|
var icon = "icon-device-offline";
|
|||
|
|
if (list.onlineFlag == 1) {
|
|||
|
|
icon = "icon-device-online";
|
|||
|
|
data.push({
|
|||
|
|
id: list.id,
|
|||
|
|
text: list.name,
|
|||
|
|
iconCls: icon,
|
|||
|
|
attributes: {
|
|||
|
|
list: list
|
|||
|
|
},
|
|||
|
|
state: "closed",
|
|||
|
|
children: [{
|
|||
|
|
text: '正在查询资源……'
|
|||
|
|
}]
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
$('#resource_tree').tree('append', {
|
|||
|
|
data: data
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function device_resource_tree() {
|
|||
|
|
$('#resource_tree').tree({
|
|||
|
|
data: [],
|
|||
|
|
onBeforeLoad: function () {},
|
|||
|
|
onDblClick: function (node) {
|
|||
|
|
console.log('node',node)
|
|||
|
|
playvideo(node);
|
|||
|
|
},
|
|||
|
|
onExpand: function (node) {
|
|||
|
|
|
|||
|
|
var childs = $(this).tree('getChildren', node.target);
|
|||
|
|
if (childs.length == 1) {
|
|||
|
|
if (node.children[0].text == "正在查询资源……") {
|
|||
|
|
var newList = node.attributes.list;
|
|||
|
|
var params = {
|
|||
|
|
puid: [newList.id]
|
|||
|
|
};
|
|||
|
|
var url = bonuspath+"/mcu/getBallList?puid="+newList.id;
|
|||
|
|
|
|||
|
|
bonusRequest(url, rv => {
|
|||
|
|
console.log(rv);
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
var res = respJSON.obj;
|
|||
|
|
var videoList = [];
|
|||
|
|
var childNodes = new Array();
|
|||
|
|
for (let j = 0; j < res.length; j++) {
|
|||
|
|
var resource = res[j];
|
|||
|
|
if (resource.type != "IV") {
|
|||
|
|
continue;
|
|||
|
|
} else {
|
|||
|
|
videoList = resource
|
|||
|
|
var iconsuffix = "offline";
|
|||
|
|
var icon = "icon-camera-" + iconsuffix;
|
|||
|
|
if (newList.onlineFlag == 1) {
|
|||
|
|
iconsuffix = "online";
|
|||
|
|
icon = "icon-camera-" + iconsuffix;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
childNodes.push({
|
|||
|
|
id: newList.id + "_" + videoList.ballIndex,
|
|||
|
|
text: videoList.name,
|
|||
|
|
iconCls: icon,
|
|||
|
|
attributes: {
|
|||
|
|
newList: newList,
|
|||
|
|
self: videoList
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (childNodes.length > 0) {
|
|||
|
|
//删除load节点
|
|||
|
|
for (var i = 0; i < childs.length; i++) {
|
|||
|
|
$('#resource_tree').tree('remove', childs[i].target);
|
|||
|
|
}
|
|||
|
|
$('#resource_tree').tree('append', {
|
|||
|
|
parent: node.target,
|
|||
|
|
data: childNodes
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function CheckifSelectExamNo(){
|
|||
|
|
if($("#kc").val() ==""){
|
|||
|
|
alert("请输入本场考试的考场号")
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
function playvideo(puid,idx,site) {
|
|||
|
|
//alert("node"+node)
|
|||
|
|
//校验是否选择考场号
|
|||
|
|
// CheckifSelectExamNo();
|
|||
|
|
//console.log('node',node)
|
|||
|
|
//var puid = node.attributes.newList.id;
|
|||
|
|
//var idx = node.attributes.self.ballIndex;
|
|||
|
|
//播视频接口
|
|||
|
|
let url = _cf.q2http_url + "stream.flv?puid=" + puid + "&idx=" + idx + "&stream=0&token=" + token;
|
|||
|
|
if (flvjs.isSupported()) {
|
|||
|
|
var videoElement = "";
|
|||
|
|
//4个窗口循环播放
|
|||
|
|
if (site == 2) {
|
|||
|
|
videoElement = document.getElementById('video2');
|
|||
|
|
} else if (site == 3) {
|
|||
|
|
videoElement = document.getElementById('video3');
|
|||
|
|
} else if (site == 4) {
|
|||
|
|
videoElement = document.getElementById('video4');
|
|||
|
|
} else if (site == 1) {
|
|||
|
|
videoElement = document.getElementById('video1');
|
|||
|
|
} else if (site == 5) {
|
|||
|
|
videoElement = document.getElementById('video5');
|
|||
|
|
} else if (site == 6) {
|
|||
|
|
videoElement = document.getElementById('video6');
|
|||
|
|
} else if (site == 7) {
|
|||
|
|
videoElement = document.getElementById('video7');
|
|||
|
|
} else if (site == 8) {
|
|||
|
|
videoElement = document.getElementById('video8');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//循环播放后清除对应窗口数据缓存
|
|||
|
|
if (flvPlayerList && flvPlayerList.length > 0 && replay == 1) {
|
|||
|
|
//去掉空播放对象
|
|||
|
|
flvPlayerList.forEach(function (item, index) {
|
|||
|
|
if (!item) {
|
|||
|
|
flvPlayerList.splice(index, 1);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
for (let v of flvPlayerList) {
|
|||
|
|
if (v.key == playsite) {
|
|||
|
|
if (v.value) {
|
|||
|
|
v.value.unload();
|
|||
|
|
v.value.detachMediaElement();
|
|||
|
|
v.value.destroy();
|
|||
|
|
v.value = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
videoElement.controls = false;
|
|||
|
|
flvPlayer = flvjs.createPlayer({
|
|||
|
|
type: 'flv',
|
|||
|
|
url: url,
|
|||
|
|
isLive: true,
|
|||
|
|
hasAudio: false
|
|||
|
|
}, {
|
|||
|
|
enableWorker: false,
|
|||
|
|
autoCleanupSourceBuffer: true, //清理缓冲区
|
|||
|
|
enableStashBuffer: false,
|
|||
|
|
stashInitialSize: 128, // 减少首桢显示等待时长
|
|||
|
|
statisticsInfoReportInterval: 600
|
|||
|
|
});
|
|||
|
|
flvPlayer.attachMediaElement(videoElement);
|
|||
|
|
flvPlayer.load();
|
|||
|
|
|
|||
|
|
setTimeout(function () {
|
|||
|
|
flvPlayer.play();
|
|||
|
|
}, 100);
|
|||
|
|
|
|||
|
|
flvPlayer.on("scriptdata_arrived", function (e) {
|
|||
|
|
console.log("视频正在播放");
|
|||
|
|
|
|||
|
|
//记下存放flvPlayer
|
|||
|
|
flvPlayerList.push({ key: playsite, value: flvPlayer });
|
|||
|
|
//去掉空播放对象
|
|||
|
|
flvPlayerList.forEach(function (item, index) {
|
|||
|
|
console.log(item);
|
|||
|
|
if (!item.value) {
|
|||
|
|
flvPlayerList.splice(index, 1);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//如果4个播放窗口播完开始循环播放,从第一个窗口播放
|
|||
|
|
if (playsite < 8) {
|
|||
|
|
playsite += 1;
|
|||
|
|
} else {
|
|||
|
|
playsite = 1;
|
|||
|
|
replay = 1;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
flvPlayer.on("error", function (e) {
|
|||
|
|
//出现错误,重新播放
|
|||
|
|
console.log("出现错误,重新播放");
|
|||
|
|
console.log('url', url);
|
|||
|
|
setTimeout(() => {
|
|||
|
|
if (flvPlayerList && flvPlayerList.length) {
|
|||
|
|
flvPlayerList[playsite - 1].unload();
|
|||
|
|
flvPlayerList[playsite - 1].detachMediaElement();
|
|||
|
|
flvPlayerList[playsite - 1].destroy();
|
|||
|
|
flvPlayerList[playsite - 1] = ""
|
|||
|
|
}
|
|||
|
|
var videoElement = document.getElementById('video1');
|
|||
|
|
if (playsite == 2) {
|
|||
|
|
videoElement = document.getElementById('video2');
|
|||
|
|
} else if (playsite == 3) {
|
|||
|
|
videoElement = document.getElementById('video3');
|
|||
|
|
} else if (playsite == 4) {
|
|||
|
|
videoElement = document.getElementById('video4');
|
|||
|
|
} else if (playsite == 1) {
|
|||
|
|
videoElement = document.getElementById('video1');
|
|||
|
|
} else if (playsite == 5) {
|
|||
|
|
videoElement = document.getElementById('video5');
|
|||
|
|
} else if (playsite == 6) {
|
|||
|
|
videoElement = document.getElementById('video6');
|
|||
|
|
} else if (playsite == 7) {
|
|||
|
|
videoElement = document.getElementById('video7');
|
|||
|
|
} else if (playsite == 8) {
|
|||
|
|
videoElement = document.getElementById('video8');
|
|||
|
|
}
|
|||
|
|
if (videoelem) {
|
|||
|
|
videoElement = videoelem;
|
|||
|
|
}
|
|||
|
|
videoElement.controls = false;
|
|||
|
|
var flvPlayer = new flv.createPlayer({
|
|||
|
|
type: 'flv',
|
|||
|
|
isLive: true,
|
|||
|
|
hasAudio: false,
|
|||
|
|
url: url
|
|||
|
|
}, {
|
|||
|
|
enableWorker: false,
|
|||
|
|
autoCleanupSourceBuffer: true,
|
|||
|
|
enableStashBuffer: false,
|
|||
|
|
stashInitialSize: 128, // 减少首桢显示等待时长
|
|||
|
|
statisticsInfoReportInterval: 600
|
|||
|
|
});
|
|||
|
|
flvPlayer.attachMediaElement(videoElement);
|
|||
|
|
flvPlayer.load();
|
|||
|
|
flvPlayer.play();
|
|||
|
|
}, 100)
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
createPlayer();
|
|||
|
|
myPlayer.src(url);
|
|||
|
|
myPlayer.on("error", e => {
|
|||
|
|
setTimeout(e => {
|
|||
|
|
myPlayer.src(url);
|
|||
|
|
myPlayer.load(url);
|
|||
|
|
myPlayer.play();
|
|||
|
|
}, 1000);
|
|||
|
|
});
|
|||
|
|
myPlayer.on("ended", e => {
|
|||
|
|
setTimeout((e) => {
|
|||
|
|
myPlayer.src(url);
|
|||
|
|
myPlayer.load(url);
|
|||
|
|
myPlayer.play();
|
|||
|
|
}, 1000);
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function playvideo1(puid,idx,site) {
|
|||
|
|
//alert("node"+node)
|
|||
|
|
//校验是否选择考场号
|
|||
|
|
// CheckifSelectExamNo();
|
|||
|
|
//console.log('node',node)
|
|||
|
|
//var puid = node.attributes.newList.id;
|
|||
|
|
//var idx = node.attributes.self.ballIndex;
|
|||
|
|
//播视频接口
|
|||
|
|
let url = _cf1.q2http_url + "stream.flv?puid=" + puid + "&idx=" + idx + "&stream=0&token=" + token;
|
|||
|
|
if (flvjs.isSupported()) {
|
|||
|
|
var videoElement = "";
|
|||
|
|
//4个窗口循环播放
|
|||
|
|
if (site == 2) {
|
|||
|
|
videoElement = document.getElementById('video2');
|
|||
|
|
} else if (site == 3) {
|
|||
|
|
videoElement = document.getElementById('video3');
|
|||
|
|
} else if (site == 4) {
|
|||
|
|
videoElement = document.getElementById('video4');
|
|||
|
|
} else if (site == 1) {
|
|||
|
|
videoElement = document.getElementById('video1');
|
|||
|
|
} else if (site == 5) {
|
|||
|
|
videoElement = document.getElementById('video5');
|
|||
|
|
} else if (site == 6) {
|
|||
|
|
videoElement = document.getElementById('video6');
|
|||
|
|
} else if (site == 7) {
|
|||
|
|
videoElement = document.getElementById('video7');
|
|||
|
|
} else if (site == 8) {
|
|||
|
|
videoElement = document.getElementById('video8');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//循环播放后清除对应窗口数据缓存
|
|||
|
|
if (flvPlayerList && flvPlayerList.length > 0 && replay == 1) {
|
|||
|
|
//去掉空播放对象
|
|||
|
|
flvPlayerList.forEach(function (item, index) {
|
|||
|
|
if (!item) {
|
|||
|
|
flvPlayerList.splice(index, 1);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
for (let v of flvPlayerList) {
|
|||
|
|
if (v.key == playsite) {
|
|||
|
|
if (v.value) {
|
|||
|
|
v.value.unload();
|
|||
|
|
v.value.detachMediaElement();
|
|||
|
|
v.value.destroy();
|
|||
|
|
v.value = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
videoElement.controls = false;
|
|||
|
|
flvPlayer = flvjs.createPlayer({
|
|||
|
|
type: 'flv',
|
|||
|
|
url: url,
|
|||
|
|
isLive: true,
|
|||
|
|
hasAudio: false
|
|||
|
|
}, {
|
|||
|
|
enableWorker: false,
|
|||
|
|
autoCleanupSourceBuffer: true, //清理缓冲区
|
|||
|
|
enableStashBuffer: false,
|
|||
|
|
stashInitialSize: 128, // 减少首桢显示等待时长
|
|||
|
|
statisticsInfoReportInterval: 600
|
|||
|
|
});
|
|||
|
|
flvPlayer.attachMediaElement(videoElement);
|
|||
|
|
flvPlayer.load();
|
|||
|
|
|
|||
|
|
setTimeout(function () {
|
|||
|
|
flvPlayer.play();
|
|||
|
|
}, 100);
|
|||
|
|
|
|||
|
|
flvPlayer.on("scriptdata_arrived", function (e) {
|
|||
|
|
console.log("视频正在播放");
|
|||
|
|
|
|||
|
|
//记下存放flvPlayer
|
|||
|
|
flvPlayerList.push({ key: playsite, value: flvPlayer });
|
|||
|
|
//去掉空播放对象
|
|||
|
|
flvPlayerList.forEach(function (item, index) {
|
|||
|
|
console.log(item);
|
|||
|
|
if (!item.value) {
|
|||
|
|
flvPlayerList.splice(index, 1);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//如果4个播放窗口播完开始循环播放,从第一个窗口播放
|
|||
|
|
if (playsite < 8) {
|
|||
|
|
playsite += 1;
|
|||
|
|
} else {
|
|||
|
|
playsite = 1;
|
|||
|
|
replay = 1;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
flvPlayer.on("error", function (e) {
|
|||
|
|
//出现错误,重新播放
|
|||
|
|
console.log("出现错误,重新播放");
|
|||
|
|
console.log('url', url);
|
|||
|
|
setTimeout(() => {
|
|||
|
|
if (flvPlayerList && flvPlayerList.length) {
|
|||
|
|
flvPlayerList[playsite - 1].unload();
|
|||
|
|
flvPlayerList[playsite - 1].detachMediaElement();
|
|||
|
|
flvPlayerList[playsite - 1].destroy();
|
|||
|
|
flvPlayerList[playsite - 1] = ""
|
|||
|
|
}
|
|||
|
|
var videoElement = document.getElementById('video1');
|
|||
|
|
if (playsite == 2) {
|
|||
|
|
videoElement = document.getElementById('video2');
|
|||
|
|
} else if (playsite == 3) {
|
|||
|
|
videoElement = document.getElementById('video3');
|
|||
|
|
} else if (playsite == 4) {
|
|||
|
|
videoElement = document.getElementById('video4');
|
|||
|
|
} else if (playsite == 1) {
|
|||
|
|
videoElement = document.getElementById('video1');
|
|||
|
|
} else if (playsite == 5) {
|
|||
|
|
videoElement = document.getElementById('video5');
|
|||
|
|
} else if (playsite == 6) {
|
|||
|
|
videoElement = document.getElementById('video6');
|
|||
|
|
} else if (playsite == 7) {
|
|||
|
|
videoElement = document.getElementById('video7');
|
|||
|
|
} else if (playsite == 8) {
|
|||
|
|
videoElement = document.getElementById('video8');
|
|||
|
|
}
|
|||
|
|
if (videoelem) {
|
|||
|
|
videoElement = videoelem;
|
|||
|
|
}
|
|||
|
|
videoElement.controls = false;
|
|||
|
|
var flvPlayer = new flv.createPlayer({
|
|||
|
|
type: 'flv',
|
|||
|
|
isLive: true,
|
|||
|
|
hasAudio: false,
|
|||
|
|
url: url
|
|||
|
|
}, {
|
|||
|
|
enableWorker: false,
|
|||
|
|
autoCleanupSourceBuffer: true,
|
|||
|
|
enableStashBuffer: false,
|
|||
|
|
stashInitialSize: 128, // 减少首桢显示等待时长
|
|||
|
|
statisticsInfoReportInterval: 600
|
|||
|
|
});
|
|||
|
|
flvPlayer.attachMediaElement(videoElement);
|
|||
|
|
flvPlayer.load();
|
|||
|
|
flvPlayer.play();
|
|||
|
|
}, 100)
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
createPlayer();
|
|||
|
|
myPlayer.src(url);
|
|||
|
|
myPlayer.on("error", e => {
|
|||
|
|
setTimeout(e => {
|
|||
|
|
myPlayer.src(url);
|
|||
|
|
myPlayer.load(url);
|
|||
|
|
myPlayer.play();
|
|||
|
|
}, 1000);
|
|||
|
|
});
|
|||
|
|
myPlayer.on("ended", e => {
|
|||
|
|
setTimeout((e) => {
|
|||
|
|
myPlayer.src(url);
|
|||
|
|
myPlayer.load(url);
|
|||
|
|
myPlayer.play();
|
|||
|
|
}, 1000);
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function createPlayer() {
|
|||
|
|
|
|||
|
|
var videoElement = document.getElementById('video1');
|
|||
|
|
if (videoelem) {
|
|||
|
|
videoElement = videoelem;
|
|||
|
|
}
|
|||
|
|
myPlayer = new videojs('videoElement', {
|
|||
|
|
"techOrder": ["html5", "flash"],
|
|||
|
|
preload: 'auto',
|
|||
|
|
posterImage: false,
|
|||
|
|
controls: true,
|
|||
|
|
autoplay: true,
|
|||
|
|
bigPlayButton: false,
|
|||
|
|
videoWidth: 704,
|
|||
|
|
videoHeight: 598,
|
|||
|
|
controlBar: {
|
|||
|
|
playToggle: false,
|
|||
|
|
volumePanel: {
|
|||
|
|
inline: false
|
|||
|
|
},
|
|||
|
|
remainingTimeDisplay: false,
|
|||
|
|
progressControl: false,
|
|||
|
|
LiveDisplay: true
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
//停止视频
|
|||
|
|
function pausevideo() {
|
|||
|
|
if (flvjs.isSupported()) {
|
|||
|
|
// //去掉空播放对象
|
|||
|
|
flvPlayerList.forEach(function (item, index) {
|
|||
|
|
if (!item) {
|
|||
|
|
flvPlayerList.splice(index, 1);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
if (chooseplaysite && flvPlayerList && flvPlayerList.length) {
|
|||
|
|
for (let v of flvPlayerList) {
|
|||
|
|
if (v.key == chooseplaysite) {
|
|||
|
|
if (v.value) {
|
|||
|
|
v.value.unload();
|
|||
|
|
v.value.detachMediaElement();
|
|||
|
|
v.value.destroy();
|
|||
|
|
v.value = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
alert("请选择要视频窗口");
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
myPlayer.reset();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//双击视频可以全屏播放
|
|||
|
|
function videofullscreen(a) {
|
|||
|
|
|
|||
|
|
// $(p).fullScreen(true);
|
|||
|
|
// $(p).toggleFullScreen();
|
|||
|
|
//$(p).fullScreen(false);
|
|||
|
|
canvasDrawVideo.onLoad('c1')
|
|||
|
|
event.stopPropagation();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//单击视频框添加样式
|
|||
|
|
function changestyle(box) {
|
|||
|
|
var p = '#' + box.id;
|
|||
|
|
$(p).siblings().css("border", "1px grey solid");
|
|||
|
|
$(p).css("border", "1px rgb(97, 19, 239) solid");
|
|||
|
|
if (box == windowbox) {
|
|||
|
|
videoelem = document.getElementById('video1');
|
|||
|
|
chooseplaysite = 1; //对应的第1窗口,以下类推
|
|||
|
|
} else if (box == windowbox2) {
|
|||
|
|
videoelem = document.getElementById('video2');
|
|||
|
|
chooseplaysite = 2;
|
|||
|
|
} else if (box == windowbox3) {
|
|||
|
|
videoelem = document.getElementById('video3');
|
|||
|
|
chooseplaysite = 3;
|
|||
|
|
} else if (box == windowbox4) {
|
|||
|
|
videoelem = document.getElementById('video4');
|
|||
|
|
chooseplaysite = 4;
|
|||
|
|
} else if (box == windowbox5) {
|
|||
|
|
videoelem = document.getElementById('video5');
|
|||
|
|
chooseplaysite = 5;
|
|||
|
|
} else if (box == windowbox6) {
|
|||
|
|
videoelem = document.getElementById('video6');
|
|||
|
|
chooseplaysite = 6;
|
|||
|
|
} else if (box == windowbox7) {
|
|||
|
|
videoelem = document.getElementById('video7');
|
|||
|
|
chooseplaysite = 7;
|
|||
|
|
} else if (box == windowbox8) {
|
|||
|
|
videoelem = document.getElementById('video8');
|
|||
|
|
chooseplaysite = 8;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//右键点击事件取消具体某个窗口播放视频
|
|||
|
|
document.oncontextmenu = function (e) {
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
$(p).mousedown(function (e) {
|
|||
|
|
if (e.which == 3) {
|
|||
|
|
$(p).css("border", "1px grey solid");
|
|||
|
|
videoelem = "";
|
|||
|
|
chooseplaysite = 0;
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//云台操作
|
|||
|
|
function get_select_node() {
|
|||
|
|
var node = $('#resource_tree').tree("getSelected");
|
|||
|
|
/*if (node && node.attributes && node.attributes.self && node.attributes.self.Type == "IV") {
|
|||
|
|
return {
|
|||
|
|
puid: node.attributes.newList.id,
|
|||
|
|
idx: node.attributes.self.Idx
|
|||
|
|
};
|
|||
|
|
}*/
|
|||
|
|
return {
|
|||
|
|
puid: node.attributes.newList.id,
|
|||
|
|
idx: node.attributes.self.Idx
|
|||
|
|
};
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
//缩放功能
|
|||
|
|
function zoomcontrol(btn, option) {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
let params = {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx
|
|||
|
|
}
|
|||
|
|
if (!camera) return;
|
|||
|
|
if (option == "stop") {
|
|||
|
|
//停止缩放接口
|
|||
|
|
requestPost('PTZ/C_PTZ_StopPictureZoom?token=' + token, params, rv => {
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
})
|
|||
|
|
} else if (option == "zoomin") {
|
|||
|
|
//放大图像接口
|
|||
|
|
requestPost('PTZ/C_PTZ_ZoomInPicture?token=' + token, params, rv => {})
|
|||
|
|
} else {
|
|||
|
|
//缩小图像接口
|
|||
|
|
requestPost('PTZ/C_PTZ_ZoomOutPicture?token=' + token, params, rv => {})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//远近焦点功能
|
|||
|
|
function focuscontrol(btn, option) {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
let params = {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx
|
|||
|
|
}
|
|||
|
|
if (!camera) return;
|
|||
|
|
if (option == "near") {
|
|||
|
|
requestPost('PTZ/C_PTZ_MakeFocusNear?token=' + token, params, rv => {
|
|||
|
|
console.log(rv)
|
|||
|
|
})
|
|||
|
|
} else if (option == "faraway") {
|
|||
|
|
requestPost('PTZ/C_PTZ_MakeFocusFar?token=' + token, params, rv => {
|
|||
|
|
console.log(rv)
|
|||
|
|
})
|
|||
|
|
} else {
|
|||
|
|
requestPost('PTZ/C_PTZ_StopFocusMove?token=' + token, params, rv => {
|
|||
|
|
console.log(rv)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//动态添加select里面的option
|
|||
|
|
function getValue() {
|
|||
|
|
var data = new Array();
|
|||
|
|
data.length = 256;
|
|||
|
|
for (let i = 1; i < data.length; i++) {
|
|||
|
|
$("#select").append("<option value='" + i + "'>预置位" + i + "</option>");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//设置预置位
|
|||
|
|
function setPresetPos() {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
var value = $("#select option:selected").val();
|
|||
|
|
console.log(value)
|
|||
|
|
if (value != "") {
|
|||
|
|
pos = value;
|
|||
|
|
}
|
|||
|
|
requestPost('PTZ/C_PTZ_SetPresetPos?token=' + token, {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx,
|
|||
|
|
PresetPos: pos
|
|||
|
|
}, rv => {});
|
|||
|
|
}
|
|||
|
|
//前往预置位
|
|||
|
|
function startPresetPos(presetPos) {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
var value = $("#select").val();
|
|||
|
|
requestPost('PTZ/C_PTZ_MoveToPresetPos?token=' + token, {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx,
|
|||
|
|
PresetPos: value
|
|||
|
|
}, rv => {});
|
|||
|
|
}
|
|||
|
|
//前往最原始预置位
|
|||
|
|
function originalPresetPos() {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
requestPost('PTZ/C_PTZ_GotoOriginalPresetPos?token=' + token, {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx
|
|||
|
|
}, rv => {
|
|||
|
|
// console.log(rv)
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
//开始云抓拍
|
|||
|
|
function startmanual() {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
|
|||
|
|
requestPost('CSS/C_CSS_StartManualSnapshot?token=' + token, {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx,
|
|||
|
|
stream: 0
|
|||
|
|
}, rv => {
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
pictureId = respJSON.ID;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//开始云录像
|
|||
|
|
function startstorage() {
|
|||
|
|
let self = this;
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
var puid = camera.puid;
|
|||
|
|
var idx = camera.idx;
|
|||
|
|
|
|||
|
|
requestPost('CSS/C_CSS_StartManualStorage?token=' + token, {
|
|||
|
|
puid: camera.puid,
|
|||
|
|
idx: camera.idx,
|
|||
|
|
duration: 5,
|
|||
|
|
reserveDay: 30,
|
|||
|
|
fileLength: 15,
|
|||
|
|
type: 0
|
|||
|
|
}, rv => {
|
|||
|
|
var respJSON = rv.responseJSON;
|
|||
|
|
storageId = respJSON.Param.ID;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//停止云抓拍、云录像
|
|||
|
|
function stopmanual(id) {
|
|||
|
|
console.log(id);
|
|||
|
|
requestPost('CSS/C_CSS_StopManualStorage?token=' + token, {
|
|||
|
|
id: id
|
|||
|
|
}, rv => {});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
function stopcall() {
|
|||
|
|
var camera = get_select_node();
|
|||
|
|
if (!camera) return;
|
|||
|
|
var puid = camera.puid;
|
|||
|
|
var idx = camera.idx;
|
|||
|
|
var name = puid + "_" + idx
|
|||
|
|
|
|||
|
|
//参数说明
|
|||
|
|
/*
|
|||
|
|
name:喊话的标识,每个喊话都有一个标识,刷新网页或者不需要喊话了,请调用停止接口,否则喊话通道会一直存在
|
|||
|
|
*/
|
|||
|
|
stopCall(name);
|
|||
|
|
}
|