183 lines
5.9 KiB
JavaScript
183 lines
5.9 KiB
JavaScript
var token1 = localStorage.getItem("video_token1");
|
||
var type = localStorage.getItem("alarmType");
|
||
$(function () {
|
||
getAlarmVideo();
|
||
})
|
||
|
||
function getAlarmVideo() {
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: dataUrl + "index/getAlarmVideo",
|
||
data: "",
|
||
dataType: 'json',
|
||
// async:false,
|
||
success: function (res) {
|
||
if (res.resMsg = "数据获取成功") {
|
||
puid = res.obj.puid;
|
||
var btn = document.getElementById('videoBtn')
|
||
btn.addEventListener('click', function () {
|
||
qxPlayVideo(puid, "0");
|
||
});
|
||
document.getElementById('videoBtn').click();
|
||
|
||
} else {
|
||
layer.msg("当前没有在线球机", {icon: 0, time: 2000});
|
||
}
|
||
},
|
||
});
|
||
// var btn = document.getElementById('videoBtn')
|
||
// btn.addEventListener('click', function () {
|
||
// qxPlayVideo("34020000001180000047", "0");
|
||
// });
|
||
// document.getElementById('videoBtn').click();
|
||
}
|
||
|
||
/**
|
||
* 播放视频
|
||
* @param puId
|
||
* @param idx
|
||
*/
|
||
function qxPlayVideo(puId, idx) {
|
||
setTimeout(function () {
|
||
readyPlay(puId, idx);
|
||
}, 500);
|
||
}
|
||
|
||
var myPlayer = null;
|
||
|
||
//开始播放视频
|
||
function readyPlay(puId, idx) {
|
||
//若是清晰平台,删除连接对象
|
||
// mySet.delete(selectedScreen);
|
||
let url = _cf_1.q2http_url + "stream.flv?puid=" + puId + "&idx=0&stream=0&token=" + token1;
|
||
//循环视频播放列表
|
||
try {
|
||
myPlayer = flvjs.createPlayer({
|
||
type: 'flv',
|
||
url: url,
|
||
isLive: true,
|
||
hasAudio: false
|
||
}, {
|
||
enableWorker: false,
|
||
autoCleanupSourceBuffer: true, //清理缓冲区
|
||
enableStashBuffer: false,
|
||
stashInitialSize: 128, // 减少首桢显示等待时长
|
||
statisticsInfoReportInterval: 600
|
||
});
|
||
|
||
myPlayer.attachMediaElement(document.getElementById('video1'));
|
||
myPlayer.load();
|
||
setTimeout(function () {
|
||
myPlayer.play();
|
||
}, 200);
|
||
} catch (e) {
|
||
alert("该视频不在线。。。");
|
||
}
|
||
var selectedScreen = 'video1';
|
||
$('#video' + selectedScreen + '_html5_api').css("width", "100%");
|
||
$('#video' + selectedScreen + '_html5_api').css("height", "100%");
|
||
$('#video1').css("width", "85%");
|
||
$('#video1').css("height", "100%");
|
||
$('#video1').css("margin-left", "7%");
|
||
$('#video1').css("margin-top", "4%");
|
||
$('#video' + selectedScreen + '_html5_api').css("background-color", "black");
|
||
$('.vjs-text-track-display').hide();
|
||
$('.vjs-loading-spinner').hide();
|
||
$('.vjs-big-play-button').hide();
|
||
$('.vjs-control-bar').hide();
|
||
$('.vjs-error-display').hide();
|
||
$('.vjs-error-display').hide();
|
||
$('.vjs-modal-dialog').hide();
|
||
$('.vjs-poster').removeAttr("class");
|
||
$('.video' + selectedScreen + '-dimensions').css("width", "100%");
|
||
$('.video' + selectedScreen + '-dimensions').css("height", "100%");
|
||
}
|
||
|
||
window.onbeforeunload = function (e) {
|
||
myPlayer.pause();
|
||
myPlayer.unload();
|
||
myPlayer.detachMediaElement();
|
||
myPlayer.destroy();
|
||
myPlayer = null;
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @param {*} player 播放控件对象
|
||
* @param {*} index playBallList 下标,第几个
|
||
* @param {*} type 类型 1切换窗口关闭视频,2主动关闭视频
|
||
*/
|
||
function stopVideo(player, index, type) {
|
||
if (type == 1) {
|
||
player.unload();
|
||
player.detachMediaElement();
|
||
player.destroy();
|
||
player = null;
|
||
playBallList.splice(index, 1);
|
||
} else {
|
||
$.each(playBallList, function (index, item) {
|
||
if (!isEmpty(item)) {
|
||
if (selectedScreen === item.selectedScreen) {
|
||
let start = item.start;
|
||
let player = item.myPlayer;
|
||
if (start && player !== null) {
|
||
player.unload();
|
||
player.detachMediaElement();
|
||
player.destroy();
|
||
player = null;
|
||
playBallList.splice(index, 1);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function openAlarm() {
|
||
layer.alert('请确认是否开启人员道闸进口?', {
|
||
skin: 'layui-layer-molv' // 样式类名
|
||
}, function () {
|
||
open(type);
|
||
});
|
||
}
|
||
|
||
function open(type) {
|
||
var url = "";
|
||
var date;
|
||
if (type === 1 || type === "1") {
|
||
url = "http://192.168.0.110:18886/boot-manager/terminal/remoteControl?deviceIp=192.168.0.14&devicePort=8000&userName=admin&pwd=hk123456&type=1";
|
||
}
|
||
if (type === 2 || type === "2") {
|
||
// url = "http://192.168.0.110:18886/boot-manager/terminal/remoteControl?deviceIp=192.168.0.13&devicePort=8000&userName=admin&pwd=hk123456";
|
||
url = "http://192.168.0.110:18886/boot-manager/terminal/remoteControl?deviceIp=192.168.0.14&devicePort=8000&userName=admin&pwd=hk123456&type=0";
|
||
}
|
||
if (type === 3 || type === "3") {
|
||
url = "http://192.168.0.110:18886/boot-manager/terminal/gateControl?deviceIp=192.168.0.18&dwStaic=1";
|
||
}
|
||
if (type === 4 || type === "4") {
|
||
url = "http://192.168.0.110:18886/boot-manager/terminal/gateControl?deviceIp=192.168.0.17&dwStaic=1";
|
||
}
|
||
console.log(url);
|
||
//使用代理服务器方式跨域请求
|
||
var xhr = new XMLHttpRequest();
|
||
xhr.open('POST', url, true);
|
||
xhr.responseType = 'json';
|
||
// const usp = new URLSearchParams(data)
|
||
// const query = usp.toString()
|
||
xhr.onreadystatechange = function () {
|
||
if (xhr.readyState == 4 && xhr.status == 200) {
|
||
console.log(xhr.response);
|
||
}
|
||
};
|
||
// 发送请求
|
||
xhr.send()
|
||
// 监听load 响应请求获取响应结果
|
||
xhr.addEventListener('load', function () {
|
||
console.log(this.response) //true
|
||
if (this.response === true) {
|
||
layer.msg('开闸成功!', {icon: 1, time: 2000})
|
||
} else {
|
||
layer.msg('开闸失败!', {icon: 2, time: 2000})
|
||
}
|
||
})
|
||
} |