var heAnth = null,heList = [],nowHe = null,userAgent = null,setItime = null,setItimes = 0; var o = void 0, s = 14963200, n = o+"@47.106.114.236:11011", a = s+"@47.106.114.236:11011", l = "wss://caps.runde.pro:11014", r = "0000", h = void 0, u = void 0, p = void 0, m = void 0, d = null, c = null, _ = null, y = null, f = [], v = void 0; window.addEventListener('message',(_data)=>{ if(_data.data.cmd != undefined){ setPlay(_data.data); }else{ if(nowHe != null){ $("._Call img").attr("src","../img/voice.yz4975.png"); if(y != null) u.terminate(); clearInterval(setItime); setItime = null; setItimes = 0; $("._Call .margin-top-sm").text("未连接"); $("._Call .text-lg").text("00:00:00"); $("._helme").css("display","none"); $("#html_view li .text-sm").removeClass("act"); window.parent.postMessage({info:{act: "ma_stop_rtsp",device_id: nowHe.device_id},change: "helemt"}, '*'); } heAnth = JSON.parse(localStorage.getItem("nowShip")); getList(0); } }) var User = JSON.parse(localStorage.getItem("_yz_TU")); $(document).ready(function(){ heAnth = JSON.parse(localStorage.getItem("nowShip")); getList(0); setInterval(()=>{ getList(1); },60*1000); sipInit(); }); function setPlay(_data){ if(_data.cmd == "ma_open_rtsp"&& _data.status){ let _ind = _data.play_url.findIndex((i,ind) => {return i.indexOf("webrtc://") != -1;}); player = new JSWebrtc.Player(_data.api_url, _data.play_url[_ind], { video: document.getElementById("localMonitor"), autoplay: !0, onPlay: startPlay, onFail: onFail }) }else if(_data.cmd == "ma_stop_rtsp"&& _data.status){ console.log("关闭成功"); $("._Call").css("display","none"); callErr(); $("#_View").html('
'); }else if(_data.cmd == "ma_set_sip_info"&& _data.status){ sipCall(); } } var startPlay = function () { console.log("开始播放"); $(".loadImg").remove(); }; var onFail = function () { setTimeout(function() { window.parent.postMessage({info:{act: "ma_open_rtsp",device_id: nowHe.device_id},change: "helemt"}, '*'); }, 1000) } function sipInit() { o = localStorage.getItem("sipId"); n = o+"@47.106.114.236:11011" var e = { uri: n, transportOptions: { wsServers: [l], connectionTimeout: 30 }, authorizationUser: o, password: r, sessionDescriptionHandlerFactoryOptions: { peerConnectionOptions: { rtcConfiguration: { iceServers: [{ urls: "stun:47.106.114.236:40998", }, { urls: "turn:47.106.114.236:40998", username: "fstest", credential: "123456" }] } } } }; userAgent = new SIP.UA(e); userAgent.on("registered", function() { console.log("registered ok"); // call(); }) userAgent.on("registrationFailed", function(){ console.log("registrationFailed ok") }) } function sipCall(){ console.log(11233) c = document.getElementById("helmeVi"); d = document.getElementById("remoteMonitor"); var i = { sessionDescriptionHandlerOptions: { constraints: { audio: !0, video: !1 } } } h = userAgent.invite(a, i), p = h, h.on("accepted",function(t) { var i = h.sessionDescriptionHandler.peerConnection, o = new MediaStream; if (i.getReceivers().forEach(function(t) { o.addTrack(t.track) }), c.srcObject = o, c.play(), c .muted = !0, i.getSenders()) { var s = new MediaStream; i.getSenders().forEach(function(t) { s.addTrack(t.track), t.track.kind }),d.srcObject = s, d.play(), y = new MediaRecorder(s) } _ = new MediaRecorder(o), y.ondataavailable = function(t) { v.push(t.data) }, _.ondataavailable = function(t) { v.push(t.data) }, _.onstop = function(t) { e.blobDownload() } setTimeout(()=>{ callSes(); },4000) }); h.on("rejected", function(t, i) { console.log("onRejected - ", t, i) }); h.on("failed", function(t, i) { console.log("onFailed - ", t, i) }); h.on("terminated", function(t, i) { console.log("onTerminated - ", t, i); }) } function getList(num){ if(heAnth !=null && heAnth != "null"&&heAnth.other_info !=null && heAnth.other_info != ""){ var dsd = heAnth.other_info.split(","); let _opts = { url: helUrl + "/index.php?ctl=bruce&act=get_group_member_list", type:"POST" }; let _data = { admin_id: 7903, udid: "11111111", g_id: dsd[0] }; postAxios(_opts, _data, {}).then((res) =>{ heList = []; if(res.status){ if(res.data.length){ setHelme(num,res.data,dsd); }else{ _str=`