let dtree, util, tree; let noNum = 0, num = 0, all = 0; let type = 'city'; let winDom = 'videoPlayer'; /** * 播放视频 * @param {Object} winNum * @param {Object} devCode * @param {Object} devName * @param videoType 视频类型 */ function playVideo(winNum, devCode) { //videos.closeAllVideo(); destoryVideo(flvPlayer); QXPlayVideo(devCode, '0', winDom) } //双击视频可以全屏播放 function videofullscreen(box) { var video = document.getElementById("windowbox"); if (!document.fullscreenElement) { video.requestFullscreen().catch(err => { console.error("Fullscreen request failed:", err); }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') { handleEscapePress(); } }); document.addEventListener('fullscreenchange', handleFullscreenChange); } else { if (document.exitFullscreen) { document.exitFullscreen(); $('#videoControlBtn').css('display', 'none'); } } } // 全屏状态变化处理 function handleFullscreenChange() { const isFullscreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement; // console.log('全屏状态变化:', isFullscreen ? '进入全屏' : '退出全屏'); if (isFullscreen) { // 进入全屏时的操作 // console.log('现在可以监听ESC键了'); $('#videoControlBtn').removeAttr('style'); } else { // 退出全屏 $('#videoControlBtn').css('display', 'none'); } } function handleEscapePress() { const isFullscreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement; if (isFullscreen) { console.log('在全屏状态下按下了ESC键'); // 这里可以添加自定义逻辑,比如显示控制栏等 } } /** * 云台控制 * @param devCode */ function playControl() { let key; //点击事件 let btn = $('[lay-event=control]'); btn.unbind(); btn.mousedown(function (event) { if (ty_code == passWay) { key = tyControlType[$(this).attr('id')]; nrUvpVideoObj.uvpVideoControl({ devCode: videoObject.devCode, cmd: key[0] }) } else { key = qxControlType[$(this).attr('id')]; if (videoObject.playState) { key = qxControlType[$(this).attr('id')]; if (key[2]) { //清新 -球机移动 turnControl(key[0], videoObject.devCode).then(r => { }); } else { //球机放大缩小 qxControl(videoObject.devCode, key[1]) } } } event.stopPropagation(); }).mouseup(function (event) { if (ty_code == passWay) { key = tyControlType[$(this).attr('id')]; nrUvpVideoObj.uvpVideoControl({ devCode: videoObject.devCode, cmd: key[1] }) } else { key = qxControlType[$(this).attr('id')]; if (videoObject.playState) { key = qxControlType[$(this).attr('id')]; if (key[2]) { turnControl(key[3], videoObject.devCode).then(r => { }); } else { qxControl(videoObject.devCode, key[3]) } } else { layer.msg("请先播放视频....", { icon: 0 }); } } event.stopPropagation(); }); } // 获取所有操作按钮 const controlButtons = document.querySelectorAll('.control2'); const videoControlBtn = document.querySelectorAll('#videoControlBtn'); // 为每个按钮添加双击事件阻止 controlButtons.forEach(button => { button.addEventListener('dblclick', function(e) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); return false; }); }); videoControlBtn.forEach(button => { button.addEventListener('dblclick', function(e) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); return false; }); }); // 视频全屏,按钮的点击事件 function playControl2() { let key; //点击事件 let btn = $('[lay-event=control2]'); btn.unbind(); btn.mousedown(function (event) { event.stopPropagation(); if (ty_code == passWay) { key = tyControlType[$(this).attr('id')]; nrUvpVideoObj.uvpVideoControl({ devCode: videoObject.devCode, cmd: key[0] }) } else { key = qxControlType[$(this).attr('id')]; console.log(key); if (videoObject.playState) { key = qxControlType[$(this).attr('id')]; if (key[2]) { //清新 -球机移动 turnControl(key[0], videoObject.devCode).then(r => { }); } else { //球机放大缩小 qxControl(videoObject.devCode, key[1]) } } } event.stopPropagation(); }).mouseup(function (event) { if (ty_code == passWay) { key = tyControlType[$(this).attr('id')]; nrUvpVideoObj.uvpVideoControl({ devCode: videoObject.devCode, cmd: key[1] }) } else { key = qxControlType[$(this).attr('id')]; if (videoObject.playState) { key = qxControlType[$(this).attr('id')]; if (key[2]) { turnControl(key[3], videoObject.devCode).then(r => { }); } else { qxControl(videoObject.devCode, key[3]) } } else { layer.msg("请先播放视频....", { icon: 0 }); } } event.stopPropagation(); }); } let numA = ""; let up = "W"; let down = "S"; let left = "A"; let right = "D"; let amplify = "Q"; let shrink = "E"; let farFocus = "R"; let nearFocus = "T"; let photoLocal = "F"; let videoLocal = "G"; let escape = "Escape"; //键盘监听事件——本地截屏 document.onkeydown = function (event) { up = isEmpty(localStorage.getItem("up")) ? "W" : localStorage.getItem("up"); down = isEmpty(localStorage.getItem("down")) ? "S" : localStorage.getItem("down"); left = isEmpty(localStorage.getItem("left")) ? "A" : localStorage.getItem("left"); right = isEmpty(localStorage.getItem("right")) ? "D" : localStorage.getItem("right"); amplify = isEmpty(localStorage.getItem("amplify")) ? "Q" : localStorage.getItem("amplify"); shrink = isEmpty(localStorage.getItem("shrink")) ? "E" : localStorage.getItem("shrink"); farFocus = isEmpty(localStorage.getItem("farFocus")) ? "R" : localStorage.getItem("farFocus"); nearFocus = isEmpty(localStorage.getItem("nearFocus")) ? "T" : localStorage.getItem("nearFocus"); photoLocal = isEmpty(localStorage.getItem("photoLocal")) ? "F" : localStorage.getItem("photoLocal"); videoLocal = isEmpty(localStorage.getItem("videoLocal")) ? "G" : localStorage.getItem("videoLocal"); escape = isEmpty(localStorage.getItem("escape")) ? "Escape" : localStorage.getItem("escape"); let e = event || window.event || arguments.callee.caller.arguments[0]; if (numA !== e.code.replaceAll("Key", '')) { whichkey(event); } numA = e.code.replaceAll("Key", ''); }; function whichkey(event) { let e = event || window.event || arguments.callee.caller.arguments[0]; if (e.code === escape && e) { let esc = localStorage.getItem('esc'); if (esc) { closePage(); // localStorage.removeItem('esc'); } else { configure(); } } else if (e && e.code.replaceAll("Key", '') === photoLocal) { // Ctrl_B screenshot(); } else if (e && e.code.replaceAll("Key", '') === videoLocal) { // Ctrl_B $("#videoLocal").click() } else if (e && e.code.replaceAll("Key", '') === up) { // Ctrl_B controlDown("up"); } else if (e && e.code.replaceAll("Key", '') === down) { // Ctrl_B controlDown("down"); } else if (e && e.code.replaceAll("Key", '') === left) { // Ctrl_B controlDown("left"); } else if (e && e.code.replaceAll("Key", '') === right) { // Ctrl_B controlDown("right"); } else if (e && e.code.replaceAll("Key", '') === amplify) { // Ctrl_B controlDown("amplify"); } else if (e && e.code.replaceAll("Key", '') === shrink) { // Ctrl_B controlDown("shrink"); } else if (e && e.code.replaceAll("Key", '') === farFocus) { // Ctrl_B controlDown("farFocus"); } else if (e && e.code.replaceAll("Key", '') === nearFocus) { // Ctrl_B controlDown("nearFocus"); } } document.onkeyup = function (event) { numA = ""; let e = event || window.event || arguments.callee.caller.arguments[0]; if (e && e.code.replaceAll("Key", '') === up) { // Ctrl_B controlUp("up"); } else if (e && e.code.replaceAll("Key", '') === down) { // Ctrl_B controlUp("down"); } else if (e && e.code.replaceAll("Key", '') === left) { // Ctrl_B controlUp("left"); } else if (e && e.code.replaceAll("Key", '') === right) { // Ctrl_B controlUp("right"); } else if (e && e.code.replaceAll("Key", '') === amplify) { // Ctrl_B controlUp("amplify"); } else if (e && e.code.replaceAll("Key", '') === shrink) { // Ctrl_B controlUp("shrink"); } else if (e && e.code.replaceAll("Key", '') === farFocus) { // Ctrl_B controlUp("farFocus"); } else if (e && e.code.replaceAll("Key", '') === nearFocus) { // Ctrl_B controlUp("nearFocus"); } } function controlDown(type) { //统一视频 if (ty_code == passWay) { let key = tyControlType[type]; nrUvpVideoObj.uvpVideoControl({ devCode: videoObject.devCode, cmd: key[0] }) } else { if (videoObject.playState) { let key = qxControlType[type]; if (key[2]) { //清新 -球机移动 turnControl(key[0], videoObject.devCode).then(r => { }); } else { //球机放大缩小 qxControl(videoObject.devCode, key[1]) } } else { layer.msg("请先播放视频....", { icon: 0 }); } } } function controlUp(type) { if (ty_code == passWay) { let key = tyControlType[type]; nrUvpVideoObj.uvpVideoControl({ devCode: videoObject.devCode, cmd: key[1] }) } else { if (videoObject.playState) { //球机移动 let key = qxControlType[type]; if (key[2]) { turnControl(key[3], videoObject.devCode).then(r => { }); } else { qxControl(videoObject.devCode, key[3]) } } else { layer.msg("请先播放视频....", { icon: 0 }); } } } function configure() { let height = '90%', width = '30%'; let layerIndex = parent.layer.open({ id: "configure", title: ['快捷键设置', 'font-size:18px;'], type: 2, shade: 0.1, shadeClose: false, maxmin: false, content: '../../html/video/configure.html', area: [width, height], move: false, success: function () { if (indexArr) { indexArr.push({ 'type': 'parent', 'index': layerIndex }); } }, end: function (layero, index) { if (indexArr && indexArr.length > 0) { indexArr.forEach(function (item, index) { if (item.index === layerIndex) indexArr.splice(index, 1); }) $('#startTime').focus(); } } }); }