function PlayerPlayback(){throw{msg:"Don't NEW a singleton."}}function ViewReplaySearch(){throw{msg:"Don't NEW a singleton."}}EventListener.apply(PlayerPlayback),function(){var e=EnumPBPlayState.IDLE;PlayerPlayback.init=function(){this.pbChannel_mode=1,this.streamSel=0,this.isSearching=!1,this.fileTypeSels=[],this.fileTypeSelIndex=0,this.chPositions=[],this.bcDatePicker,this.pbFileBarCanvas,this.trigger("init"),this.initEvents(),this.replayableDays="0",this.initUI(),ViewReplaySearch.init&&ViewReplaySearch.init(),delete this.init},PlayerPlayback.initUI=function(){this.bcDatePicker=new BCDatePicker,g_bcDatePicker=this.bcDatePicker,this.bcDatePicker.initDatePicker(),this.pbFileBarCanvas=new PbFileBarCanvas,g_pbFileBarCanvas=this.pbFileBarCanvas,g_device&&this.pbFileBarCanvas.initPlaybackToolbar(),ControllerMain.on("resize",(function(){setTimeout((function(){if(null!=g_pbFileBarCanvas){var e=document.getElementById("playback_toolbar_bg");if(null!=e){var a=document.getElementById("playbaack_toolbar_content");e.width=a.clientWidth,g_pbFileBarCanvas.redrawPlaybackTool(),g_pbFileBarCanvas.initPlaybackToolbar()}}}),50)})),g_pbFileBarCanvas.mouse={y:20,x:256},delete this.initUI},PlayerPlayback.initEvents=function(){FPlayer.on("statechange",(function(e,a,t){if(FPlayer.getMode()==EnumViewStatus.PLAYBACK)switch(t){case EnumViewStatus.BUFFERING:case EnumViewStatus.PLAYING:PlayerPlayback.updateState(EnumPBPlayState.PLAYING);break;case EnumViewStatus.PAUSED:PlayerPlayback.updateState(EnumPBPlayState.PAUSED);break;case EnumViewStatus.ERROR:case EnumViewStatus.CLOSED:default:PlayerPlayback.updateState(EnumPBPlayState.IDLE)}})),BcH5Player.on("statechange",(function(e,a,t){if(ChannelManager.get(e.getChannel()).getMode()==EnumViewStatus.PLAYBACK)switch(t){case EnumViewStatus.BUFFERING:case EnumViewStatus.PLAYING:PlayerPlayback.updateState(EnumPBPlayState.PLAYING);break;case EnumViewStatus.PAUSED:PlayerPlayback.updateState(EnumPBPlayState.PAUSED);break;case EnumViewStatus.ERROR:case EnumViewStatus.CLOSED:default:PlayerPlayback.updateState(EnumPBPlayState.IDLE)}})),$("input[name=pb_type_checkbox_all]").on("click",(function(){$("input[name=pb_type_checkbox_item]").prop("checked",$(this).is(":checked")),PlayerPlayback.updateFileTypeSels()})),$("input[name=pb_type_checkbox_item]").on("click",(function(){PlayerPlayback.updateFileTypeSels()})),delete this.initEvents},PlayerPlayback.on("dayChange",(function(){ViewReplaySearch.searchFile(PlayerPlayback.bcDatePicker.getSearchDate())})),PlayerPlayback.on("monthChange",(function(e,a){ViewReplaySearch.searchMonth(e,a)})),PlayerPlayback.constructRTMPUrl=function(e,a,t,n,i){var l=ControllerLogin.getQueryDataByCount([],"PlayerPlayback",0),r="";-1!==l&&(r=l.query);var c="";return c=ControllerMain.isNvr?"rtmp://"+window.location.hostname+":"+ControllerFlash.rtmpPort+"/bcs/playback.bcs?channel="+e+"&type="+EnumRTMPStreamType[t]+"&start="+i+"&seek="+n+"&token="+infoHandler.recover2Str(ControllerLogin.token)+"&"+r:"rtmp://"+window.location.hostname+":"+ControllerFlash.rtmpPort+"/vod/"+a+"?token="+infoHandler.recover2Str(ControllerLogin.token)+"&channel="+e+"&stream="+EnumRTMPStreamType[t]+"&"+r,console.dbg("PlayerPlayback.constructRTMPUrl: ",c),c},PlayerPlayback.constructH5Url=function(e,a,t,n,i){var l=ControllerLogin.getQueryDataByCount([],"PlayerPlayback",0),r="";-1!==l&&(r=l.query);var c=window.location.port?":"+window.location.port:"",o="";return o=ControllerMain.isNvr?window.location.protocol+"//"+window.location.hostname+c+"/flv?port="+ControllerFlash.rtmpPort+"&app=bcs&stream=playback.bcs&channel="+e+"&type="+EnumRTMPStreamType[t]+"&start="+i+"&seek="+n+"&token="+infoHandler.recover2Str(ControllerLogin.token)+"&"+r:window.location.protocol+"//"+window.location.hostname+c+"/cgi-bin/api.cgi?cmd=Playback&source="+a+"&output="+a+"&token="+infoHandler.recover2Str(ControllerLogin.token)+"&"+r,console.dbg("PlayerPlayback.constructFlvUrl: ",o),o},PlayerPlayback.reload=function(){PlayerPlayback.pbChangePlayStreamSel(PlayerPlayback.streamSel),PlayerPlayback.pbChannel_mode=EnumPbChannelMode.ONE,g_device.isIPC?$("#plabck_channels_views").hide():$("#plabck_channels_views").show(),PlayerPlayback.pbFileBarCanvas.setChannelMode(PlayerPlayback.pbChannel_mode);for(var e=0;e<4;++e)PlayerPlayback.pbSetViewPositionWithChannel(e,-1);PlayerPlayback.pbFileBarCanvas.initPlaybackToolbar(),PlayerPlayback.bcDatePicker.initDatePicker(),0==PlayerPlayback.fileTypeSelIndex?($("input[name=pb_type_checkbox_all]").prop("checked",!0),$("input[name=pb_type_checkbox_item]").prop("checked",!0)):($("input[name=pb_type_checkbox_all]").prop("checked",!1),$("input[name=pb_type_checkbox_item]").prop("checked",!1),$("input[name=pb_type_checkbox_item]").eq(PlayerPlayback.fileTypeSelIndex-1).prop("checked",!0)),PlayerPlayback.updateFileTypeSels()},PlayerPlayback.updateFileTypeSels=function(){PlayerPlayback.fileTypeSels.length=0,$("input[name=pb_type_checkbox_item]").each((function(){$(this).prop("checked")&&PlayerPlayback.fileTypeSels.push(PlayerPlayback.getPbFileType($(this).val()))})),PlayerPlayback.fileTypeSels.length<3?$("input[name=pb_type_checkbox_all]").prop("checked",!1):$("input[name=pb_type_checkbox_all]").prop("checked",!0),PlayerPlayback.pbFileBarCanvas.setCanvasPositionArray(PlayerPlayback.chPositions)},PlayerPlayback.getPbFileType=function(e){return"Schedule"==e?EnumPbShowFileType.SCHEDULE:"Manual"==e?EnumPbShowFileType.MANUAL:"Alarm"==e?EnumPbShowFileType.ALARM:EnumPbShowFileType.ALL},PlayerPlayback.timelineDidSeekToDate=function(e){ViewReplaySearch.seek(e)},PlayerPlayback.timeCutAreaToDate=function(e,a){var t=ViewManager.getViewObject(0).getChannelId();if(e>a){var n=e;e=a,a=n}var i={year:e.getFullYear(),mon:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),min:e.getMinutes(),sec:e.getSeconds()},l={year:a.getFullYear(),mon:a.getMonth()+1,day:a.getDate(),hour:a.getHours(),min:a.getMinutes(),sec:a.getSeconds()};new dialogPoint({msg:"Confirm the video of the download period ?
( "+(i.year+"-"+i.mon+"-"+i.day+" "+i.hour+":"+i.min+":"+i.sec+" ~ "+l.year+"-"+l.mon+"-"+l.day+" "+l.hour+":"+l.min+":"+l.sec)+" )",callback:function(){ViewReplaySearch.waiter.show();const e=ViewReplaySearch.getSelectedStream(),a=~~(EnumStreamType.TRACK_FLUENT===e||EnumStreamType.TRACK_CLEAR===e);CGI.sendCommand("NvrDownload",{NvrDownload:{channel:t,iLogicChannel:a,StartTime:i,EndTime:l,streamType:EnumStreamFullNames[e]}},(function(e){ViewReplaySearch.waiter.hide(),g_device.channels[t].videoFiles=e.fileList,ControllerDownload.show(t)}),(function(e,a,t){ViewReplaySearch.waiter.hide(),CGI.autoErrorHandler(e,a,t)}),!0,void 0,15e4)}})},PlayerPlayback.pbChangePlayStreamSel=function(e){PlayerPlayback.streamSel=parseInt(e),ViewReplaySearch.setSelectedStream(PlayerPlayback.streamSel)},PlayerPlayback.isFileTypeSel=function(e){var a=0,t=!1;for(a=0;a3||(PlayerPlayback.chPositions[e]=a)},PlayerPlayback.getState=function(){return e},PlayerPlayback.updateState=function(a){e=a},PlayerPlayback.resetState=function(){this.updateState(EnumPBPlayState.IDLE),ViewReplaySearch.resetState()},PlayerPlayback.changeChannel=function(e){ControllerFlash.setView(ViewManager.getViewObject(0),e),ViewReplaySearch.isFirstVisited=1,g_bcDatePicker.setDate(new Date,!0),PlayerPlayback.trigger("monthChange",[(new Date).getFullYear(),(new Date).getMonth()+1]),$("#TimelineBox").css({top:$("#preContent").offset().top+$("#preContent").outerHeight()}),setTimeout((function(){var a=ControllerLogin.channelState[e]?ControllerLogin.channelState[e].name:"";a=a||oneToZeroOne(e+1),$("#view-block-PLAYBACK-0-toolbar .view-channel-id").text(a)}),1e3),PlayerPlayback.resetState(),ControllerMain.trigger("resize"),g_pbFileBarCanvas.setScale(1),g_pbFileBarCanvas.autoScale(),g_pbFileBarCanvas.redrawPlaybackTool(),ChannelManager.get(e).setCurrentChannel()}}(),EventListener.apply(ViewReplaySearch),function(){var e=EnumStreamType.CLEAR,a="idle",t=0,n="0".repeat(31),i=null,l=null,r=null,c=null,o=null,s=!1;this.resetState=function(){s=!1},this.init=function(){this.waiter=new ViewWaiting({id:"replay-wait-search",text:"waiting.Searching_files",cancel:function(){a="idle",ViewReplaySearch.unbind("searchFileDone")}}),delete this.init},this.setSelectedStream=function(a){var t=e;e=a,this.trigger("streamTypeChange",[t,a])},this.closeAllPlayer=function(){$(range(0,ChannelManager.getNumber()-1)).each((function(e){try{flashCheck()?FPlayer.close(e):BcH5Player.destroy(e)}catch(e){}})),PlayerPlayback.updateState(EnumPBPlayState.IDLE)},this.on("streamTypeChange",(function(e,a){if(ViewManager.getMode()==EnumCurState.PLAYBACK)if(a!=e&&(s=!1),a!=e||PlayerPlayback.getState()==EnumPBPlayState.IDLE)s?this.firstSwitchedStream?this.seek(t):this.firstSwitchedStream=!0:this.searchFile(o);else{for(var n=0,i=0;i=0;--c){var s,y="";if(ControllerMain.isNvr&&(y=r[c].PlaybackTime.year+"",y+=r[c].PlaybackTime.mon<10?"0"+r[c].PlaybackTime.mon:r[c].PlaybackTime.mon,y+=r[c].PlaybackTime.day<10?"0"+r[c].PlaybackTime.day:r[c].PlaybackTime.day,y+=r[c].PlaybackTime.hour<10?"0"+r[c].PlaybackTime.hour:r[c].PlaybackTime.hour,y+=r[c].PlaybackTime.min<10?"0"+r[c].PlaybackTime.min:r[c].PlaybackTime.min,y+=r[c].PlaybackTime.sec<10?"0"+r[c].PlaybackTime.sec:r[c].PlaybackTime.sec),r[c].startTime<=a&&a<=r[c].endTime?s=Math.round((a.getTime()-r[c].startTime)/1e3):(0==c&&r[c].startTime>=a||c>0&&r[c].startTime>=a&&r[c-1].endTime<=a)&&(s=0),void 0!==s){var h="";h=flashCheck()?PlayerPlayback.constructRTMPUrl(l.getId(),r[c].fileName,PlayerPlayback.streamSel,s,y):PlayerPlayback.constructH5Url(l.getId(),r[c].fileName,PlayerPlayback.streamSel,s,y),l.setReplayData(h,s);break}}c<0&&l.getStatus()!=EnumChannelStatus.CLOSED&&l.close();try{if(c<0)throw flashCheck()||BcH5Player.showStatusImg(EnumFlvStatus.nofile),"no records";l.playingFile=c,l.playingStream=e,l.playingDay=o.getUnixDateOnly(),l.playingStart=Math.max(0,(r[c].startTime.getTime()-o.getTime())/1e3),void 0!==s&&(l.open(PlayerPlayback.streamSel),n++)}catch(e){l.close()}n?PlayerPlayback.updateState(EnumPBPlayState.PLAYING):PlayerPlayback.updateState(EnumPBPlayState.IDLE)}},this.getUsingDay=function(){return o},this.on("searchFileReceived",(function(e){if(this.firstSwitchedStream=!0,"searching"==a){a="idle",o=i;for(var t=0;t