let loginName = "admin@system"; let password = ""; let start = []; $(function() { if(isNumber(puId)){ connect(); }else { alert("puId错误!!!") } }); function shot(){ screenshot($('#windowBox_video')); } /** * 获取websocket地址 */ function connect() { $.ajax({ url:dataUrl+"video/getWebSocket", type: "POST", data: { data:getDefatData() }, success: function(data) { console.log(data); let jsons = JSON.parse(data); let webSocket = jsons.content.Addr; if (webSocket.indexOf("127.0.0.1") !== -1) { ` webSocket = webSocket.replace("127.0.0.1", "112.30.98.105"); ` } let win = new H5Live.Window("windowBox", { callback: function(action, instance, data) { if (action.action==='ws.close'){ layer.msg('视频播放失败,请检查网络!!!', { icon: 2, time: 2000 //2秒关闭(如果不配置,默认是3秒) }); } } }); play(win, puId, '0',webSocket); }, error: function(error) { layer.msg('服务链接异常', { icon: 2, time: 2000 //2秒关闭(如果不配置,默认是3秒) }); } }) } function play(win, puid, idx,webSocket) { let options = { wsPath: webSocket, puid: puid, idx: idx, streamType: 'REALTIME' } win.OpenVideo(options); } /** * 云台控制 * @param {Object} type */ function ballController(type){ $.ajax({ url: dataUrl + "video/getBallPTZControl", type: "POST", data: { puid: encrypt(puId), type: encrypt(type) }, success: function(data) { $('#hint').show(); setTimeout(" $('#hint').hide();", 3000); console.log(new Date().getTime()+"云台控制:",data); }, error: function(error) { console.log("请求错误:",error); } }); } function control(key) { switch (key) { case 0: ballController('StopTurn') break; case 1: ballController('TurnUp'); break; case 2: ballController('TurnDown'); break; case 3: ballController('TurnLeft'); break; case 4: ballController('TurnRight'); break; case 5: ballController('ZoomInPicture'); break; case 6: ballController('ZoomOutPicture'); break; case 7: ballController('MakeFocusNear'); break; case 8: ballController('MakeFocusFar'); break; case 9: ballController('StopPictureZoom'); break; case 10: ballController('StopFocusMove'); break; default: break; } }