var timer1;
|
var timer2;
|
var timer3;
|
|
/**
|
* 页面最多同时调用三个视频,一个车牌识别,抓拍,三个顺序执行
|
* @param lprParam 车牌识别参数
|
* @param snapParam1 抓拍参数1
|
* @param snapPram2 抓拍参数2
|
*/
|
function initVideo(snapParam1, snapParam2, snapPram3) {
|
|
// console.log(lprParam);
|
|
//车牌识别播放
|
if (snapParam1) {
|
$.ajax({
|
type: "POST",
|
url: "../../inout/api/inout-video-play",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(snapParam1),
|
success: function (result) {
|
if (result.code != "0000") {
|
layer.msg(result.msg);
|
} else {
|
snapDto1 = result.data;
|
initSnapVideo(result.data, 1);
|
}
|
//执行第二个
|
initVideo2(snapParam2, snapPram3);
|
},
|
error: function () {
|
layer.msg("过程1摄像头配置失败……");
|
//执行第二个
|
initVideo2(snapParam2, snapPram3);
|
}
|
});
|
} else {
|
initVideo2(snapParam2, snapPram3);
|
}
|
}
|
|
function initVideo2(snapParam2, snapParam3) {
|
if (snapParam2) {
|
$.ajax({
|
type: "POST",
|
url: "../../inout/api/inout-video-play",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(snapParam2),
|
success: function (result) {
|
if (result.code != "0000") {
|
layer.msg(result.msg);
|
} else {
|
snapDto2 = result.data;
|
initSnapVideo(result.data, 2);
|
}
|
//执行第三个
|
initVideo3(snapParam3);
|
},
|
error: function () {
|
layer.msg("过程2摄像头配置失败……");
|
//执行第三个
|
initVideo3(snapParam3);
|
}
|
});
|
} else {
|
initVideo3(snapParam3);
|
}
|
}
|
|
function initVideo3(snapParam3) {
|
if (!snapParam3) return;
|
$.ajax({
|
type: "POST",
|
url: "../../inout/api/inout-video-play",
|
dataType: "json",
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(snapParam3),
|
success: function (result) {
|
if (result.code != "0000") {
|
layer.msg(result.msg);
|
} else {
|
snapDto3 = result.data;
|
initSnapVideo(result.data, 3);
|
}
|
},
|
error: function () {
|
layer.msg("过程3摄像头配置失败……");
|
}
|
});
|
}
|
|
|
/**
|
* 视频播放
|
* @param data
|
* @param order
|
*/
|
function initSnapVideo(data, order) {
|
var htm = "";
|
//海康web4.0播放
|
if (PlayType.HIK_WEB4 == data.playType) {
|
var url = "../../inout/api/iframe-hik?id=" + data.id;
|
if (ship && ship == "ship") { //船运称重页面
|
url += "&length=340&width=195";
|
} else { //称重页面
|
url += "&length=310&width=170";
|
}
|
htm = '<iframe src=' + url + ' style="width: 100%;height: 100%"></iframe>';
|
}
|
//VLC播放
|
if (PlayType.VLC == data.playType) {
|
htm = "<object type='application/x-vlc-plugin' "
|
+ "events='true' width='100%' height='100%'"
|
+ "pluginspage='http://www.videolan.org'"
|
+ "th:codebase='@{../../static/plugins/vlc/npapi-vlc-2.2.2.tar.xz}'>\n"
|
+ "<param name='mrl' value='" + data.playAddr + "'/>\n"
|
+ "<param name='volume' value='50'/>\n"
|
+ "<param name='autoplay' value='true'/>\n"
|
+ "<param name='loop' value='false'/>\n"
|
+ "<param name='fullscreen' value='true'/>\n"
|
+ "<param name='toolbar' value='false'/>\n" + "</object>";
|
}
|
//流媒体播放
|
if (PlayType.FZZY_GB == data.playType) {
|
var id = "easyPlayer" + order;
|
htm = "<easy-player live=true' show-custom-button='true' auto-play='true' muted='true' id='" + id + "' "
|
+ " video-url='" + data.playAddr + "'"
|
+ "></easy-player>";
|
|
//定时器-保活直播
|
if (order == 1) {
|
if (timer1) clearInterval(timer1);
|
timer1 = setInterval(function () {
|
keepAlive(data);
|
}, 15 * 1000);
|
}
|
|
if (order == 2) {
|
if (timer2) clearInterval(timer2);
|
timer2 = setInterval(function () {
|
keepAlive(data);
|
}, 15 * 1000);
|
}
|
if (order == 3) {
|
if (timer3) clearInterval(timer3);
|
timer3 = setInterval(function () {
|
keepAlive(data);
|
}, 15 * 1000);
|
}
|
}
|
|
if (1 == order) {
|
$("#kccz-r-video1").append(htm);
|
}
|
if (2 == order) {
|
$("#kccz-r-video2").append(htm);
|
}
|
if (3 == order) {
|
$("#kccz-r-video3").append(htm);
|
}
|
}
|
|
/**
|
* 保活,msg参数为了防止浏览器缓存
|
*/
|
function keepAlive(data) {
|
var param = {
|
playType: data.playType,
|
sn: data.sn,
|
ip: data.ip,
|
msg: Math.random()
|
};
|
$.ajax({
|
type: 'POST',
|
url: "../../inout/api/video-keep-alive",
|
dataType: 'JSON',
|
contentType: "application/json;charset=UTF-8",
|
data: JSON.stringify(param)
|
});
|
}
|