988 lines
35 KiB
JavaScript
988 lines
35 KiB
JavaScript
//清晰连接id
|
||
let connectQxId = null;
|
||
//创世连接id
|
||
let connectCsId = null;
|
||
let exist = false;
|
||
|
||
var resOAIndex = null;
|
||
let ResOAChannelsQx = new P_Utils.Hash();
|
||
|
||
let path = "D:/";
|
||
$(function () {
|
||
//键盘监听事件——本地截屏
|
||
document.onkeydown = function (event) {
|
||
let e = event || window.event || arguments.callee.caller.arguments[0];
|
||
if (e && e.code === "KeyB") { // Ctrl_B
|
||
if (playBallList.length === 0) {
|
||
layer.msg("请先播放视频", {icon: 2});
|
||
} else {
|
||
screenshot(selectedScreen);
|
||
}
|
||
}
|
||
};
|
||
});
|
||
|
||
/**
|
||
* 判断是否存在插件
|
||
* @returns {boolean}
|
||
*/
|
||
function load() {
|
||
P_LY.UnLoad();
|
||
//初始化插件,插件初始化失败给出提示
|
||
try {
|
||
|
||
let rv = P_LY.Init(new P_LY.Struct.InitParamStruct(true, function (msg) {
|
||
console.log("清新", msg)
|
||
}));
|
||
if (rv.rv !== 0) {
|
||
notify("博诺思插件加载失败", "error", "请刷新页面,重新加载插件!!!");//清新插件加载失败
|
||
return false;
|
||
} else {
|
||
connectQx();
|
||
}
|
||
notify("插件加载成功", "success", "");
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 清新连接平台
|
||
*/
|
||
function connectQx() {
|
||
//创建连接,并记录在P_LY.Connections中
|
||
let ip = _cf.connParams.address;
|
||
let port = _cf.connParams.port;
|
||
let epId = _cf.connParams.epid;
|
||
let uid = _cf.connParams.user;
|
||
let pwd = _cf.connParams.password;
|
||
let bfix = _cf.connParams.bfix;
|
||
|
||
// 构造连接对象
|
||
let param = new P_IF.Struct.ConnParamStruct(ip, port, uid, epId, pwd, bfix || 0);
|
||
let conn = P_LY.Connect(param);
|
||
if (conn.rv === P_Error.SUCCESS) {
|
||
// 连接成功,返回connectId,此参数很重要,后面很多操作都需要
|
||
connectQxId = conn.response;
|
||
} else {
|
||
notify("博诺思平台连接失败", "error", "请刷新页面,重新加载!!!"); //清新平台连接失败
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 页面关闭或刷新释放插件
|
||
*/
|
||
window.onunload = function () {
|
||
unload();
|
||
}
|
||
/**
|
||
* 页面加载完,加载插件
|
||
*/
|
||
window.onload = function () {
|
||
exist = load();
|
||
}
|
||
|
||
/**
|
||
* 释放插件对象,网页退出必须释放插件,否则会出现浏览器异常的错误
|
||
*/
|
||
function unload() {
|
||
//创世插件是否
|
||
NPPILY.UnLoad();
|
||
//清晰插件释放
|
||
P_LY.UnLoad();
|
||
}
|
||
|
||
/**
|
||
* 通知
|
||
* @param title
|
||
* @param type
|
||
* @param description
|
||
*/
|
||
function notify(title, type, description) {
|
||
GrowlNotification.notify({
|
||
title: title,
|
||
type: type,//warning,error,success
|
||
description: description,
|
||
closeTimeout: 3000,
|
||
animation: {
|
||
open: 'slide-in',
|
||
close: 'slide-out'
|
||
},
|
||
animationDuration: .2,
|
||
position: 'top-left',
|
||
});
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 清新云台控制
|
||
* @param puid puid
|
||
* @param type 操作类型
|
||
*/
|
||
function controlQx(puid, type) {
|
||
let options = {
|
||
degree: 50
|
||
}
|
||
switch (type) {
|
||
case "TurnUp": //上
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.turnup, options)
|
||
break;
|
||
case "TurnDown": //停止
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.turndown, options)
|
||
break;
|
||
case "TurnLeft": //做
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.turnleft, options)
|
||
break;
|
||
case "TurnRight": //右
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.turnright, options)
|
||
break;
|
||
case "AugmentAperture": //
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.aperturea)
|
||
break;
|
||
case "MinishAperture": //拉远
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.aperturem)
|
||
break;
|
||
case "ZoomInPicture": //放大图片
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.zoomin)
|
||
break;
|
||
case "ZoomOutPicture": //缩小图片
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.zoomout)
|
||
break;
|
||
case "MakeFocusFar":
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.focusfar)
|
||
break;
|
||
case "MakeFocusNear"://使焦点靠近
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.focusnear)
|
||
break;
|
||
case "StopFocusMove":
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.stopfocus)
|
||
break;
|
||
case "StopApertureZoom":
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.stopaperture)
|
||
break;
|
||
case "StopPictureZoom":
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.stopzoom)
|
||
break;
|
||
default:
|
||
P_LY.PTZ.Control(connectQxId, puid, "0", P_LY.Enum.PTZDirection.stopturn)
|
||
break;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 清新播放视频
|
||
* @param puid
|
||
* @param idx
|
||
* @returns {boolean}
|
||
*/
|
||
function playQxPlugin(puid, idx) {
|
||
// 窗口对象一定放到WindowContainers,这个请开发人员注意
|
||
if (!P_LY.WindowContainers.get(selectedScreen)) {
|
||
P_LY.WindowContainers.set(selectedScreen, new P_LY.Struct.WindowContainerStruct(selectedScreen, P_LY.Enum.WindowType.VIDEO));
|
||
}
|
||
console.log(P_LY.WindowContainers.get(selectedScreen));
|
||
if (P_LY.WindowContainers.get(selectedScreen)) {
|
||
let window = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (window != null) {
|
||
if (window.status.playvideoing) {
|
||
$('#' + window.containerId)[0].innerHtml = "";
|
||
stopVideoQx(window.containerId);
|
||
}
|
||
}
|
||
let menu_params = {
|
||
menu_command: {
|
||
status: true,
|
||
menu: [{
|
||
key: "stopvideo",
|
||
text: "停止视频"
|
||
}, {
|
||
key: "snapshot",
|
||
text: "本地抓拍"
|
||
}, {
|
||
key: "record",
|
||
text: "本地录像"
|
||
}, {
|
||
key: "playaudio",
|
||
text: "播放音频"
|
||
}, {
|
||
key: "playCall",
|
||
text: "开始喊话"
|
||
},{
|
||
key: "playtalk",
|
||
text: "开始对讲"
|
||
}, {
|
||
key: "cloudrecord",
|
||
text: "远程录像"
|
||
}, {
|
||
key: "cloudsnapshot",
|
||
text: "远程抓拍"
|
||
}],
|
||
callback: function (key) {
|
||
switch (key) {
|
||
case "stopvideo":
|
||
stopVideoQx(window.containerId);
|
||
break;
|
||
case "snapshot":
|
||
localSnapQx(window.containerId, window.params.puid);
|
||
break;
|
||
case "record":
|
||
localVideoQx(window.containerId, window.params.puid);
|
||
break;
|
||
case "playaudio":
|
||
playAudioQx(window.containerId);
|
||
break;
|
||
case "playCall":
|
||
playCallQx(window.containerId);
|
||
break;
|
||
case "playtalk":
|
||
playTalkQx(window.containerId);
|
||
break;
|
||
case "cloudsnapshot":
|
||
cloudSnapshotQx(window.containerId);
|
||
break;
|
||
case "cloudrecord":
|
||
cloudRecordQx(window.containerId);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
let wndEvent = new P_LY.Struct.WindowEventStruct();
|
||
wndEvent.menu_command.status = menu_params.menu_command.status;
|
||
wndEvent.menu_command.menu = menu_params.menu_command.menu;
|
||
wndEvent.menu_command.callback = menu_params.menu_command.callback;
|
||
|
||
wndEvent.lbtn_click.status = true;
|
||
wndEvent.lbtn_click.callback = function () {
|
||
ballScreen(window.containerId)
|
||
}
|
||
let rv = P_LY.CreateWindow(connectQxId, selectedScreen, P_LY.Enum.WindowType.VIDEO, wndEvent);
|
||
if (rv.rv !== P_Error.SUCCESS) {
|
||
return false;
|
||
}
|
||
window = rv.response;
|
||
P_LY.WindowContainers.get(selectedScreen).window = window;
|
||
P_LY.WindowContainers.get(selectedScreen).window.customParams.upaudio = "start";
|
||
P_LY.WindowContainers.get(selectedScreen).window.customParams.talk = "start";
|
||
P_LY.WindowContainers.get(selectedScreen).window.customParams.gpsstatus = "start";
|
||
let operator = P_LY.PlayVideo(connectQxId, window, puid, idx);
|
||
P_LY.ResizeWindowDimension(window, "100%", "100%");
|
||
if (operator.rv !== P_Error.SUCCESS) {
|
||
//播放成功改变窗口状态
|
||
$.each(videoList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.playState = false;
|
||
}
|
||
});
|
||
$.each(playBallList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.window = null;
|
||
}
|
||
});
|
||
return false;
|
||
} else {
|
||
//播放成功改变窗口状态
|
||
$.each(videoList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.playState = true;
|
||
}
|
||
});
|
||
$.each(playBallList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.window = window;
|
||
}
|
||
});
|
||
ballScreen(window.containerId);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 创世播放视频
|
||
* @param puid
|
||
* @param idx
|
||
*/
|
||
/*function playCsPlugin(puid, idx) {
|
||
if (!NPPILY.WindowContainers.get(selectedScreen)) {
|
||
NPPILY.WindowContainers.set(selectedScreen, new NPPILY.Struct.WindowContainerStruct($('#' + selectedScreen)[0], NPPILY.Enum.WindowType.VIDEO, false, null, null));
|
||
NPPILY.WindowContainers.each(function (item) {
|
||
let node = item.value;
|
||
if (node.type === NPPILY.Enum.WindowType.VIDEO) {
|
||
node.active = item.key === selectedScreen;
|
||
}
|
||
});
|
||
}
|
||
console.log(NPPILY.WindowContainers.get(selectedScreen));
|
||
if (NPPILY.WindowContainers.get(selectedScreen)) {
|
||
let window = NPPILY.WindowContainers.get(selectedScreen).window;
|
||
if (window != null) {
|
||
if (window.status.playvideoing) {
|
||
stopVideoCs(window.containerId);
|
||
}
|
||
}
|
||
//鼠标事件
|
||
let menu_params = {
|
||
menu_command: {
|
||
status: true,
|
||
menu: [{
|
||
key: "stopvideo",
|
||
text: "停止视频"
|
||
}, {
|
||
key: "snapshot",
|
||
text: "本地抓拍"
|
||
}, {
|
||
key: "record",
|
||
text: "本地录像"
|
||
}, {
|
||
key: "playaudio",
|
||
text: "播放音频"
|
||
}, {
|
||
key: "playCall",
|
||
text: "开始喊话"
|
||
},{
|
||
key: "playtalk",
|
||
text: "开始对讲"
|
||
}, {
|
||
key: "cloudrecord",
|
||
text: "远程录像"
|
||
}, {
|
||
key: "cloudsnapshot",
|
||
text: "远程抓拍"
|
||
}],
|
||
callback: function (key) {
|
||
switch (key) {
|
||
case "stopvideo":
|
||
stopVideoCs(window.containerId);
|
||
break;
|
||
case "snapshot":
|
||
localSnapCs(window.containerId, window.params.puid);
|
||
break;
|
||
case "record":
|
||
localVideoCs(window.containerId, window.params.puid);
|
||
break;
|
||
case "playaudio":
|
||
playAudioCs(window.containerId);
|
||
break;
|
||
case "playtalk":
|
||
playTalkCs(window.containerId);
|
||
break;
|
||
case "cloudsnapshot":
|
||
cloudSnapshotCs(window.containerId);
|
||
break;
|
||
case "cloudrecord":
|
||
cloudRecordCs(window.containerId);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
let wndEvent = new NPPILY.Struct.WindowEventStruct();
|
||
wndEvent.menu_command.status = menu_params.menu_command.status;
|
||
wndEvent.menu_command.menu = menu_params.menu_command.menu;
|
||
wndEvent.menu_command.callback = menu_params.menu_command.callback;
|
||
wndEvent.lbtn_click.status = true;
|
||
wndEvent.lbtn_click.callback = function () {
|
||
ballScreen(window.containerId)
|
||
}
|
||
//创建窗口
|
||
let rv = NPPILY.CreateWindow(connectCsId, selectedScreen, NPPILY.Enum.WindowType.VIDEO, wndEvent);
|
||
if (rv.rv !== P_Error.SUCCESS) {
|
||
return false;
|
||
}
|
||
window = rv.response;
|
||
NPPILY.WindowContainers.get(selectedScreen).window = window;
|
||
NPPILY.WindowContainers.get(selectedScreen).window.customParams.upaudio = "start";
|
||
NPPILY.WindowContainers.get(selectedScreen).window.customParams.talk = "start";
|
||
NPPILY.WindowContainers.get(selectedScreen).window.customParams.gpsstatus = "start";
|
||
let operator = NPPILY.PlayVideo(connectCsId, window, puid, idx, NPPILY.Enum.NrcapStreamType.REALTIME);
|
||
window.customParams.ivName = "";
|
||
NPPILY.ResizeWindowDimension(window, "100%", "100%");
|
||
if (operator.rv !== P_Error.SUCCESS) {
|
||
//播放成功改变窗口状态
|
||
$.each(videoList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.playState = false;
|
||
}
|
||
});
|
||
$.each(playBallList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.window = null;
|
||
}
|
||
});
|
||
} else {
|
||
record(puid, document.title, "球机操作(视频播放)")
|
||
//播放成功改变窗口状态
|
||
$.each(videoList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.playState = true;
|
||
}
|
||
});
|
||
$.each(playBallList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.window = window;
|
||
}
|
||
});
|
||
ballScreen(window.containerId);
|
||
}
|
||
}
|
||
}*/
|
||
|
||
// 停止视频
|
||
function stopVideoCs(selectedScreen) {
|
||
if (!NPPILY.WindowContainers.get(selectedScreen)) {
|
||
return;
|
||
}
|
||
let window = NPPILY.WindowContainers.get(selectedScreen).window
|
||
$.each(videoList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.playState = false;
|
||
}
|
||
});
|
||
$.each(playBallList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.window = null;
|
||
}
|
||
});
|
||
NPPILY.StopVideo(window);
|
||
// 把视频插件宽高置为0,注意本身及其所有祖先容器不可设置成隐藏(尤其在非IE浏览器中)
|
||
NPPILY.ResizeWindowDimension(window, 0, 0);
|
||
record(window.params.puid, document.title, "球机操作(停止视频播放)")
|
||
}
|
||
|
||
/**
|
||
* 停止播放
|
||
* @param selectedScreen
|
||
*/
|
||
function stopVideoQx(selectedScreen) {
|
||
if (!P_LY.WindowContainers.get(selectedScreen)) {
|
||
return;
|
||
}
|
||
let window = P_LY.WindowContainers.get(selectedScreen).window
|
||
$.each(videoList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.playState = false;
|
||
}
|
||
});
|
||
$.each(playBallList, function (index, item) {
|
||
if (window.containerId === item.selectedScreen) {
|
||
item.window = null;
|
||
}
|
||
});
|
||
P_LY.StopVideo(window);
|
||
P_LY.ResizeWindowDimension(window, 0, 0);
|
||
record(window.params.puid, document.title, "球机操作(停止视频播放)")
|
||
}
|
||
|
||
/**
|
||
* 清新抓拍
|
||
* @param selectedScreen
|
||
* @param puid
|
||
*/
|
||
function localSnapQx(selectedScreen, puid) {
|
||
let fileName = new Date().getTime() + 'Qx(' + puid + ').bmp'
|
||
let wnd = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (typeof wnd != "object") {
|
||
return false;
|
||
}
|
||
if (wnd.status.playvideoing) {
|
||
P_LY.Snapshot(wnd, path, fileName);
|
||
notify("抓拍成功", "success", "保存路径为:" + path + fileName);
|
||
//record(wnd.params.puid, document.title, "球机操作(本地抓拍)")
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 创世抓拍
|
||
* @param selectedScreen
|
||
* @param puid
|
||
*/
|
||
/*function localSnapCs(selectedScreen, puid) {
|
||
let fileName = new Date().getTime() + 'Cs(' + puid + ').bmp'
|
||
let window = NPPILY.WindowContainers.get(selectedScreen).window;
|
||
if (typeof window != "object") {
|
||
return false;
|
||
}
|
||
if (window.status.playvideoing) {
|
||
NPPILY.Snapshot(window, path, fileName);
|
||
notify("抓拍成功", "success", "保存路径为:" + path + fileName);
|
||
record(window.params.puid, document.title, "球机操作(本地抓拍)")
|
||
}
|
||
}*/
|
||
|
||
|
||
/**
|
||
* 清新本地录像
|
||
*/
|
||
function localVideoQx(selectedScreen, puid) {
|
||
let window = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (typeof window != "object") {
|
||
return false;
|
||
}
|
||
if (window.status.playvideoing) {
|
||
let fileName = new Date().getTime() + 'Qx(' + puid + ').avi'
|
||
P_LY.LocalRecord(window, path, fileName);
|
||
if (window.status.recording) {
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "record",
|
||
text: "停止本地录像"
|
||
}]);
|
||
notify("开始本地录像", "success", "保存路径为:" + path + fileName);
|
||
//record(window.params.puid, document.title, "球机操作(开始本地录像)")
|
||
$('#localVideoBtn').attr('src', '../../img/video/remoteVideo2.png')
|
||
} else {
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "record",
|
||
text: "本地录像"
|
||
}]);
|
||
notify("停止本地录像", "success", "");
|
||
//record(window.params.puid, document.title, "球机操作(停止本地录像)")
|
||
$('#localVideoBtn').attr('src', '../../img/video/remoteVideo.png')
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 创世本地录像
|
||
*/
|
||
/*function localVideoCs(selectedScreen, puid) {
|
||
let window = NPPILY.WindowContainers.get(selectedScreen).window;
|
||
if (typeof window != "object") {
|
||
return false;
|
||
}
|
||
if (window.status.playvideoing) {
|
||
let fileName = new Date().getTime() + 'Cs(' + puid + ').avi'
|
||
NPPILY.LocalRecord(window, path, fileName);
|
||
if (window.status.recording) {
|
||
NPPILY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "record",
|
||
text: "停止本地录像"
|
||
}]);
|
||
$('#localVideoBtn').css('background-image', 'url(../../img/video/no_check/local_video_no.png)')
|
||
notify("开始本地录像", "success", "保存路径为:" + path + fileName);
|
||
record(window.params.puid, document.title, "球机操作(开始本地录像)")
|
||
} else {
|
||
NPPILY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "record",
|
||
text: "本地录像"
|
||
}]);
|
||
$('#localVideoBtn').css('background-image', 'url(../../img/video/no_check/local_video.png)')
|
||
notify("停止本地录像", "success", "");
|
||
record(window.params.puid, document.title, "球机操作(停止本地录像)")
|
||
}
|
||
}
|
||
}*/
|
||
|
||
/**
|
||
* 清新播放音频
|
||
* @param selectedScreen
|
||
*/
|
||
function playAudioQx(selectedScreen) {
|
||
if (P_LY.WindowContainers.get(selectedScreen)) {
|
||
let wnd = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (wnd.status.playvideoing) {
|
||
P_LY.PlayAudio(wnd);
|
||
if (wnd.status.playaudioing) {
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "playaudio",
|
||
text: "停止音频"
|
||
}]);
|
||
record(wnd.params.puid, document.title, "球机操作(播放音频)")
|
||
} else {
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "playaudio",
|
||
text: "播放音频"
|
||
}]);
|
||
record(wnd.params.puid, document.title, "球机操作(停止音频播放)")
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 创世播放音频
|
||
* @param selectedScreen
|
||
*/
|
||
/*function playAudioCs(selectedScreen) {
|
||
if (NPPILY.WindowContainers.get(selectedScreen)) {
|
||
let wnd = NPPILY.WindowContainers.get(selectedScreen).window;
|
||
if (wnd.status.playvideoing) {
|
||
NPPILY.PlayAudio(wnd);
|
||
if (wnd.status.playaudioing) {
|
||
NPPILY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "playaudio",
|
||
text: "停止音频"
|
||
}]);
|
||
record(wnd.params.puid, document.title, "球机操作(播放音频)")
|
||
} else {
|
||
NPPILY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "playaudio",
|
||
text: "播放音频"
|
||
}]);
|
||
record(wnd.params.puid, document.title, "球机操作(停止音频播放)")
|
||
}
|
||
}
|
||
}
|
||
}*/
|
||
|
||
/**
|
||
* 清新对讲
|
||
* @param selectedScreen
|
||
*/
|
||
function playTalkQx(selectedScreen) {
|
||
let window = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (window) {
|
||
if (window.status.playvideoing) {
|
||
try {
|
||
let rv_arr = checkTalkEnableQx(connectQxId, window.params.puid) || [-1, -1];
|
||
resOAIndex = rv_arr[1];
|
||
switch (rv_arr[0]) {
|
||
case -1:
|
||
notify("设备不支持对讲", "warning", "")
|
||
return false;
|
||
case 0:
|
||
notify("资源已被占用,无法开启对讲!", "warning", "")
|
||
return false;
|
||
default:
|
||
break;
|
||
}
|
||
} catch (e) {
|
||
}
|
||
if (window.status.playvideoing && window.status.talking) {
|
||
let rv = P_LY.CallTalkControl.Stop(connectQxId, window.params.puid, resOAIndex);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
window.status.talking = false;
|
||
window.customParams.talk = "start";
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "playtalk",
|
||
text: "开始对讲"
|
||
}]);
|
||
notify("停止对讲", "success", "");
|
||
//record(window.params.puid, document.title, "球机操作(停止对讲)")
|
||
}
|
||
} else {
|
||
let rv = P_LY.CallTalkControl.StartTalk(connectQxId, window.params.puid, resOAIndex);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
window.status.talking = true;
|
||
window.customParams.talk = "end";
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "playtalk",
|
||
text: "停止对讲"
|
||
}]);
|
||
notify("开始对讲", "success", "");
|
||
//record(window.params.puid, document.title, "球机操作(开始对讲)")
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 清新喊话
|
||
* @param selectedScreen
|
||
*/
|
||
function playCallQx(selectedScreen) {
|
||
let window = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (window) {
|
||
if (window.status.playvideoing) {
|
||
try {
|
||
let rv_arr = checkTalkEnableQx(connectQxId, window.params.puid) || [-1, -1];
|
||
resOAIndex = rv_arr[1];
|
||
switch (rv_arr[0]) {
|
||
case -1:
|
||
notify("设备不支持喊话", "warning", "")
|
||
return false;
|
||
case 0:
|
||
notify("资源已被占用,无法开启喊话!", "warning", "")
|
||
return false;
|
||
default:
|
||
break;
|
||
}
|
||
} catch (e) {
|
||
}
|
||
if (window.status.playvideoing && window.status.talking) {
|
||
//停止设备喊话或对讲
|
||
let rv = P_LY.CallTalkControl.Stop(connectQxId, window.params.puid, resOAIndex);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
window.status.talking = false;
|
||
window.customParams.talk = "start";
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "playCall",
|
||
text: "开始喊话"
|
||
}]);
|
||
notify("停止喊话", "success", "");
|
||
//record(window.params.puid, document.title, "球机操作(停止对讲)")
|
||
}
|
||
} else {
|
||
let rv = P_LY.CallTalkControl.StartCall(connectQxId, window.params.puid, resOAIndex);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
window.status.talking = true;
|
||
window.customParams.talk = "end";
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "playCall",
|
||
text: "停止喊话"
|
||
}]);
|
||
notify("开始喊话", "success", "");
|
||
//record(window.params.puid, document.title, "球机操作(开始对讲)")
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 清新对讲
|
||
* @param selectedScreen
|
||
*/
|
||
/*function playTalkCs(selectedScreen) {
|
||
let window = NPPILY.WindowContainers.get(selectedScreen).window;
|
||
if (window) {
|
||
if (window.status.playvideoing) {
|
||
try {
|
||
let rv_arr = checkTalkEnableCs(connectCsId, window.params.puid) || [-1, -1];
|
||
resOAIndex = rv_arr[1];
|
||
switch (rv_arr[0]) {
|
||
case -1:
|
||
notify("设备不支持对讲", "warning", "")
|
||
return false;
|
||
case 0:
|
||
notify("资源已被占用,无法开启对讲!", "warning", "")
|
||
return false;
|
||
default:
|
||
break;
|
||
}
|
||
} catch (e) {
|
||
}
|
||
if (window.status.playvideoing && window.status.talking) {
|
||
let rv = NPPILY.CallTalkControl.Stop(connectCsId, window.params.puid, resOAIndex);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
window.status.talking = false;
|
||
window.customParams.talk = "start";
|
||
NPPILY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "playtalk",
|
||
text: "开始对讲"
|
||
}]);
|
||
record(window.params.puid, document.title, "球机操作(停止对讲)")
|
||
}
|
||
} else {
|
||
let rv = NPPILY.CallTalkControl.StartTalk(connectCsId, window.params.puid, resOAIndex);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
window.status.talking = true;
|
||
window.customParams.talk = "end";
|
||
NPPILY.WindowAttachEvent.UpdateMenuCommand(window, [{
|
||
key: "playtalk",
|
||
text: "停止对讲"
|
||
}]);
|
||
record(window.params.puid, document.title, "球机操作(开始对讲)")
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}*/
|
||
|
||
function checkTalkEnableQx(connectId, puid) {
|
||
let rv = P_LY.ForkResource(connectId, P_LY.Enum.ForkResourceLevel.nppForkPUResourceInfo, 0, 200, null, {
|
||
PUID: puid
|
||
});
|
||
let re = rv.response;
|
||
for (let i = 0; i < re.length; i++) {
|
||
let childRes = re[i];
|
||
if (childRes.type === P_LY.Enum.PuResourceType.AudioOut) {
|
||
try {
|
||
ResOAChannelsQx.set(puid + "_" + childRes.idx, {
|
||
puid: puid,
|
||
index: childRes.idx,
|
||
windowKey: "",
|
||
flag: false
|
||
});
|
||
} catch (e) {
|
||
console.log(e.message);
|
||
}
|
||
}
|
||
}
|
||
let found = false,
|
||
activeResOAIdx = 0,
|
||
flag = -1;
|
||
|
||
ResOAChannelsQx.each(
|
||
function (ee) {
|
||
let e = ee.value;
|
||
if (e.puid === puid) {
|
||
flag = 0; // 存在OA资源
|
||
if (found === false && e.flag !== true) {
|
||
activeResOAIdx = e.index;
|
||
found = true;
|
||
}
|
||
}
|
||
}
|
||
);
|
||
if (found === true) {
|
||
flag = 1
|
||
}
|
||
resOAIndex = activeResOAIdx;
|
||
return [flag, activeResOAIdx];
|
||
}
|
||
|
||
function checkTalkEnableCs(connectId, puid) {
|
||
let rv = NPPILY.ForkResource(connectId, NPPILY.Enum.ForkResourceLevel.nppForkPUResourceInfo, 0, 200, null, {
|
||
PUID: puid
|
||
});
|
||
let re = rv.response;
|
||
for (let i = 0; i < re.length; i++) {
|
||
let childRes = re[i];
|
||
if (childRes.type === NPPILY.Enum.PuResourceType.AudioOut) {
|
||
try {
|
||
ResOAChannelsCs.set(puid + "_" + childRes.idx, {
|
||
puid: puid,
|
||
index: childRes.idx,
|
||
windowKey: "",
|
||
flag: false
|
||
});
|
||
} catch (e) {
|
||
console.log(e.message);
|
||
}
|
||
}
|
||
}
|
||
let found = false,
|
||
activeResOAIdx = 0,
|
||
flag = -1;
|
||
|
||
ResOAChannelsCs.each(
|
||
function (ee) {
|
||
let e = ee.value;
|
||
if (e.puid === puid) {
|
||
flag = 0; // 存在OA资源
|
||
if (found === false && e.flag !== true) {
|
||
activeResOAIdx = e.index;
|
||
found = true;
|
||
}
|
||
}
|
||
}
|
||
);
|
||
if (found === true) {
|
||
flag = 1
|
||
}
|
||
resOAIndex = activeResOAIdx;
|
||
return [flag, activeResOAIdx];
|
||
}
|
||
|
||
|
||
/**
|
||
* 清新云抓拍
|
||
*/
|
||
function cloudSnapshotQx(selectedScreen) {
|
||
if (P_LY.WindowContainers.get(selectedScreen)) {
|
||
let wnd = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (wnd.status.playvideoing) {
|
||
let options = {
|
||
Duration: 1, //云抓拍持续时间(分)
|
||
ReserveDay: 30, //文件保存时间(天)
|
||
Interval: 1 //抓拍时间间隔(秒)
|
||
}
|
||
let rv = P_LY.CloudSnapshotOne(wnd, options);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
notify("远程抓拍成功", "success", "");
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 清新云录像
|
||
*/
|
||
function cloudRecordQx(selectedScreen) {
|
||
if (P_LY.WindowContainers.get(selectedScreen)) {
|
||
let wnd = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (wnd.status.playvideoing) {
|
||
let options = {
|
||
Duration: 30, //录像持续时间(分)
|
||
ReserveDay: 30, //文件保存时间(天)
|
||
FileLength: 15, //录像时文件时长(分钟)
|
||
}
|
||
P_LY.CloudRecord(wnd, options);
|
||
console.log(wnd.status.cloudrecording)
|
||
if (wnd.status.cloudrecording) {
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "cloudrecord",
|
||
text: "取消远程录像"
|
||
}]);
|
||
notify("开始远程录像", "success", "");
|
||
//record(wnd.params.puid, document.title, "球机操作(开始远程录像)")
|
||
$('#remoteVideoBtn').attr('src', '../../img/video/localVideo2.png')
|
||
} else {
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "cloudrecord",
|
||
text: "远程录像"
|
||
}]);
|
||
notify("停止远程录像", "success", "");
|
||
//record(wnd.params.puid, document.title, "球机操作(停止远程录像)")
|
||
$('#remoteVideoBtn').attr('src', '../../img/video/localVideo.png')
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 创世云抓拍
|
||
*/
|
||
function cloudSnapshotCs(selectedScreen) {
|
||
if (NPPILY.WindowContainers.get(selectedScreen)) {
|
||
let wnd = NPPILY.WindowContainers.get(selectedScreen).window;
|
||
if (wnd.status.playvideoing) {
|
||
let rv = NPPILY.SC_ManualStart(connectCsId, "155165612271245609", "0", wnd.params.puid, wnd.params.idx, NPPILY.Enum.NrcapStreamType.PICTURE, "Manual", 1);
|
||
if (rv.rv === P_Error.SUCCESS) {
|
||
notify("远程抓拍成功", "success", "");
|
||
record(wnd.params.puid, document.title, "球机操作(远程抓拍)")
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 创世云录像
|
||
*/
|
||
function cloudRecordCs(selectedScreen) {
|
||
if (P_LY.WindowContainers.get(selectedScreen)) {
|
||
let wnd = P_LY.WindowContainers.get(selectedScreen).window;
|
||
if (wnd.status.playvideoing) {
|
||
let options = {
|
||
Duration: 30, //录像持续时间(分)
|
||
ReserveDay: 30, //文件保存时间(天)
|
||
FileLength: 15, //录像时文件时长(分钟)
|
||
}
|
||
if (!wnd.status.cloudrecording) {
|
||
NPPILY.SC_ManualStart(connectCsId, "155165612271245609", "0", wnd.params.puid, wnd.params.idx, NPPILY.Enum.NrcapStreamType.REALTIME, "Manual", 1);
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "cloudrecord",
|
||
text: "取消远程录像"
|
||
}]);
|
||
notify("开始远程录像", "success", "");
|
||
record(wnd.params.puid, document.title, "球机操作(远程录像)")
|
||
$('#remoteVideoBtn').css('background-image', 'url(../../img/video/no_check/remote_video_no.png)')
|
||
} else {
|
||
NPPILY.SC_ManualStop(connectCsId, "155165612271245609", "0", wnd.params.puid, wnd.params.idx, NPPILY.Enum.NrcapStreamType.REALTIME);
|
||
P_LY.WindowAttachEvent.UpdateMenuCommand(wnd, [{
|
||
key: "cloudrecord",
|
||
text: "远程录像"
|
||
}]);
|
||
notify("停止远程录像", "success", "");
|
||
record(wnd.params.puid, document.title, "球机操作(停止远程录像)")
|
||
$('#remoteVideoBtn').css('background-image', 'url(../../img/video/no_check/remote_video.png)')
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|