var videoplay = null,
|
_index;
|
function timestampToTime(date) {
|
// var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
|
// var Y = date.getFullYear() + "-";
|
// var M =
|
// (date.getMonth() + 1 < 10
|
// ? "0" + (date.getMonth() + 1)
|
// : date.getMonth() + 1) + "-";
|
// var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + "-";
|
// //var D = date.getDate() + ' ';
|
// //var h = (date.getHours() < 10? '0'+ date.getHours() : date.getHours())+ ':';
|
// var h = date.getHours() + ":";
|
// var m = date.getMinutes() + ":";
|
// var s = date.getSeconds();
|
// return Y + M + D + h + m + s;
|
|
/**
|
* 2019/07/08修改
|
* 上面的时间转换,个位的数字没有添加0,导致查看视频的时间参数会少几位
|
*/
|
var day = new Date(date * 1000);
|
var Year = 0;
|
var Month = 0;
|
var Day = 0;
|
var Hour = 0;
|
var Minute = 0;
|
var Second = 0;
|
var CurrentDate = "";
|
//初始化时间
|
Year = day.getFullYear();
|
Month = day.getMonth() + 1;
|
Day = day.getDate();
|
Hour = day.getHours();
|
Minute = day.getMinutes();
|
Second = day.getSeconds();
|
CurrentDate = CurrentDate + Year + "-";
|
if (Month >= 10) {
|
CurrentDate = CurrentDate + Month + "-";
|
} else {
|
CurrentDate = CurrentDate + "0" + Month + "-";
|
}
|
if (Day >= 10) {
|
CurrentDate = CurrentDate + Day;
|
} else {
|
CurrentDate = CurrentDate + "0" + Day;
|
}
|
|
if (Hour >= 10) {
|
CurrentDate += " " + Hour;
|
} else {
|
CurrentDate += " 0" + Hour;
|
}
|
if (Minute >= 10) {
|
CurrentDate = CurrentDate + ":" + Minute;
|
} else {
|
CurrentDate = CurrentDate + ":0" + Minute;
|
}
|
if (Second >= 10) {
|
CurrentDate = CurrentDate + ":" + Second;
|
} else {
|
CurrentDate = CurrentDate + ":0" + Second;
|
}
|
|
return CurrentDate;
|
}
|
function formatDate(ns) {
|
return new Date(parseInt(ns))
|
.toLocaleString()
|
.replace(/年|月/g, "-")
|
.replace(/日/g, " ");
|
}
|
//播放当前的监控
|
function play(index, width, height, len) {
|
//var url = $('#cameralist option:selected').val();
|
//var accessToken = "at.262uxopt6ifa59wi62a92w19cf9jqzl3-5tow0h34ce-1qzgzxf-4ci8iqqrk";
|
//var index = $('#cameralist option:selected').val();
|
videoplay ? videoplay.stop() : function() {};
|
var url;
|
if (index.length > 1) {
|
len = 2;
|
url = "";
|
for (var i = 0; i < index.length; i++) {
|
if (i === index.length) return;
|
var info = hkDevice.cameralist[index[i]];
|
url +=
|
"ezopen://open.ys7.com/" +
|
info.deviceSerial +
|
"/" +
|
info.channelNo +
|
".live,";
|
}
|
url = url.slice(0, url.length - 1);
|
} else {
|
var info = hkDevice.cameralist[index[0]];
|
url = "";
|
url =
|
"ezopen://open.ys7.com/" +
|
info.deviceSerial +
|
"/" +
|
info.channelNo +
|
".live";
|
}
|
|
videoplay = new EZUIKit.EZUIPlayer({
|
id: "videoWin",
|
autoplay: true,
|
url: url,
|
accessToken: hkDevice.accessToken,
|
decoderPath: "/IntelligentForestry/lib/videoPlay", //decoderPath:${window.YOUR_PATH};请在生产模式输入ezuikit.js的绝对路径
|
width: width,
|
height: height,
|
// handleError: handleError,
|
handleSuccess: function() {
|
|
for (var i = 0; i < index.length; i++) {
|
$("#videoWin>div div:nth-child(" + (i + 1) + ")").append(
|
"<img onmousedown='PtzMove(3," +
|
index[i] +
|
");' onmouseup='PtzStop(" +
|
index[i] +
|
");' style='position:absolute;top:50%;margin-top:-21px;right:20px;display:none;' src='../images/btn-right.png'/>" +
|
"<img onmousedown='PtzMove(2," +
|
index[i] +
|
");' onmouseup='PtzStop(" +
|
index[i] +
|
");' style='position:absolute;top:50%;margin-top:-21px;left:20px;display:none;' src='../images/btn-left.png'/>" +
|
"<img onmousedown='PtzMove(0," +
|
index[i] +
|
");' onmouseup='PtzStop(" +
|
index[i] +
|
");' style='position:absolute;left:50%;margin-left:-21px;top:20px;display:none;' src='../images/btn-top.png'/>" +
|
"<img onmousedown='PtzMove(1," +
|
index[i] +
|
");' onmouseup='PtzStop(" +
|
index[i] +
|
");' style='position:absolute;left:50%;margin-left:-21px;bottom:20px;display:none;' src='../images/btn-bottom.png'/>" +
|
"<img onmousedown='PtzMove(8," +
|
index[i] +
|
");' onmouseup='PtzStop(" +
|
index[i] +
|
");' style='position:absolute;right:60px;top:20px;display:none;' src='../images/btn-max.png'/>" +
|
"<img onmousedown='PtzMove(9," +
|
index[i] +
|
");' onmouseup='PtzStop(" +
|
index[i] +
|
");' style='position:absolute;right:20px;top:20px;display:none;' src='../images/btn-min.png'/>"
|
);
|
|
let iFlag = i + 1;
|
|
$("#videoWin>div div:nth-child(" + iFlag + ") img").mouseover(function(
|
event
|
) {
|
$("#videoWin>div div:nth-child(" + iFlag + ") img").show();
|
});
|
$("#videoWin>div div:nth-child(" + iFlag + ") .draw-window").mouseover(
|
function(event) {
|
event.stopPropagation();
|
$("#videoWin>div div:nth-child(" + iFlag + ") img").show();
|
return false;
|
}
|
);
|
$("#videoWin>div div:nth-child(" + iFlag + ") .draw-window").mouseout(
|
function(event) {
|
event.stopPropagation();
|
$("#videoWin>div div:nth-child(" + iFlag + ") img").hide();
|
return false;
|
}
|
);
|
}
|
}
|
});
|
}
|
|
function mppx(list) {
|
var count = list.length;
|
for (var i = 0; i < count - 1; i++) {
|
for (var j = 0; j < count - 1; j++) {
|
if (list[j].channelNo > list[j + 1].channelNo) {
|
var t = list[j];
|
list[j] = list[j + 1];
|
list[j + 1] = t;
|
}
|
}
|
}
|
return list;
|
}
|
//存储摄像头通道列表
|
var cameralist = [];
|
//存储最后遍历出来的数据
|
var backRecord = [];
|
//list为监控点的列表,fn为最终要执行的代码
|
function setCameralist(list, fn) {
|
list = mppx(list);
|
//list为结构处理后的站点列表
|
fn && fn(list);
|
}
|
//自动连接万年的视频监测站点
|
var hkDevice = new HkDevice(
|
"b70a982cc38f404c9a43e42faa956977",
|
"4d3145fa43146db39ba419e9fe1b65e6"
|
);
|
//获取token
|
function getAccessToken(listFn, fn) {
|
hkDevice.getAccessToken(function(data) {
|
listFn && listFn(fn);
|
});
|
}
|
// function getLiveVideoList() {
|
// hkDevice.getLiveVideoList(function (data) {
|
|
// });
|
// }
|
// function getDeviceList() {
|
// hkDevice.getDeviceList(function (data) {
|
|
// });
|
// }
|
function getCamerasList(fn) {
|
hkDevice.getCamerasList(function(data) {
|
setCameralist(data.data, fn);
|
});
|
}
|
function PtzMove(direction, index) {
|
//var index = $('#cameralist option:selected').val();
|
var info = hkDevice.cameralist[index];
|
hkDevice.setPtzTurn(
|
{
|
deviceSerial: info.deviceSerial,
|
channelNo: info.channelNo,
|
direction: direction,
|
speed: 1 //云台速度:0-慢,1-适中,2-快
|
},
|
function(data) {}
|
);
|
}
|
function PtzStop(index) {
|
//var index = $('#cameralist option:selected').val();
|
var info = hkDevice.cameralist[index];
|
hkDevice.setPtzStop(
|
{
|
deviceSerial: info.deviceSerial,
|
channelNo: info.channelNo
|
},
|
function(data) {}
|
);
|
}
|
//index(通道id),name(站点名称)
|
function getPlaybackRecord(index, name) {
|
//var index = $('#cameralist option:selected').val();
|
var info = hkDevice.cameralist[index];
|
//var begin = document.getElementById("begintime").value;
|
//var end = document.getElementById("endtime").value;
|
var begin = (end = "");
|
hkDevice.getPlaybackRecord(
|
{
|
deviceSerial: info.deviceSerial,
|
channelNo: info.channelNo,
|
startTime: begin,
|
endTime: end
|
},
|
function(data) {
|
//console.log(data);
|
if (!!data.data) {
|
if (data.data.length > 10) {
|
var arr = data.data.slice(0, 9);
|
for (var i = 0; i < arr.length; i++) {
|
arr[i].name = name;
|
arr[i].index = index;
|
}
|
backRecord = backRecord.concat(arr);
|
//console.log(backRecord);
|
} else {
|
for (var i = 0; i < data.data.length; i++) {
|
data.data[i].name = name;
|
data.data[i].index = index;
|
}
|
//console.log(data.data);
|
//backRecord.push(data.data[i]);
|
backRecord = backRecord.concat(data.data);
|
//console.log(backRecord);
|
}
|
}
|
}
|
);
|
}
|
//index(通道id),begin(开始时间),end(结束时间),width(弹窗宽度),height弹窗高度
|
function playback(index, begin, end, width, height,fn) {
|
videoplay ? videoplay.stop() : function() {};
|
_index = index;
|
//var begin = document.getElementById("begintime").value;
|
//var end = document.getElementById("endtime").value;
|
//var index = $('#cameralist option:selected').val();
|
var info = hkDevice.cameralist[index];
|
var url =
|
"ezopen://open.ys7.com/" +
|
info.deviceSerial +
|
"/" +
|
info.channelNo +
|
".rec?begin=" +
|
begin +
|
"&end=" +
|
end;
|
|
videoplay = new EZUIKit.EZUIPlayer({
|
id: "videoWin",
|
autoplay: true,
|
url: url,
|
accessToken: hkDevice.accessToken,
|
decoderPath: "/IntelligentForestry/lib/videoPlay", //decoderPath:${window.YOUR_PATH};请在生产模式输入ezuikit.js的绝对路径
|
width: width,
|
height: height,
|
// handleError: handleError,
|
//handleSuccess: handleSuccess,
|
handleSuccess:function(){
|
fn&&fn();
|
},
|
handleError:function(){
|
fn&&fn();
|
}
|
});
|
}
|