button_status=true; var first_start=false; videofl(); plays=[]; chushihua=[]; status = {}; $(function() { $(".zhufenlei").click(function(e) { $(this).addclass('zhufenleiact').siblings().removeclass('zhufenleiact'); var index = $(this).index(); $('.two').eq(index).addclass('display_b').siblings().removeclass('display_b'); var videoflid=$(e.target).attr("id") getvideourl(videoflid); }); }); function videofl(){ $.ajax({ url: "https://www.zdjt.com/api/shikuangzd/getcate", type: "get", datatype: "json", async: false, success: function(data) { var morenfenlei=data.data[0].id $('.two_box').empty() for (var i=0;i'+videofl.name+'

'); //二级 str= `
` $('.two_box').append(str) status[videofl.id]=false } //默认显示 $('.zhufenlei').eq(0).addclass('zhufenleiact').siblings().removeclass('zhufenleiact'); $('.two').eq(0).addclass('display_b').siblings().removeclass('display_b'); // 二级 getvideourl(morenfenlei); } }); } var time = 0; function refresh(videoid,obj){ if(!button_status){ return } if (time == 0) { time = 1; //设定间隔时间(秒) //启动计时器,倒计时time秒后自动关闭计时器。 var index = setinterval(function(){ time--; if (time == 0) { clearinterval(index); } }, 1000); if($('#playwind').length > 0){ console.log($("#playwind")) //关闭所有websocket stopplay() //关闭所有websocket } var videotimestamp = date.parse(new date()); // console.log($(obj).parent()) var videoparent = $(obj).parent() //清除所有cavas $('#playwind').remove() $('.sl_img').css('height','100%') //缩略图隐藏 videoparent.children('div').eq(1).css('height',0) $.ajax({ url: "https://www.zdjt.com/api/shikuangzd/getdataone_ws?ids="+videoid+"", type: "get", datatype: "json", async: false, success: function(data) { //清除所有cavas button_status=false; // chushihua[videoparent.index()]=null // //销毁实例 // videoparent.children().eq(0).remove() videoparent.children('div').eq(0).prepend(`
`); videoparent.prepend(`
`); init(data.data.url) } }); }else{ console.log("刷新速度过快已禁止") } } function getvideourl(id){ var videoflid=id; $.ajax({ url: "https://www.zdjt.com/api/shikuangzd/getdata_ws?category="+videoflid+"", type: "get", datatype: "json", async: false, success: function(data) { var two_index = $('.display_b').index(); if($(".two").eq(two_index).children('.videolist').children().length>0){ $('.two').eq(two_index).addclass('display_b').siblings().removeclass('display_b'); }else{ for (var i=0;i

${videourl.cameraname}

`); } // $('.myvideo').each(function(i,item){ let id = 'myvideo_'+videoflid+'_'+i settimeout(function() { chushihua.push(videojs(id)); let myplayer = videojs(id); videojs(id).ready(function() { let myplayer = this; myplayer.video_status=false; myplayer.play(); // console.log(this) // 自动播放 myplayer.on('timeupdate', function() { // 监听播放状态 if(myplayer.video_status==false){ myplayer.pause(); }   })    myplayer.on("pause", function(){ myplayer.video_status=true; }) }); }, 0); }) } var time=settimeout(function(){ console.log(first_start) if (first_start==false){ refresh(data.data[0].id,$(".video_last_p").eq(0)) first_start=true cleartimeout(time) } },0) //首次进入界面自动播放 first_start:状态 } }); } var oplugin = null; var iwind = 0; //窗口索引 function init(url){ //var szbrowserversion = ""; //var ibrowserversion = -1; var ascript = []; var szuseragent = navigator.useragent.tolowercase(); // if (szuseragent.match(/chrome\/([\d.]+)/) || szuseragent.match(/firefox\/([\d.]+)/)) { //szbrowserversion = szuseragent.match(/chrome\/([\d.]+)/)[1]; //ibrowserversion = parseint(szbrowserversion.split(".")[0], 10); if (szuseragent.indexof('win64') > -1 || szuseragent.indexof('x64') > -1) { ascript = ["/video_ws/h5player.min.js"]; } else { ascript = ["/video_ws/h5player.min.js"]; } // } getscript(ascript, function () { //初始化插件 oplugin = new jsplugin({ szid: "playwind", iwidth: 320, iheight: 180, imaxsplit: 1, icurrentsplit: 2, szbasepath: "/video_ws/", ostyle: { border: "#343434", borderselect: "#ffcc00", background: "#000" }, opendebug: true }); initplugin(); realplay(url); }); // var szwebsocketsessionid = "4cc81824281f214eceb5"; //设备直连取流uuid, 流媒体取流不需要该参数 var sztoken = ""; } function getscript(url, fn) { if ("string" === typeof (url)) { url = [url]; //如果不是数组带个套 }; var ok = 0; //加载成功几个js var len = url.length; //一共几个js var head = document.getelementsbytagname("head").item(0); var js = null; var _url; create = function (url) {//创建js var oscript = null; oscript = document.createelement("script"); oscript.type = "text/javascript"; oscript.src = url; head.appendchild(oscript); return oscript; }; for (var i = 0; i < len; i++) { _url = url[i]; js = create(_url);//创建js fn && (js.onload = function () { if (++ok >= len) {//如果加载完所有的js则执行回调 fn(); } }); }; } function initplugin() { oplugin.js_setwindowcontrolcallback({ windoweventselect: function (iwndindex) { //插件选中窗口回调 iwind = iwndindex; // console.log(iwndindex); }, pluginerrorhandler: function (iwndindex, ierrorcode, oerror) { //插件错误回调 console.error('window-${iwndindex}, errorcode: ${ierrorcode}', oerror); }, windoweventover: function (iwndindex) { //鼠标移过回调 //console.log(iwndindex); }, windoweventout: function (iwndindex) { //鼠标移出回调 //console.log(iwndindex); }, windoweventup: function (iwndindex) { //鼠标mouseup事件回调 //console.log(iwndindex); }, windowfullccreenchange: function (bfull) { //全屏切换回调 console.log(bfull); }, firstframedisplay: function (iwndindex, iwidth, iheight) { //首帧显示回调 // console.log(iwndindex, iwidth, iheight); }, performancelack: function () { //性能不足回调 console.log("性能不足回调") } }); oplugin.js_setoptions({ // bsupportsound: false //是否支持音频,默认支持 // bsuppordoubleclickfull: false, //是否双击窗口全屏,默认支持 // bonlysupportmse: true //只支持mse // bonlysupportjsdecoder: true //只支持jsdecoder }).then(function () { // console.log("js_setoptions"); }); } function getversion() { oplugin.js_getpluginversion().then(function (szversion) { // console.log(szversion); }); } function destroy() { oplugin.js_destroyworker().then(function () { // console.log("destroyworker success"); }); } function setsecretkey() { var secretkey = document.getelementbyid("secretkey").value; oplugin.js_setsecretkey(iwind, secretkey).then(function () { // console.log("js_setsecretkey success"); }, function () { // console.log("js_setsecretkey failed"); }); } function realplay(url) { let streamtype = getradiovalue('streamtype'); oplugin.js_play(url, { playurl: url, mode: 1, //session: szwebsocketsessionid, //定制设备 //token: sztoken, }, iwind).then(function () { // console.log("realplay success"); // 播放成功 button_status=true; $('.loading').remove() }, function () { // console.log("realplay failed"); }); } function getradiovalue(radioname) { let value = ''; document.getelementsbyname(radioname).foreach(el => { if (el.checked) { value = el.value } }) return value } function stopplay() { console.log("已停止播放") oplugin.js_stop().then( () => { console.log('stop realplay success') }, e => { console.error(e) } ) } //停止播放 function playback() { var url = "wss://219.149.166.154:6014/openurl/xrld5fy"; var szstartdate = document.getelementbyid("sdate").value; var szenddate = document.getelementbyid("edate").value; let streamtype = getradiovalue('streamtype'); if (document.getelementbyid("urlplayback").value && szstartdate && szenddate) { oplugin.js_play(url, { // token: sztoken, //流媒体 playurl: url, //联网共享的取流url mode: parseint(streamtype), //proxy后面的属性为代理的目标地址,根据实际情况配置,联网共享http下需要用到该参数 //mode: "media", //建立连接的url新增一个media节点, 联网共享http下需要用到该参数 }, iwind, szstartdate, szenddate).then(function () { // console.log("playback success"); }, function () { // console.log("playback failed"); }); } else { return; } } function playbacklocation() { var szstartdate = document.getelementbyid("sdate1").value; var szenddate = document.getelementbyid("edate1").value; oplugin.js_seek(iwind, szstartdate, szenddate).then(function () { // console.log("playbacklocation success"); }, function () { // console.log("playbacklocation failed"); }); } function stop() { oplugin.js_stop(iwind).then(function () { // console.log("stop success"); }, function (e) { // console.error("stop failed", e); }); } function arrangewindow(i) { oplugin.js_arrangewindow(i).then(function () { // console.log("js_arrangewindow success"); }); } function pause() { oplugin.js_pause(iwind).then(function () { // console.log("pause success"); }, function (e) { // console.error("pause failed", e); }); } function resume() { oplugin.js_resume(iwind).then(function () { // console.log("resume success"); }, function (e) { // console.error("resume failed", e); }); } function slow() { oplugin.js_slow(iwind).then(function (irate) { console.log("slow success, current rate", irate); }, function (e) { console.error("slow failed", e); }); } function fast() { oplugin.js_fast(iwind).then(function (irate) { console.log("fast success, current rate", irate); }, function (e) { console.error("fast failed", e); }); } function frameforward() { oplugin.js_frameforward(iwind).then(function () { console.log("frameforward success"); }, function () { console.log("frameforward failed"); }); } function getosdtime() { oplugin.js_getosdtime(iwind).then(function (time) { console.log(new date(time)); }); } function closesound() { oplugin.js_closesound(iwind).then(function () { console.log("js_closesound success"); }, function () { console.log("js_closesound failed"); }); } function enablezoom() { oplugin.js_enablezoom(iwind).then(function () { console.log("enablezoom success"); }).catch(err => { console.warn(`enablezoom failed: `, err) }); } function disablezoom() { oplugin.js_disablezoom(iwind).then(function () { console.log("disablezoom success"); }).catch(err => { console.error("disablezoom failed: ", err) }); } function enable3dzoom() { oplugin.js_enable3dzoom(iwind, function (orect) { console.log(orect); }) } function disable3dzoom() { oplugin.js_disable3dzoom(iwind).then(function () { console.log("js_disable3dzoom success"); }, function () { console.log("js_disable3dzoom failed"); }); } function opensound() { var iret = oplugin.js_opensound(iwind).then(function () { console.log("js_opensound success"); }, function () { console.log("js_opensound failed"); }); } function setvolume() { // oplugin.js_setvolume (iwind, 32500).then(function () { // console.log("js_setvolume success"); // }, function () { // console.log("js_setvolume failed"); // }); let volume = document.getelementbyid('volume').value; oplugin.js_setvolume(iwind, parsefloat(volume)).then( () => { console.log("js_setvolume success", volume); }, (err) => { console.error("js_setvolume failed", err); } ); } function selectwnd() { oplugin.js_selectwnd(3).then(function () { console.log("js_selectwnd success"); }, function () { console.log("js_selectwnd failed"); }); } function getvolume() { oplugin.js_getvolume(iwind).then(function (i) { console.log(i); }); } function capturepicture(sztype) { oplugin.js_capturepicture(iwind, "img", sztype).then(function () { console.log("capturepicture success"); }, function () { console.log("capturepicture failed"); }); } function stoprealplayall() { oplugin.js_stoprealplayall().then(function () { console.log("js_stoprealplayall success"); }, function () { console.log("js_stoprealplayall failed"); }); } function dateformat(odate, fmt) { var o = { "m+": odate.getmonth() + 1, //月份 "d+": odate.getdate(), //日 "h+": odate.gethours(), //小时 "m+": odate.getminutes(), //分 "s+": odate.getseconds(), //秒 "q+": math.floor((odate.getmonth() + 3) / 3), //季度 "s": odate.getmilliseconds()//毫秒 }; if (/(y+)/.test(fmt)) { fmt = fmt.replace(regexp.$1, (odate.getfullyear() + "").substr(4 - regexp.$1.length)); } for (var k in o) { if (new regexp("(" + k + ")").test(fmt)) { fmt = fmt.replace(regexp.$1, (regexp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); } } return fmt; } function record() { var sztime = dateformat(new date(), "yyyymmddhhmmsss"); oplugin.js_startsave(iwind, "127.0.0.1_" + sztime + ".mp4").then(function () { console.log("record success"); }, function () { console.log("record failed"); });; } function stoprecord() { oplugin.js_stopsave(iwind).then(function () { console.log("stoprecord success"); }, function () { console.log("stoprecord failed"); });; } function starttalk() { var talkurl = document.getelementbyid("talkurl").value oplugin.js_starttalk(talkurl).then(function () { console.log("starttalk success"); }, function () { console.log("starttalk failed"); }); } function stoptalk() { oplugin.js_stoptalk().then(function () { console.log("stoptalk success"); }, function () { console.log("stoptalk failed"); }); } function talksetvolume() { let volume = document.getelementbyid('talkvolume').value; oplugin.js_talksetvolume(parsefloat(volume)).then( () => { console.log("js_talksetvolume success", volume); }, (err) => { console.error("js_talksetvolume failed", err); } ); } function talkgetvolume() { oplugin.js_talkgetvolume().then(function (i) { console.log(i); }); } function fullsreen() { oplugin.js_fullscreendisplay(true).then(function () { console.log("js_fullscreendisplay success"); }, function () { console.log("js_fullscreendisplay failed"); }); } function fullscreensingle() { oplugin.js_fullscreensingle(iwind).then(function () { console.log("js_fullscreensingle success"); }, function () { console.log("js_fullscreensingle failed"); }); } function triggerprivatedata(btrue) { let ninteltype = parseint(document.getelementbyid('ninteltype').value); let result = oplugin.js_renderprivatedata(ninteltype, btrue); console.info('triggerprivatedata', result) } function ninteltypechange() { let ninteltype = document.getelementbyid('ninteltype').value; subselectelment = document.getelementbyid('nsubtype') subselectelment.innerhtml = '' let submap = { '0x00000010': [ { value: 0x00000001, label: '火点框显示' }, { value: 0x00000002, label: '火点最高温显示' }, { value: 0x00000004, label: '最高温位置显示' }, { value: 0x00000008, label: '最高温度距离' }, ], '0x00000020': [ { value: 0x00000001, label: '框测温' }, { value: 0x00000002, label: '线测温' }, { value: 0x00000004, label: '点测温' }, ], '0x00000040': [ { value: 0x00000001, label: '人的轨迹信息' }, { value: 0x00000002, label: '车的轨迹信息' }, ], '0x00000080': [ { value: 0x00000001, label: '烟火屏蔽' }, { value: 0x00000002, label: '规则废气检测' }, { value: 0x00000004, label: '目标废气检测' }, ] } submap[ninteltype].foreach(item => { let optionelement = document.createelement('option') optionelement.value = item.value optionelement.innertext = item.label subselectelment.appendchild(optionelement) }); } function triggerprivatedatasub(btrue) { let ninteltype = parseint(document.getelementbyid('ninteltype').value); let nsubtype = parseint(document.getelementbyid('nsubtype').value); let result = oplugin.js_renderprivatedataex(ninteltype, nsubtype, btrue); console.info('triggerprivatedatasub', result) } function triggerjsdecoderlog(bflag) { oplugin.js_setlogflag(bflag); } //进入全屏 function fullscreen() { var ele = document.getelementbyid('playwindow0'); if (ele.requestfullscreen) { ele.requestfullscreen(); } else if (ele.mozrequestfullscreen) { ele.mozrequestfullscreen(); } else if (ele.webkitrequestfullscreen) { ele.webkitrequestfullscreen(); } } //退出全屏 function exitfullscreen() { var de = document; if (de.exitfullscreen) { de.exitfullscreen(); } else if (de.mozcancelfullscreen) { de.mozcancelfullscreen(); } else if (de.webkitcancelfullscreen) { de.webkitcancelfullscreen(); } }