var CDN_TYPE={_WANGSU:"wansu",_GRIFFINMAS:"griffinmas",_AKAMAI:"akamai",_ERROR:-999}; class StreamPlayer{constructor(a,b,c){this.Version="v 024.07.11.01T";this.HLSObj=null;this.debug=b?b:!1;this.isMonitor=c?c:!1;this.options=a?a:{};console.log("Player Version: "+this.Version);this.lastSoundState=this.playState=null;this.lastclientTime=this.lastBufferd=this.lastCurrent=0;this.lastbase="";this.chkPlayBackTimes=this.chkBasetimes=this.chkLoadErrorTimes=this.chkSeekTimes=this.chkReadyStateTimes=this.chkBufferdTimes=this.chkCurrentTimes=0;this.chkBase="";this.hlsSupport=Hls.isSupported(); this.iOS=!!navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform);this.userAgent=navigator.userAgent;this.linePart=0;this.m3u8Url=this.errDetails="";this.delayTime=this.currentTime=this.readyState=this.bufferTime=0;this.varObj={};this.varObj.maxMaxBufferLength=500;this.varObj.maxBufferSize=5E7;this.varObj.fragLoadingMaxRetry=1;this.varObj.manifestLoadingMaxRetry=1;this.varObj.levelLoadingMaxRetry=0;this.varObj.liveSyncDurationCount=3;this.varObj.liveMaxLatencyDurationCount=4;this.varObj.initialLiveManifestSize= 1;this.varObj.forceKeyFrameOnDiscontinuity=!0;this.varObj.enableWebVTT=!1;this.varObj.enableCEA708Captions=!1;this.varObj.playerObject=this;this.varObj.wasmUrl=a.wasmUrl;this.todoErrorHint=!1;this.rateOffset="undefined"!=typeof this.options.rateOffset?this.options.rateOffset:0;this.autoSwitch="undefined"!=typeof this.options.autoSwitch?this.options.autoSwitch:!0;this.defaultMuted="undefined"!=typeof this.options.defaultMuted?this.options.defaultMuted:!0;this.maxChkCurrentTimes="undefined"!=typeof this.options.maxChkCurrentTimes? this.options.maxChkCurrentTimes:2;this.maxChkBufferdTimes="undefined"!=typeof this.options.maxChkBufferdTimes?this.options.maxChkBufferdTimes:5;this.maxChkReadyStateTimes="undefined"!=typeof this.options.maxChkReadyStateTimes?this.options.maxChkReadyStateTimes:5;this.maxChkSeekTimes="undefined"!=typeof this.options.maxChkSeekTimes?this.options.maxChkSeekTimes:2;this.maxDelaySec="undefined"!=typeof this.options.maxDelaySec?this.options.maxDelaySec:8;this.errorSendBack="undefined"!=typeof this.options.errorCallBack? this.options.errorCallBack:null;this.doInfo=-1;this.iNowNetErrorErrorCnt=0;this.RegId="undefined"!=typeof this.options.RegId?this.options.RegId:(new Date).getTime();this.bIsFirstPlayHint=!1;this.TotalChangeLineCnt=this.iErrorTotalCnt=0;this.MaxTotalChangeLineCnt=10;this.DelayStartTime=0;this.MaxDelayTimeGap=60}InitConnect(a,b,c,f){this.Stop();this.showLogs("Player InitConnect");var d=this;this.init=!0;this.bIsFirstPlayHint=!1;this.vUrl=b;this.linePart=c;this.chkLoadErrorTimes=0;this.resetVar();-1!= this.doInfo&&(clearInterval(this.doInfo),this.doInfo=-1);this.doInfo=setInterval(this.info.bind(this),1E3);"undefined"!==typeof f&&(this.maxDelaySec=this.options.maxDelaySec=f);if(null==this.videoElm)if(this.videoElm=document.getElementById(a),this.videoElm.defaultMuted=this.defaultMuted,this.lastSoundState=this.videoElm.muted=this.defaultMuted,this.addTimedMetadataEvent(),!0===this.hlsSupport)this.HLSObj=new Hls(this.varObj),console.log("HLS Version:["+Hls.version+"]"),this.SetPloader(),this.HLSObj.startPosition= 0,this.hlsEvent();else for(this.videoElm.crossorigin="use-credentials",this.videoElm.addEventListener("play",function(){d.showLogs("ElementEvent play")}),this.videoElm.addEventListener("loadstart",function(){d.showLogs("ElementEvent loadstart");var e=new XMLHttpRequest;e.onreadystatechange=function(){4==e.readyState&&200==e.status&&d.m3u8URLParse(e.responseText)};e.open("GET",d.vUrl,!0);e.send(null)}),this.videoElm.addEventListener("error",function(e){d.showLogs("Error code: "+e.currentTarget.error.code); e.currentTarget.error.message&&d.showLogs("Error message: "+e.currentTarget.error.message);d.showLogs("Error loading: "+d.vUrl);4===e.currentTarget.error.code&&(d.showLogs("call restart"),d.restart())}),this.videoElm.addEventListener("loadedmetadata",function(){d.showLogs("ElementEvent loadedmetadata")}),a=0;ab&&(this.debug&&a.showLogs("Error: Buffered length error"),b=0);try{this.bufferTime=this.videoElm.buffered.end(b)}catch(d){this.bufferTime= 0}this.readyState=this.videoElm.readyState;this.currentTime=this.videoElm.currentTime;this.delayTime=this.bufferTime-this.currentTime;this.logId&&(document.getElementById("readyState").innerHTML="ReadyState: "+this.readyState+"",document.getElementById("currentTime").innerHTML="Current: "+this.currentTime+"",document.getElementById("bufferTime").innerHTML="Buffered: "+this.bufferTime+"",document.getElementById("delayTime").innerHTML="Delay: "+this.delayTime+"",this.isMonitor|| (document.getElementById("timedMeta").innerHTML="TimedMeta: "+this.timedMeta+"",document.getElementById("timedMetaTime").innerHTML="TimedMetaTime: "+this.timedMetaTime+"",this.videoElm.getVideoPlaybackQuality&&typeof this.videoElm.getVideoPlaybackQuality===typeof Function?document.getElementById("dropFrame").innerHTML="DropFrame: "+this.videoElm.getVideoPlaybackQuality.droppedVideoFrames+"":document.getElementById("dropFrame").innerHTML="DropFrame: "+this.videoElm.webkitDroppedFrameCount+ ""));if(!1===this.videoElm.paused){if(this.lastCurrent!=this.currentTime?(this.lastCurrent=this.currentTime,this.chkCurrentTimes=0):(++this.chkCurrentTimes,a.showLogs("check Current: "+this.chkCurrentTimes)),this.chkCurrentTimes>=this.maxChkCurrentTimes){a.showLogs("check current to max count.");this.ErrorHint("403");return}}else this.chkCurrentTimes=0;this.lastBufferd!=this.bufferTime?(this.lastBufferd=this.bufferTime,this.chkBufferdTimes=0):(++this.chkBufferdTimes,a.showLogs("check bufferd: "+ this.chkBufferdTimes));if(this.chkBufferdTimes>=this.maxChkBufferdTimes)a.showLogs("check bufferd to max count."+this.maxChkBufferdTimes),this.ErrorHint("403");else if(2>this.readyState?(++this.chkReadyStateTimes,a.showLogs("check ReadyState: "+this.chkReadyStateTimes)):this.chkReadyStateTimes=0,this.chkReadyStateTimes>this.maxChkReadyStateTimes)a.showLogs("check ReadyState to max count."),this.ErrorHint("403");else{if(!0===this.iOS){var c=(new Date).getTime();if(0==this.lastclientTime||2E3this.maxDelaySec/2+1?this.chkPlayBackTimes+1:0;2["+this.videoElm.seekable.start(0)+","+this.videoElm.seekable.end(0)+"]");this.seekableEnd>this.videoElm.currentTime&&this.Seek(this.seekableEnd)}else!0===this.hlsSupport&&(this.seekTime=this.delayTime- this.maxDelaySec,this.Seek(this.videoElm.currentTime+this.seekTime));this.chkSeekTimes=this.delayTime>this.maxDelaySec?this.chkSeekTimes+1:0;this.delayTime>this.maxDelaySec&&this.chkSeekTimes>=this.maxChkSeekTimes&&(this.showLogs("Delay > "+this.maxDelaySec+" and seek failed, restart connect now "),this.restart())}}resetVar(){this.chkPlayBackTimes=this.chkBasetimes=this.chkLoadErrorTimes=this.chkSeekTimes=this.chkReadyStateTimes=this.chkBufferdTimes=this.chkCurrentTimes=this.lastbase=this.lastclientTime= this.lastBufferd=this.lastCurrent=this.delayTime=this.currentTime=this.readyState=this.bufferTime=0;this.errDetails=""}setLogId(a){this.logId=a;a=document.createElement("div");a.setAttribute("id","readyState");a.setAttribute("style","margin-top:10px");a.innerHTML="ReadyState: ";document.body.appendChild(a);a=document.createElement("div");a.setAttribute("id","currentTime");a.setAttribute("style","margin-top:10px");a.innerHTML="Current: ";document.body.appendChild(a);a=document.createElement("div"); a.setAttribute("id","bufferTime");a.setAttribute("style","margin-top:10px");a.innerHTML="Buffer: ";document.body.appendChild(a);a=document.createElement("div");a.setAttribute("id","delayTime");a.setAttribute("style","margin-top:10px");a.innerHTML="Delay: ";document.body.appendChild(a);this.isMonitor||(a=document.createElement("div"),a.setAttribute("id","dropFrame"),a.setAttribute("style","margin-top:10px"),a.innerHTML="DropFrame: ",document.body.appendChild(a),a=document.createElement("div"), a.setAttribute("id","timedMeta"),a.setAttribute("style","margin-top:10px"),a.innerHTML="TimedMeta: ",document.body.appendChild(a),a=document.createElement("div"),a.setAttribute("id","timedMetaTime"),a.setAttribute("style","margin-top:10px"),a.innerHTML="TimedMetaTime: ",document.body.appendChild(a),a=document.createElement("div"),a.setAttribute("id",this.logId),a.setAttribute("style","width:600px; height:300px; overflow:auto; background-color:#eee; margin-top:10px; "),document.body.appendChild(a))}ErrorHint(a){var b= !1;!0===this.todoErrorHint?console.log("errorhint be return :["+a+"]"):("001"!==a&&(this.TotalChangeLineCnt+=1,this.TotalChangeLineCnt<=this.MaxTotalChangeLineCnt?(b=!0,this.DelayStartTime=Date.now()/1E3):Date.now()/1E3-this.DelayStartTime>=this.MaxDelayTimeGap&&(b=!0,this.DelayStartTime=Date.now()/1E3)),1==b&&(this.todoErrorHint=!0,-1!=this.doInfo&&(this.showLogs("to do stop info setInterval!!"),clearInterval(this.doInfo),this.doInfo=-1),this.Stop(),null!=this.errorSendBack&&this.errorSendBack(this.RegId, a)))}showLogs(a){var b=new Date;b="["+b.getFullYear()+"-"+(b.getMonth()+1)+"-"+b.getDate()+" "+b.getHours()+":"+b.getMinutes()+":"+b.getSeconds()+":"+b.getMilliseconds()+"]";if(!0===this.debug&&(console.warn(b+" "+a),""!=this.logId)){var c="
"+$("#"+this.logId).html();$("#"+this.logId).html(b+" "+a+c)}}pStatus(a){this.showLogs(a)}} ;