playbackSDK.js 44 KB

1
  1. !function(e){var t={};function a(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=t,a.d=function(e,t,i){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(a.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(i,n,function(t){return e[t]}.bind(null,n));return i},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=1)}([,function(e,t){!function e(t,a,i){var n="3.7.0";!function(){function e(e){console.log&&console.log(e)}function t(e){console.warn&&console.warn(e)}function i(e,t){for(var a=e.split("."),i=t.split("."),n=0,r=a.length,s=!1;n<r-1;){var o=parseInt(a[n]),c=parseInt(i[n]);if(o>c){s=!0;break}if(o<c){s=!1;break}n++}return s}var r="//view.csslcloud.net/version/version.json?v="+(new Date).getTime(),s=null;try{a.XMLHttpRequest?s=new XMLHttpRequest:a.ActiveXObject&&(s=new ActiveXObject("Microsoft.XMLHTTP")),s&&(s.open("GET",r,!0),s.onreadystatechange=function(){if(4===s.readyState&&200===s.status){var a=JSON.parse(s.responseText);a&&function(a){var r=a.h5?a.h5:{};if(r.lowyerVersion&&i(r.lowyerVersion.v,n)){r.lowyerVersion.expiration;var s=r.errorMsg;if(e(s),Error)throw new Error(s);t(s)}else if(r.latestVersion&&i(r.latestVersion.v,n))t(r.notify)}(a)}},s.send())}catch(t){e("获取版本信息失败")}}();var r={retry:0,isFrist:!0,ccTrackTimer:null,ccTrackCount:0,catonDuration:0,isCaton:!1,catonCount:0,HEART_BEAT:6e4,isEnd:!1,ccTrackTiming:0,init:function(e){ccTrack.init({business:"2001",roleid:e.viewerId,userid:e.viewerId,roomid:e.roomId,liveid:e.liveId,platform:H.isMobile()?"h5-pc":"h5-m",scene_type:1,event_ver:"2.1",recordid:e.recordId,appVer:n,appid:e.userId}),this.join()},join:function(){try{var e={event:"join",code:200,rid:(new Date).getTime()};ccTrack.tragger(e)}catch(e){}},pusherSucces:function(){try{var e={event:"pusher",code:200,rid:(new Date).getTime()};ccTrack.tragger(e)}catch(e){}},pusherReconnect:function(){this.retry++;try{var e={event:"pusher",code:201,rid:(new Date).getTime(),retry:this.retry};ccTrack.tragger(e)}catch(e){}},pusherReconnecting:function(){try{var e={event:"pusher",code:402,rid:(new Date).getTime()};ccTrack.tragger(e)}catch(e){}},pusherFailed:function(){try{var e={event:"pusher",code:401,rid:(new Date).getTime()};ccTrack.tragger(e)}catch(e){}},pusherDisconnect:function(){try{var e={event:"pusher",code:400,rid:(new Date).getTime()};ccTrack.tragger(e)}catch(e){}},ccTrackTimerFoo(){var e=this;e.ccTrackTimer&&(clearInterval(e.ccTrackTimer),e.ccTrackTimer=null),e.ccTrackTimer=setInterval(function(){if(e.isEnd)return clearInterval(e.ccTrackTimer),void(e.ccTrackTimer=null);try{e.ccTrackCount=e.ccTrackCount+1,e.isCaton&&(e.catonDuration=e.catonDuration+((new Date).getTime()-e.catonTime)),e.catonDuration>=6e4&&(e.isCaton=!1);var t={event:"heartbeat",code:200,blocktimes:e.catonCount,blockduration:e.catonDuration>=6e4?0:e.catonDuration,rid:(new Date).getTime(),num:e.ccTrackCount,heartinter:60,cdn:e.ccTrackCDN};e.catonCount=0,e.catonDuration=0,e.ccTrackTiming=(new Date).getTime(),ccTrack.tragger(t)}catch(e){console.log("ccTrackTimer:",e)}},e.HEART_BEAT)},setUrl(e){this.ccTrackCDN=/^http(s)?:\/\/(.*?)\//.exec(e)[2]},endLive(){this.isEnd=!0,this.isFrist=!0},bindVideoEvent:function(e){var t=this,a=e;try{a.removeEventListener("waiting",function(){}),a.removeEventListener("play",function(){}),a.removeEventListener("canplay",function(){}),a.removeEventListener("ended",function(){})}catch(e){}a.addEventListener("canplay",function(){t.startPlayTime=(new Date).getTime(),t.isCaton&&(t.isCaton=!1,0===t.catonCount?(t.catonCount=t.catonCount+1,t.catonDuration=t.catonDuration+((new Date).getTime()-t.ccTrackTiming)):t.catonDuration=t.catonDuration+((new Date).getTime()-t.catonTime))}),a.addEventListener("play",function(){var e=(new Date).getTime();if(t.isFrist){t.ccTrackTimerFoo(),t.isFrist=!1;try{var a={event:"play",et:e-t.startPlayTime,code:200,rid:(new Date).getTime(),cdn:t.ccTrackCDN};ccTrack.tragger(a)}catch(e){}}}),a.addEventListener("waiting",function(){t.isSeeking||(t.catonCount=t.catonCount+1,t.isCaton=!0,t.catonTime=(new Date).getTime())}),a.addEventListener("playing",function(){}),a.addEventListener("seeking",function(){t.isSeeking=!0},!1),a.addEventListener("seeked",function(){t.isSeeking=!1},!1),a.addEventListener("ended",function(){t.isEnd=!0},!1),a.onerror=function(){try{var e={event:"play",code:400,rid:(new Date).getTime()};ccTrack.tragger(e)}catch(e){}}}},s=function(e){this.isReady=!1,this.isPublishing=0,this.id=e.callbackPlayer.id,this.playbackRateValue=1;var a={userid:e.userId,videoid:e.videoId,recordid:e.recordId,isShowBar:e.isShowBar,upid:e.upId,viewerid:e.viewerId,roomid:e.roomId,ua:"1"},n={allowFullscreen:"true",allowScriptAccess:"always",wmode:"transparent"};this.flashPlayerInit=function(){if(swfobject.embedSWF("//player.csslcloud.net/platform/live/CallbackPlayer.swf",e.callbackPlayer.id,e.callbackPlayer.width,e.callbackPlayer.height,"10.0.0","/flash/expressInstall.swf",a,n),"isMobile"!=H.isMobile())new ReportLog(e,0,1,null,!1)},I.isH5play||this.flashPlayerInit(),this.destroy=function(){I.isH5play&&H&&H.destroy()},this.getFlash=function(){return swfobject.getObjectById(this.id)},this.playbackRate=function(e){if(I.isH5play||"isMobile"===H.isMobile()){e=parseFloat(e);this.playbackRateValue=e,this.getH5player().playbackRate=e}},this.seek=function(e){if(!(e<0))if(I.isH5play||"isMobile"==H.isMobile())this.getH5player().currentTime=e;else{var t=this.getFlash();if(!t)return;t.seek(e)}},this.getFlash=function(){return swfobject.getObjectById(this.id)},this.getH5player=function(){return t("#playbackVideo")[0]},this.getPlayerTime=function(){return this.isReady?(e=I.isH5play||"isMobile"==H.isMobile()?this.getH5player().currentTime:parseInt("function"==typeof this.getFlash().getPosition?this.getFlash().getPosition():0,10),isNaN(e)||e<0?0:e):0;var e},this.getDuration=function(){if(I.isH5play||"isMobile"==H.isMobile())return this.getH5player().duration;var e=this.getFlash();return e?e.getDuration?e.getDuration():0:void 0},this.getBuffer=function(){if(I.isH5play||"isMobile"==H.isMobile()){if(!this.getH5player()||!this.getH5player().buffered||!this.getH5player().buffered.end(0))return 0;for(var e=0,t=this.getH5player().buffered,a=this.getH5player().currentTime,i=0;i<t.length;i++)if(a<t.end(i)){e=t.end(i);break}return e}var n=this.getFlash();if(n)return n.getBufferLength?n.getBufferLength():0},this.setVolume=function(e){if(!I.isH5play&&"isMobile"!=H.isMobile()){var t=this.getFlash();if(!t)return;return t.setVolume?t.setVolume(e):0}this.getH5player().volume=parseFloat(e)},this.getVolume=function(){if(I.isH5play||"isMobile"==H.isMobile())return this.getH5player().volume;var e=this.getFlash();return e?e.getVolume?e.getVolume():0:void 0},this.switchFullScreen=function(e){(I.isH5play||"isMobile"==H.isMobile())&&(e?this.getH5player().requestFullscreen?this.getH5player().requestFullscreen():this.getH5player().mozRequestFullScreen?this.getH5player().mozRequestFullScreen():this.getH5player().msRequestFullscreen?this.getH5player().msRequestFullscreen():this.getH5player().webkitSupportsFullscreen&&this.getH5player().webkitEnterFullscreen():this.getH5player().exitFullscreen?this.getH5player().exitFullscreen():this.getH5player().msExitFullscreen?this.getH5player().msExitFullscreen():this.getH5player().mozExitFullScreen?this.getH5player().mozExitFullScreen():this.getH5player().webkitExitFullscreen?this.getH5player().webkitExitFullscreen():i.mozCancelFullScreen&&i.mozCancelFullScreen())},this.play=function(){if(!I.isH5play&&"isMobile"!=H.isMobile()){var e=this.getFlash();if(!e)return;return e.isPlay?e.isPlay():0}H.pauseState?(this.getH5player().play(),this.playbackRate(this.playbackRateValue)):this.getH5player().pause()},this.setZScale=function(e){var t=this.getFlash();if(t)return t.setZScale(e)},this.getZScale=function(){var e=this.getFlash();if(e)return e.getZScale()},this.setScale=function(e){var t=this.getFlash();if(t)return t.setScale(e)},this.getScale=function(){var e=this.getFlash();if(e)return e.getScale()},this.openSettingPanel=function(){var e=this.getFlash();if(e)return e.openSettingPanel()}},o=function(e){var t="https:"===a.location.protocol,n=e.chat.host;if(t&&n&&n.indexOf(":")){var s=n.split(":");if(2==s.length){var o=parseInt(s[1]);if(!isNaN(o)){var c=o+400;n=s[0]+":"+c}}}var l=0;if("isMobile"==H.isMobile()&&(l=1),I.forceNew){var d=io.connect(i.location.protocol+"//"+n+"/replay?roomid="+e.roomId+"&sessionid="+e.viewer.sessionId+"&platform=1&terminal="+l,{forceNew:!0});v.log("{forceNew: true}")}else d=io.connect(i.location.protocol+"//"+n+"/replay",{query:{roomid:e.roomId,sessionid:e.viewer.sessionId,platform:1,terminal:l}}),v.log("{forceNew: false}");d.on("connect",function(){r.pusherSucces()}),d.on("disconnect",function(){r.pusherDisconnect()}),d.on("reconnect_failed",function(){r.pusherFailed()}),d.on("reconnecting",function(){r.pusherReconnecting()}),d.on("reconnect",function(){r.pusherReconnect()}),this.destroy=function(){d&&d.disconnect()}},c=function(e,t){this.isReady=!1;_.fastMode||swfobject.embedSWF("//zeus.csslcloud.net/flash/Player.swf",e.drawPanel.id,e.drawPanel.width,e.drawPanel.height,"10.0.0","/flash/expressInstall.swf",{type:"drawpanel"},{allowFullscreen:"true",allowScriptAccess:"always",wmode:"transparent"},{}),this.getFlash=function(){if(this.isReady)return swfobject.getObjectById(e.drawPanel.id)},this.clear=function(){_.clear();var e=this.getFlash();e&&e.clear()},this.draw=function(e){_.draw(e);var t=this.getFlash();t&&t.draw(e)},this.draws=function(e){var t,a=this.getFlash();a&&(t=e,setTimeout(function(){a.drawList(t)}))},this.filp=function(e){_.pageChange(e);var t=this.getFlash();if(t){var i=JSON.parse(e),n=i.url;"https:"===a.location.protocol&&(i.url=n.replace(/http:/g,"https:")),w.adapt?t.filp(JSON.stringify(i),"auto"):t.filp(JSON.stringify(i))}},this.animation=function(e){_.animationChange(e);var t=this.getFlash();t&&t.animation(e)},this.intervalNum=0,this.interval=function(){var e=0;try{e=m.callbackPlayer.getPlayerTime()}catch(e){}if(!(e<0)){S&&(M=e,Math.abs(M-R)>=2.5&&seekComplete&&seekComplete(),R=e),m.isRequestDraws&&m.drawsInfoRequestPool.isHttpRequestCurrentDraws(e,function(e){m.draws=e});try{if(m.animations&&m.animations.length>0)if(m.animationIndex<m.animations.length)if((r=m.pageChangeIndex)>=0){var t=m.pageChanges[r],i=m.animations[m.animationIndex+1];t&&i&&t.encryptDocId==i.encryptDocId&&e>=i.time&&t.time<=i.time&&(_.fastMode?this.animation(i):this.animation(JSON.stringify({fileName:i.docName,totalPage:i.docTotalPage,docid:i.encryptDocId,url:i.url,page:i.pageNum,step:i.step})),m.animationIndex=m.animationIndex+1)}}catch(e){}try{if(m.pageChanges&&m.pageChanges.length>0)if(m.pageChangeIndex<m.pageChanges.length)if(e>=(t=m.pageChanges[m.pageChangeIndex+1]).time){"function"==typeof a.on_cc_callback_page_change&&a.on_cc_callback_page_change(t),"function"==typeof a.on_cc_request_snapshoot&&a.on_cc_request_snapshoot(t),_.fastMode?this.filp(t):this.filp(JSON.stringify({fileName:t.docName,totalPage:t.docTotalPage,docid:t.encryptDocId,url:t.url,page:t.pageNum,useSDK:t.useSDK})),m.pageChangeIndex=m.pageChangeIndex+1;var n={};n.docId=t.docId,n.docName=t.docName,n.docTotalPage=t.docTotalPage,n.pageNum=t.pageNum,"function"==typeof a.on_cc_callback_pagechange&&a.on_cc_callback_pagechange(n)}}catch(e){}try{var r;if(m.animations&&m.animations.length>0)if(m.animationIndex<m.animations.length)if((r=m.pageChangeIndex)>=0){t=m.pageChanges[r],i=m.animations[m.animationIndex+1];t&&i&&t.encryptDocId==i.encryptDocId&&e>=i.time&&t.time<=i.time&&(_.fastMode?this.animation(i):this.animation(JSON.stringify({fileName:i.docName,totalPage:i.docTotalPage,docid:i.encryptDocId,url:i.url,page:i.pageNum,step:i.step})),m.animationIndex=m.animationIndex+1)}}catch(e){}try{if(m.draws&&m.draws.length>0&&m.drawIndex<m.draws.length)for(var s=m.draws[m.drawIndex+1];e>=s.time;)_.fastMode?this.draw(s):this.draw(s.data),m.drawIndex=m.drawIndex+1,s=m.draws[m.drawIndex+1]}catch(e){}}},this.destroy=function(){-1!=m.drawPanel.intervalNum&&clearInterval(m.drawPanel.intervalNum)},this.intervalPainting=function(e){e.drawPanel.intervalNum=setInterval(function(){e.drawPanel.interval(e)},1e3)}},l=function(e){t.ajax({url:e.url,type:"GET",data:e.data,tryCount:0,retryLimit:3,timeout:3e4,dataType:"jsonp",success:function(t){e.done(t)},error:function(a,i,n){if("timeout"==i)return this.tryCount++,this.tryCount<this.retryLimit?void t.ajax(this):void("function"==typeof e.fn&&e.fn(i));a.status}})},d=function(e,i){var s={roomid:e.roomId,userid:e.userId,liveid:e.liveId,upid:e.upId,groupid:e.groupId,recordid:e.recordId,viewertoken:e.viewertoken,viewername:e.viewername,forcibly:e.forcibly},o={globalData:{},requestLoginData:!1,requestInfoData:!1,requestDrawData:!1,requestChatqaData:!1,allRequests:0};s.version=n,s.service=3,s.client=4,l({url:"//view.csslcloud.net/api/room/replay/login",data:s,fn:a.on_cc_login_error,done:function(i){if(!c(i,a.on_cc_login_error))return!1;if(i.success){r.init(e),w.drawRequestTime=parseInt(i.datas.drawRequestTime)||1,a.TIMEOUT=a.TIMEOUT+1e3*w.drawRequestTime,_.fastMode||(w.drawRequestTime=""),v.log("options",w),m.state=new u;var n=new u;m.drawsInfoRequestPool=new h(m.state,n)}if(d(o.globalData,i),o.requestLoginData=!0,o.requestInfoData=!1,o.requestDrawData=!1,o.requestChatqaData=!1,o.allRequests++,f(o),"function"==typeof a.on_cc_login_success){var p=i.datas,g={type:p.template.type,desc:p.template.desc,name:p.template.name},y={name:p.viewer.name,id:p.viewer.id,groupId:p.viewer.groupId},I={desc:p.room.desc,liveStartTime:p.room.liveStartTime,name:p.room.name,documentDisplayMode:p.room.documentDisplayMode,barrage:p.room.barrage},b={startTime:p.live.endTime,endTime:p.live.endTime};a.on_cc_login_success({template:g,viewer:y,room:I,live:b})}var T=i.datas.viewer.marquee;"function"==typeof t.DW.getMarquee&&t.DW.getMarquee(T),w.drawRequestTime||l({url:"//view.csslcloud.net/api/view/replay/draw/info",data:s,fn:a.on_cc_request_draw_error,done:function(e){if(!c(e))return!1;d(o.globalData,e),o.requestLoginData=!1,o.requestInfoData=!1,o.requestDrawData=!0,o.requestChatqaData=!1,o.allRequests++,f(o)}}),l({url:"//view.csslcloud.net/api/view/replay/v2/chatqa/info",data:s,fn:a.on_cc_request_chatqa_error,done:function(e){if(!c(e,a.on_cc_request_chatqa_error))return!1;d(o.globalData,e),o.requestLoginData=!1,o.requestInfoData=!1,o.requestDrawData=!1,o.requestChatqaData=!0,o.allRequests++,f(o)}}),l({url:"//view.csslcloud.net/api/view/replay/v2/info",data:s,fn:a.on_cc_request_info_error,done:function(e){if(!c(e,a.on_cc_request_info_error))return!1;d(o.globalData,e),o.requestLoginData=!1,o.requestInfoData=!0,o.requestDrawData=!1,o.requestChatqaData=!1,o.allRequests++,f(o)}})}});var c=function(e,t){return e.success?!!e.datas:("function"==typeof t&&t(e),!1)},d=function(e,t){p(e,t),e.datas.meta||(e.datas.meta={}),p(e.datas.meta,t.datas.meta)},p=function(e,t){for(var a in t)t.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(e[a]=t[a])},f=function(e){i(e)}},u=function(){this.requestState=!1,this.result=0,this.startTime=0,this.endTime=0,this.key=0,this.index=0,this.ajax={},this.states=[],this.snapshoot=[],this.drawsAlready=0,this.roomId=w.roomId,this.userId=w.userId,this.recordId=w.recordId,this.liveId=w.liveId,this.drawRequestTime=w.drawRequestTime,this.setSnapshoot=function(e,t){this.snapshoot[e]=t},this.getSnapshoot=function(){return this.snapshoot},this.init=function(e){for(var t=0;t<this.drawRequestTime;t++){var a={requestState:!1,result:0,startTime:e.startTime,endTime:e.endTime,key:t};e.startTime=e.startTime+e.blockTime,e.endTime=e.startTime+e.blockTime,this.setState(a)}},this.httpRequest=function(e,i){var n=this;n.requestState=!0,this.ajax=t.ajax({url:e.url,type:"GET",data:e.param,tryCount:0,retryLimit:3,timeout:a.TIMEOUT,dataType:"jsonp",success:function(e){n.result=e,e.success?(i(e),n.requestState=!1):v.log("data.success",e.success)},error:function(e,a,i){if("timeout"==a)return this.tryCount++,this.tryCount<this.retryLimit?(t.ajax(this),void v.log("ajax["+n.key+"] try again tryCount",this.tryCount)):(v.log("数据请求失败且重试多次"),void(n.requestState=!1));e.status}})},this.abort=function(){this.ajax.abort(),this.requestState=!1},this.setState=function(e){if("object"==typeof e){var t=e.key||this.index++;e.key&&!isNaN(e.key)&&(this.index=parseInt(e.key)+1);var a=new u;a.requestState=e.requestState||this.requestState,a.result=e.result||this.result,a.startTime=e.startTime||this.startTime,a.endTime=e.endTime||this.endTime,a.ajax=e.ajax||this.ajax,a.snapshoot=e.snapshoot||this.snapshoot,a.key=t,this.states[t]=a}},this.getState=function(e){return this.states[e]},this.getStates=function(){return this.states},this.getCurrentStateIndex=function(e){for(var t=0,a=0;a<this.states.length;a++)if(e>this.states[a].startTime&&e<=this.states[a].endTime){t=a;break}return t},this.isDrawsAlready=function(){return parseInt(this.drawRequestTime,10)===parseInt(this.drawsAlready,10)}},h=function(e,t){function a(e,t){var a=e.concat(t),i=[],n={};for(var r in a)n[JSON.stringify(a[r])]||(i.push(a[r]),n[JSON.stringify(a[r])]=1);return i}this.state=e,this.requestNumber=2,this.httpRequestPool=[],this.draws=[],this.preState={},this.isHttpRequestCurrentDraws=function(t,a){if(e.drawRequestTime){var i=e.isDrawsAlready();if(i)v.log("画笔数据加载完毕,不在预加载某一段数据");else{var n=e.getStates(),r=e.getCurrentStateIndex(t),s=n[r];if(this.preState!=s&&this.preState.requestState&&(v.log("发现新的预加载请求,中断上一个预加载请求;index="+this.preState.key),this.preState.abort()),this.preState=s,i||s.result||s.requestState)v.log("预加载过这段数据或已有数据;index="+r);else{v.log("预加载数据",r);var o={index:r,states:n};this.httpRequestCurrentDraws(o,a)}}}},this.httpRequestCurrentDraws=function(e,t){var i=this,n=e.states,r=e.index,s=n[r],o={url:"//view.csslcloud.net/api/view/replay/v2/draw/range",param:{starttime:s.startTime,endtime:s.endTime,userid:s.userId,recordid:s.recordId,liveid:s.liveId}};s.httpRequest(o,function(e){var n=e.datas.meta.draw;v.log("*** 预加载成功 callback.draws["+r+"] ***",n),i.draws=a(i.draws,n),i.draws.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)}),t(i.draws),m.state.drawsAlready++})},this.httpRequestStream=function(e){var i=this;if(i.state.isDrawsAlready())return v.log("httpRequestStream draws already",i.draws),v.log("callback.state",m.state),void v.log("snapshoot",t);for(var n=i.state.getStates(),r=0;r<n.length;r++){if(!(o=n[r]).result&&!o.requestState){if(!(i.httpRequestPool.length<i.requestNumber))break;i.httpRequestPool.push(o)}}for(var s=0;s<i.httpRequestPool.length;s++){var o;(o=i.httpRequestPool[s]).result||o.requestState||function(t){var n={url:"//view.csslcloud.net/api/view/replay/v2/draw/range",param:{starttime:t.startTime,endtime:t.endTime,userid:t.userId,recordid:t.recordId,liveid:t.liveId}};t.httpRequest(n,function(n){var r=n.datas.meta.draw;v.log("请求流 draw["+t.key+"]",r),m.isRequestDraws?i.draws=a(i.draws,r):i.draws=i.draws.concat(r),i.draws.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)}),e(i.draws);for(var s=0;s<i.httpRequestPool.length;s++)if(i.httpRequestPool[s].key==t.key){i.httpRequestPool.splice(s,1);break}m.state.drawsAlready++,i.httpRequestStream(e)})}(o)}},this.httpRequestSnapshoot=function(i,n,r){var s=this;if(e.isDrawsAlready())v.log("画笔数据请求完整,不在请求快照数据");else{var o=e.getStates(),c=(n=n,e.getCurrentStateIndex(n)),l=o[c];if(l){var d=t.getSnapshoot(),u=d[i.docId+"_"+i.pageNum+"_"+i.url];if(l.result||u)v.log("当前时间段存在数据或存在快照",c+"");else{v.log("_snapshoot.getSnapshoot()",d),t.requestState&&t.abort();var h={url:"//view.csslcloud.net/api/view/replay/v2/draw/snapshot",param:{docid:i.docId,currentpage:i.pageNum,userid:t.userId,recordid:t.recordId}};t.httpRequest(h,function(e){if(t.setSnapshoot(i.docId+"_"+i.pageNum+"_"+i.url,e),l.result)v.log("快照请求成功,当前时间段数据存在,丢弃快照"+c);else{m.isRequestDraws=!0;var n=e.datas.meta.draw;v.log("*** 快照 callback.draws["+i.docId+"_"+i.pageNum+"_"+i.url+"] ***",n),s.draws=a(s.draws,n),s.draws.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)}),r(s.draws)}})}}}}};a.ListenerDuration=function(){if(on_cc_limit_request_draws){var e=setInterval(function(){parseInt(m.callbackPlayer.getDuration())&&(v.log("ListenerDuration"),on_cc_limit_request_draws&&on_cc_limit_request_draws(),clearInterval(e))},50);a.ListenerDuration=null}},a.on_cc_limit_request_draws=function(){if(w.drawRequestTime){v.log("分页请求画笔数据",w.drawRequestTime);var e=m.callbackPlayer.getDuration()+1;v.log("duration",e+"");var t=Math.ceil(e/w.drawRequestTime),i={blockTime:t,startTime:0,endTime:0+t};m.state.init(i),v.log("callback.state",m.state),m.drawsInfoRequestPool.httpRequestStream(function(e){m.draws=e,m.isHistoryReady=!0,m.drawPanel.isReady=!0}),setTimeout(function(){b()},1500),a.on_cc_limit_request_draws=null}},a.on_cc_request_snapshoot=function(e){if(w.drawRequestTime){v.log("pageChange",e);var t=m.callbackPlayer.getPlayerTime();m.drawsInfoRequestPool.httpRequestSnapshoot(e,t,function(e){m.draws=e,m.isHistoryReady=!0,m.drawPanel.isReady=!0})}};var p=function(e,n){d(e,function(s){var c=s.globalData;if(s.requestLoginData){var l=i.getElementById("playbackPanel");if(_.fastMode&&l){t("#documentDisplayMode").length<=0&&t("body").append("<input id='documentDisplayMode' type='hidden' value=''>"),t("#documentDisplayMode").val(c.datas.room.documentDisplayMode);var d=i.createElement("script");d.src="//image.csslcloud.net/live/1.0.4/web/js/dpc.js?v="+Math.floor(1e6*Math.random()),d.onload=function(){_.appendDrawPanel(),_.init({roomId:e.roomId,acountId:e.userId,type:2,token:c.datas.sessionId,isOpenWaterMark:parseInt(c.datas.fileProcess,10),recordId:e.recordId}),_.isDPReady=!0,a.on_hdLive_drawPanel_complete&&a.on_hdLive_drawPanel_complete()},i.body.appendChild(d)}e.chat={host:c.datas.pusherNode.primary},e.viewer.sessionId=c.datas.sessionId,e.liveId=c.datas.encryptLiveId,e.upId=c.datas.upId,e.viewerId=c.datas.viewer.id,n.socket=new o(e),t.DW.groupId=c.datas.viewer.groupId,"function"==typeof a.on_cc_callback_player&&a.on_cc_callback_player(c.datas),e.recordId||(e.recordId=c.datas.encryptRecordId),I.isH5play?H.init(e,3):"isMobile"==H.isMobile()&&H.init(e,1)}var u=c.datas.meta;if(!u)return;if(s.requestInfoData){var h=u.pageChange;if(h){for(var p=0;p<h.length;p++){var f=h[p].url,g="https:"===a.location.protocol;f.indexOf("//")>0&&g&&(f=f.replace("http:","https:"),h[p].url=f)}"function"==typeof a.on_cc_callback_pages&&a.on_cc_callback_pages(h)}var y=u.pageChange;if(y&&y.length){y.sort(function(e,t){return e.serverTime-t.serverTime}),y.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)});for(var m=y.length,v=-1,h=[],p=0;p<m;p++){var w=y[p];w.time==v?h[h.length-1]=w:h.push(w),v=w.time}n.pageChanges=h}n.pageChanges&&n.pageChanges.length&&n.drawPanel.filp(n.pageChanges[0]);var T=u.animation;T&&T.length&&(T.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)}),n.animations=T);var k=u.broadcast;if(a.chatLogs=u.broadcast,k&&k.length){k.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)});for(var p=0;p<k.length;p++){var q=k[p];"function"==typeof a.on_cc_live_broadcast_msg&&a.on_cc_live_broadcast_msg({content:q.content,time:q.time})}n.broadcasts=k}}if(s.requestChatqaData){var R=u.question;if(R&&R.length){R.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)}),n.questions=R;for(var p=0;p<n.questions.length;p++){var M=R[p];"function"==typeof a.on_cc_live_qa_question&&a.on_cc_live_qa_question({action:"question",value:{id:M.encryptId,content:M.content,groupId:M.groupId,userId:M.questionUserId,userName:M.questionUserName,userAvatar:M.questionUserAvatar,isPublish:M.isPublish}})}}var S=u.answer;if(S&&S.length){S.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)}),n.answers=S;for(var p=0;p<n.answers.length;p++){var C=S[p];"function"==typeof a.on_cc_live_qa_answer&&a.on_cc_live_qa_answer({action:"answer",value:{questionId:C.encryptId,content:C.content,userId:C.answerUserId,isPrivate:C.isPrivate,groupId:C.groupId,userName:C.answerUserName,userAvatar:C.answerUserAvatar,userRole:C.answerUserRole}})}}var E=u.chatLog;if(a.chatLogs=u.chatLog,E&&E.length){E.sort(function(e,t){return parseInt(e.time)-parseInt(t.time)});for(var p=0;p<E.length;p++){var x=E[p];"function"==typeof a.on_cc_live_chat_msg&&a.on_cc_live_chat_msg({userid:x.userId,username:x.userName,time:x.time,msg:x.content,groupId:x.groupId,chatId:x.chatId,status:x.status,useravatar:x.userAvatar,userRole:x.userRole,usercustommark:x.userCustomMark,role:x.role})}n.chatLogs=E}a.chatLogs&&a.chatLogs.length&&(a.CHATLOGS=a.chatLogs,D()),a.broadcasts&&a.broadcasts.length&&(a.BROADCASTS=a.broadcasts,P())}if(s.requestDrawData){var L=u.draw;L&&L.length&&(n.draws=L),n.isHistoryReady=!0,n.drawPanel.isReady=!0,setTimeout(function(){b()},1500)}a.on_cc_h5_player_load=function(){if(n.callbackPlayer.isReady=!0,!r){r=!0;var e=i.getElementById("drawPanel");e&&t.Callback.config({playerId:"playbackVideo"},u)}}});var r=!1},f=function(){this.cache=[],this.lastTimeRefresh=(new Date).getTime(),this.INTERVAL_TIME=setInterval(function(){m.broadcastCache&&m.broadcastCache.refresh&&m.broadcastCache.refresh()},80),this.push=function(e){this.cache.length>5e3||this.cache.push(e)},this.destroy=function(){-1!=this.INTERVAL_TIME&&clearInterval(this.INTERVAL_TIME)},this.ableRefresh=function(){var e=(new Date).getTime();return 0!=this.cache.length&&e-this.lastTimeRefresh>=80},this.refresh=function(){if(this.ableRefresh()){clearInterval(this.INTERVAL_TIME);for(var e=[],t=Math.min(this.cache.length,10),i=0;i<t;i++)e.push(this.cache.shift());"function"==typeof a.on_cc_live_broadcast_msg_sync&&a.on_cc_live_broadcast_msg_sync(e),this.lastTimeRefresh=(new Date).getTime(),this.INTERVAL_TIME=setInterval(function(){m.broadcastCache.refresh()},80)}}},g=function(){this.cache=[],this.lastTimeRefresh=(new Date).getTime(),this.INTERVAL_TIME=setInterval(function(){m.chatMessageCache.refresh()},80),this.destroy=function(){-1!=this.INTERVAL_TIME&&clearInterval(this.INTERVAL_TIME)},this.push=function(e){this.cache.length>5e3||this.cache.push(e)},this.ableRefresh=function(){var e=(new Date).getTime();return 0!=this.cache.length&&e-this.lastTimeRefresh>=80},this.refresh=function(){if(this.ableRefresh()){clearInterval(this.INTERVAL_TIME);for(var e=[],t=Math.min(this.cache.length,10),i=0;i<t;i++)e.push(this.cache.shift());"function"==typeof a.on_cc_live_chat_msg_sync&&a.on_cc_live_chat_msg_sync(e),this.lastTimeRefresh=(new Date).getTime(),this.INTERVAL_TIME=setInterval(function(){m.chatMessageCache.refresh()},80)}}},y=function(e){this.chatLogs=[],this.broadcasts=[],this.draws=[],this.pageChanges=[],this.isHistoryReady=!1,this.questions=[],this.answers=[],this.pageChanges=[],this.draws=[],this.animations=[],this.pageChangeIndex=-1,this.drawIndex=-1,this.animationIndex=-1,this.isRequestDraws=!1,this.drawPanel=new c(e,this),this.history=new p(e,this),this.chatMessageCache=new g,this.broadcastCache=new f,this.destroy=function(){this.chatLogs=[],this.broadcasts=[],this.draws=[],this.pageChanges=[],this.isHistoryReady=!1,this.questions=[],this.answers=[],this.pageChanges=[],this.draws=[],this.animations=[],this.pageChangeIndex=-1,this.drawIndex=-1,this.animationIndex=-1,this.isRequestDraws=!1,this.history=null,this.drawPanel&&(this.drawPanel.destroy(),this.drawPanel=null),this.chatMessageCache&&(this.chatMessageCache.destroy(),this.chatMessageCache=null),this.broadcastCache&&(this.broadcastCache.destroy(),this.broadcastCache=null)}},m={};a.isDebug=!1;var v={isDebug:a.isDebug,log:function(e,t){a.isDebug&&a.console&&"function"==typeof console.log&&(t?console.log(e+" => ",t):console.log(e))},isIE:function(){return navigator.userAgent.indexOf("compatible")>-1&&navigator.userAgent.indexOf("MSIE")>-1?navigator.userAgent.indexOf("MSIE 9.0")>-1||(navigator.userAgent.indexOf("MSIE 10.0"),!0):!!(navigator.userAgent.indexOf("Trident")>-1&&navigator.userAgent.indexOf("rv:11.0")>-1)},isMp4:function(e){var t=e.split("?")[0];return".mp4"===t.slice(t.length-4)}};a.TIMEOUT=5e3;var w={userId:t("#userId").val(),roomId:t("#roomId").val(),liveId:t("#liveId").val(),recordId:t("#recordId").val(),videoId:t("#videoId").val(),adapt:!1,isShowBar:0,viewerId:t("#viewerId").val(),upId:t("#upId").val(),viewer:{id:t("#viewerId").val(),name:t("#viewerName").val(),role:t("#viewerRole").val(),sessionId:t("#sessionId").val()},callbackPlayer:{id:"playbackPlayer",width:"100%",height:"100%"},drawPanel:{id:"playbackPanel",width:"100%",height:"100%"}},_={isDPReady:!1,dpc:{},fastMode:!0,init:function(e){this.dpc=new Dpc(e)},appendDrawPanel:function(){var e='<iframe id="dpa" allow-scripts allowfullscreen allowusermedia frameborder="0" style="width: 100%;height:100%;"></iframe>';"isMobile"==H.isMobile()&&(e='<iframe id="dpa" allow-scripts allowfullscreen allowusermedia frameborder="0" style="width: 100%;height:100%;pointer-events: none;"></iframe>'),t("#playbackPanel").append(e),"function"==typeof a.on_cc_live_db_flip&&a.on_cc_live_db_flip()},destroy:function(){this.clear(),this.dpc.dispose(),this.dpc.resetDpc(),t("#dpa").remove()},pageChange:function(e){this.isDPReady&&this.fastMode&&this.dpc.pageChange(e)},animationChange:function(e){this.isDPReady&&this.fastMode&&this.dpc.animationChange(e)},history:function(e){this.isDPReady&&this.fastMode&&this.dpc.history(e)},draw:function(e){this.isDPReady&&this.fastMode&&this.dpc.draw(e)},clear:function(){this.isDPReady&&this.fastMode&&this.dpc.clear()},docAdapt:function(e){if(this.isDPReady&&this.fastMode){var t=e?"1":"2";this.dpc.setDisplayMode(t)}},showMarquee:function(e){this.isDPReady&&this.fastMode&&this.dpc.openMarquee(e)},closeMarquee:function(){this.isDPReady&&this.fastMode&&this.dpc.closeMarquee()}};var I={isH5play:!0,fastMode:!0,forceNew:!1,setFastMode:function(e){"string"==typeof e.fastMode?"false"===e.fastMode?this.fastMode=!1:this.fastMode=!0:"boolean"==typeof e.fastMode?this.fastMode=e.fastMode:this.fastMode=!0},config:function(e){if(!function(){if(i.createElement("video").canPlayType){var e=i.createElement("video"),t=e.canPlayType('video/ogg; codecs="theora, vorbis"');if(t)return"probably"==t;var a=e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');return!!a&&"probably"==a}return!1}()?this.isH5play=!1:e.isH5play+""=="false"?this.isH5play=!1:this.isH5play=!0,!e.recordId)throw new Error("未传入有效的recordId");this.setFastMode(e),_.fastMode=this.fastMode;var n=["//static.csslcloud.net/js/socket.io.js","//static.csslcloud.net/js/swfobject.js","//static.csslcloud.net/js/json3.min.js","//static.csslcloud.net/js/module/drawingBoard-2.0.0.js","//static.csslcloud.net/js/module/drawingBoardPlayback.js","//static.csslcloud.net/js/report.js","//class.csslcloud.net/cctrack/ccTrack.js"];_.fastMode&&n.splice(3,2),this.loadScript(n,function(){!function(e){w.viewerId=e.viewerid,w=t.extend(w,e),m=new y(w)}(e),"isMobile"==H.isMobile()&&t.DrawingBoard&&!_.fastMode&&I.appendDrawPanel()}),"boolean"==typeof e.forceNew&&(this.forceNew=e.forceNew),setTimeout(function(){a._swfOk()},1e3)},appendDrawPanel:function(){t("#playbackPanel").append('<canvas id="drawPanel" width="1200" height="1200" style="position: absolute;z-index:2;top:0;left: 0"></canvas><iframe id="dpa" src="" frameborder="0" style="position: absolute;top:0;left: 0"></iframe>'),t("div#playbackPanel").hide()},logout:function(e){t.ajax({url:"//view.csslcloud.net/api/callback/logout",type:"GET",dataType:"jsonp",timeout:5e3,xhrFields:{withCredentials:!0},success:function(t){e&&e.success&&e.success(t)},error:function(t,a,i){e&&e.error&&e.error(t,a,i)}})},getScript:function(e,t){var a=!1,n=i.createElement("script");n.src=e,n.onload=n.onreadystatechange=function(){a||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(a=!0,t&&t())},i.body.appendChild(n)},loadScript:function(e,t){if("string"==typeof e){var a=e;(e=[]).push(a)}var i=this,n=function(e,t){i.getScript(e.shift(),function(){e.length?n(e,t):t&&t()})};n(e,t)},playbackRate:function(e){m.callbackPlayer.playbackRate(e)},seek:function(e){clearInterval(m.drawPanel.intervalNum),m.callbackPlayer.seek(e)},getPlayerTime:function(){return m.callbackPlayer.getPlayerTime()},destroy:function(){m&&(m.destroy(),m.socket&&m.socket.destroy(),m.callbackPlayer&&m.callbackPlayer.destroy()),_&&_.destroy(),function(){-1!=T&&clearInterval(T);-1!=k&&clearInterval(k)}(),e&&e(jQuery,a,i)},getDuration:function(){return I.isH5play?H.getDuration():"isMobile"==H.isMobile()?H.getDuration():m.callbackPlayer.getDuration()},docAdapt:function(e){_.fastMode&&_.docAdapt(e),w.adapt=e},isShowBar:function(e){w.isShowBar=e},getBuffer:function(){return m.callbackPlayer.getBuffer()},setVolume:function(e){return m.callbackPlayer.setVolume(e)},getVolume:function(){return m.callbackPlayer.getVolume()},play:function(){return m.callbackPlayer.play()},setZScale:function(e){return m.callbackPlayer.setZScale(e)},getZScale:function(){return m.callbackPlayer.getZScale()},setScale:function(e){return m.callbackPlayer.setScale(e)},getScale:function(){return m.callbackPlayer.getScale()},openSettingPanel:function(){return m.callbackPlayer.openSettingPanel()},getReplayPractice:function(){L.getReplayPracticeInfo({recordId:w.recordId})},clipVideoImage:function(){if(!(t("#"+playbackPlayer.id+" video").length<=0)){var e=i.createElement("canvas"),a=e.getContext("2d"),n=i.querySelector("#playbackVideo");return n?(e.width=n.videoWidth,e.height=n.videoHeight,a.drawImage(n,0,0,n.videoWidth,n.videoHeight),e.toDataURL()):""}},showMarqueeDoc:function(e){_.fastMode?_.showMarquee(e):c.showMarquee(e)},closeMarqueeDoc:function(){_.fastMode&&_.closeMarquee()},switchFullScreen:function(e){return m.callbackPlayer.switchFullScreen(e)},getLine:function(){if(I.isH5play)H.getLine();else{if("isMobile"!=H.isMobile())return;H.getLine()}},changeLine:function(e){if(I.isH5play)H.changeLine(e);else{if("isMobile"!=H.isMobile())return;H.changeLine(e)}},getQuality:function(){if(I.isH5play)H.getQuality();else{if("isMobile"!=H.isMobile())return;H.getQuality()}},changeQuality:function(e){if(I.isH5play)H.changeQuality(e);else{if("isMobile"!=H.isMobile())return;H.changeQuality(e)}},showControl:function(e){H.showControl(e)}};function b(){m.isHistoryReady?function e(){m.callbackPlayer.isReady?m.drawPanel.intervalPainting(m):setTimeout(function(){e()},500)}():setTimeout(function(){b()},300)}t.extend({DW:I}),a.on_cc_callback_player=function(e){w.videoId=e.live.encryptRecordvideoId,w.recordId=e.encryptRecordId,m.callbackPlayer=new s(w)};var T=-1,k=-1;function D(){-1!=T&&clearInterval(T),T=setInterval(function(){var e=0;try{e=parseInt(t("#playbackVideo")[0].currentTime,10)}catch(e){}if(!(e<=0)&&a.CHATLOGS.length)for(var i=a.CHATLOGS[0];i.time<=e;){var n=a.CHATLOGS.shift();if(m.chatMessageCache.push({userid:n.userId,username:n.userName,time:n.time,msg:n.content,groupId:n.groupId,useravatar:n.userAvatar,userRole:n.userRole,chatId:i.chatId,status:i.status,usercustommark:n.userCustomMark,role:n.role}),!a.CHATLOGS.length)break;i=a.CHATLOGS[0]}},1e3)}function P(){-1!=k&&clearInterval(k),k=setInterval(function(){var e=0;try{e=parseInt(t("#playbackVideo")[0].currentTime,10)}catch(e){}if(!(e<=0)&&a.BROADCASTS.length)for(var i=a.BROADCASTS[0];i.time<=e;){var n=a.BROADCASTS.shift();if(m.broadcastCache.push({content:n.content,time:n.time}),!a.BROADCASTS.length)break;i=a.BROADCASTS[0]}},1e3)}a.on_cc_live_player_init=function(){m.callbackPlayer.isReady=!0;try{m.callbackPlayer.getFlash().start()}catch(e){}(-1!=T&&clearInterval(T),-1!=k&&clearInterval(k),T=setInterval(function(){var e=0;try{e=m.callbackPlayer.getPlayerTime()}catch(e){}if(!(e<=0)&&m.chatLogs.length)for(var t=m.chatLogs[0];t.time<=e&&(t=m.chatLogs.shift(),m.chatMessageCache.push({userid:t.userId,username:t.userName,time:t.time,msg:t.content,groupId:t.groupId,chatId:t.chatId,status:t.status,useravatar:t.userAvatar,userRole:t.userRole,usercustommark:t.userCustomMark,role:t.role}),m.chatLogs.length);)t=m.chatLogs[0]},1e3),k=setInterval(function(){var e=0;try{e=m.callbackPlayer.getPlayerTime()}catch(e){}if(!(e<=0)&&m.broadcasts.length)for(var t=m.broadcasts[0];t.time<=e&&(t=m.broadcasts.shift(),m.broadcastCache.push({content:t.content,time:t.time}),m.broadcasts.length);)t=m.broadcasts[0]},1e3),"function"==typeof a.on_cc_live_player_load&&a.on_cc_live_player_load(),on_cc_limit_request_draws)&&(parseInt(m.callbackPlayer.getDuration())?on_cc_limit_request_draws&&on_cc_limit_request_draws():ListenerDuration&&ListenerDuration())},a.on_drampanel_ready=function(){m.drawPanel.isReady=!0,setTimeout(function(){b()},1500)},a.seekStart=function(){clearInterval(m.drawPanel.intervalNum)},a.seekComplete=function(){m.drawPanel.clear();var e=m.callbackPlayer.getPlayerTime();e<0&&(e=0),m.pageChangeIndex=-1,m.drawIndex=-1,m.animationIndex=-1;var t={pageChange:[],animation:[],draw:[]};if(m.pageChanges&&m.pageChanges.length>0){for(var i=0;i<m.pageChanges.length;i++){e>=(n=m.pageChanges[i]).time&&(m.pageChangeIndex=i)}if(m.pageChangeIndex>=0){var n=m.pageChanges[m.pageChangeIndex];"function"==typeof a.on_cc_callback_page_change&&a.on_cc_callback_page_change(n),"function"==typeof a.on_cc_request_snapshoot&&a.on_cc_request_snapshoot(n),_.fastMode?m.drawPanel.filp(n):m.drawPanel.filp(JSON.stringify({fileName:n.docName,totalPage:n.docTotalPage,docid:n.encryptDocId,url:n.url,page:n.pageNum,useSDK:n.useSDK})),t.pageChange.push(n)}}if(m.animations&&m.animations.length>0){for(i=0;i<m.animations.length;i++){e>=(s=m.animations[i]).time&&(m.animationIndex=i)}if(m.animationIndex>=0){var r=m.pageChangeIndex;if(r>=0){n=m.pageChanges[r];var s=m.animations[m.animationIndex];n&&s&&n.encryptDocId==s.encryptDocId&&e>=s.time&&n.time<=s.time&&(m.drawPanel.animation(JSON.stringify({fileName:s.docName,totalPage:s.docTotalPage,docid:s.encryptDocId,url:s.url,page:s.pageNum,step:s.step})),t.animation.push(s))}}}if(m.draws&&m.draws.length>0){for(i=0;i<m.draws.length;i++){(l=m.draws[i])&&e>=l.time&&(m.drawIndex=i)}var o=m.draws.slice(0,m.drawIndex+1);if(o.length>0){var c=[];for(i=0;i<o.length;i++){var l=o[i];c.push(l.data),t.draw.push(l)}m.drawPanel.draws(c)}}_.history(t),-1!=m.drawPanel.intervalNum&&clearInterval(m.drawPanel.intervalNum),m.drawPanel.intervalNum=setInterval(function(){m.drawPanel.interval()},1e3)};var q={};q.addEvents=function(e,t,a){i.addEventListener?q.addEvents=function(e,t,a){e.addEventListener(t,a,!1)}:q.addEvents=function(e,t,a){e.attachEvent("on"+t,function(){a.call(e,arguments)})},q.addEvents(e,t,a)};var R=0,M=0,S=!0,C=[],E=[],x=1,H={pauseState:!1,useHls:!1,src:"",audio:!1,line:0,quality:"",controls:!0,opts:{},init:function(e,n){var r=this;function s(e){t.ajax({url:"//view.csslcloud.net/api/record/vod",type:"GET",dataType:"json",data:{accountId:e.userId,recordId:e.recordId,terminal:n,mp4:o,token:e.viewer.sessionId},success:function(t){if(!1===t.success)I.isH5play=!1,m.callbackPlayer.flashPlayerInit();else if(t.data&&t.data.vod&&t.data.vod.video.length>0){C=t.data.vod.video;for(var i=0;i<C.length;i++){var n={quality:C[i].quality,desp:C[i].desp};E.push(n)}if(x=C[0].secure?C[0].secure.backup?2:1:C[0].backup?2:1,"function"==typeof a.HDReceivedVideoQuality&&a.HDReceivedVideoQuality(E,E[0]),"function"==typeof a.HDReceivedVideoAudioLines){var s=[];for(i=0;i<x;i++){var o="line"+i;s.push(o)}a.HDReceivedVideoAudioLines(s,0)}var c=t.data.vod.video[0];r.src=c.primary,r.quality=c.quality;var l=c.primary,d=c.secure;"https:"===a.location.protocol&&d&&(l=d.primary,r.src=d.primary),r.appendVideo(l,e)}else a.on_cc_live_player_load_fail&&a.on_cc_live_player_load_fail()}})}r.opts=e;var o=0;if(I.isH5play){if(v.log("浏览器版本是否是IE",v.isIE()),v.isIE())return o=1,this.useHls=!1,void s(e);o=0,this.useHls=!0;var c=i.createElement("script");return c.src="//static.csslcloud.net/js/hls.2.0.0.js?v="+parseInt(2e3*Math.random(),10),c.onload=function(){s(e)},void i.body.appendChild(c)}},destroy:function(){this.hls&&(this.hls.destroy(),this.hls=null),t("#playbackVideo").remove()},appendVideo:function(e,n){var s=this,o='<video id="playbackVideo" x5-video-player-type="h5-page" crossOrigin="anonymous" webkit-playsinline playsinline controls autoplay x-webkit-airplay="deny" x5-playsinline width="100%" height="100%" src="'+e+'"></video>';t("#"+playbackPlayer.id).html(o);i.getElementById(playbackPlayer.id);var c=i.getElementById("playbackVideo");r.setUrl(e),r.bindVideoEvent(c),this.useHls&&!v.isMp4(e)&&Hls.isSupported()?(s.hls=new Hls,s.hls.attachMedia(c),s.hls.on(Hls.Events.MEDIA_ATTACHED,function(){s.hls.loadSource(e)})):t("#playbackVideo").attr("src",e),n.isShowBar&&c.removeAttribute("controls");var l=0,d=1;"isMobile"==H.isMobile()&&(l=1,d=11);new ReportLog(n,l,d,c,!1);this.isAndroid()||(this.pauseState=!0),q.addEvents(c,"canplay",function(){(a.cc_loadDotPointsData(n),"isMobile"==H.isMobile()?(a.on_cc_live_player_load&&a.on_cc_live_player_load(),a.on_cc_h5_player_load&&a.on_cc_h5_player_load()):I.isH5play&&a.on_cc_live_player_init&&a.on_cc_live_player_init(),on_cc_limit_request_draws)&&(parseInt(m.callbackPlayer.getDuration())?on_cc_limit_request_draws&&on_cc_limit_request_draws():ListenerDuration&&ListenerDuration())},!1),q.addEvents(c,"playing",function(){s.pauseState=!1,a.on_player_start&&on_player_start(),a.on_spark_player_resume&&on_spark_player_resume()},!1),q.addEvents(c,"pause",function(){s.pauseState=!0,a.on_spark_player_pause&&on_spark_player_pause()},!1),q.addEvents(c,"ended",function(){a.on_spark_player_end&&on_spark_player_end()},!1),q.addEvents(c,"seeking",function(){S=!1,seekStart&&seekStart()},!1),q.addEvents(c,"seeked",function(){S=!1,seekComplete&&seekComplete()},!1)},getDuration:function(){var e=i.getElementById("playbackVideo");if(e)return Math.floor(e.duration)},getPlayerTime:function(){var e=i.getElementById("playbackVideo");if(e)return Math.floor(e.currentTime)},end:function(){t("#"+playbackPlayer.id).html("end")},appendDoc:function(e){var a='<img src="'+e+'" />';t("#"+playbackPanel.id).append(a)},isMobile:function(){if(this.isIPad()||this.isIPhone()||this.isAndroid()||this.isWindowsPhone())return"isMobile"},isIPad:function(){return null!=navigator.userAgent.match(/iPad/i)},isIPhone:function(){return null!=navigator.userAgent.match(/iPhone/i)},isAndroid:function(){return null!=navigator.userAgent.match(/Android/i)},isWindowsPhone:function(){return null!=navigator.userAgent.match(/Windows Phone/i)},showControl:function(e){this.controls=e},changeLine:function(e,t){var i=this;C.forEach(function(n,r){if(n.quality==i.quality){if(n.secure?1==e?n.secure.backup?(i.appendVideo(n.secure.backup,i.opts),i.line=1*e):(i.appendVideo(n.secure.primary,i.opts),i.line=0):(i.appendVideo(n.secure.primary,i.opts),i.line=1*e):1==e?n.backup?(i.appendVideo(n.backup,i.opts),i.line=1*e):(i.appendVideo(n.primary,i.opts),i.line=0):(i.appendVideo(n.primary,i.opts),i.line=1*e),x=n.backup?2:1,"function"==typeof a.HDReceivedVideoAudioLines){for(var s=[],o=0;o<x;o++){var c="line"+o;s.push(c)}a.HDReceivedVideoAudioLines(s,i.line)}}else"function"==typeof t&&t&&t("error")})},changeQuality:function(e,t){var i=this;C.forEach(function(n,r){if(n.quality==e){if(n.secure?1==i.line?n.secure.backup?i.appendVideo(n.secure.backup,i.opts):(i.appendVideo(n.secure.primary,i.opts),i.line=0):i.appendVideo(n.secure.primary,i.opts):1==i.line?n.backup?i.appendVideo(n.backup,i.opts):(i.appendVideo(n.primary,i.opts),i.line=0):i.appendVideo(n.primary,i.opts),x=n.backup?2:1,"function"==typeof a.HDReceivedVideoAudioLines){for(var s=[],o=0;o<x;o++){var c="line"+o;s.push(c)}a.HDReceivedVideoAudioLines(s,i.line)}"function"==typeof a.HDReceivedVideoQuality&&a.HDReceivedVideoQuality(E,E[r])}else"function"==typeof t&&t&&t("error")}),this.quality=e}},L={getReplayPracticeInfo:function(e){t.ajax({url:"//eva.csslcloud.net/api/v1/practice/replay/info",data:e,type:w.type||"GET",dataType:w.dataType||"jsonp",timeout:w.timeout||5e3,success:function(e){a.on_hdReplay_practice_info&&a.on_hdReplay_practice_info(e)},error:function(e){a.on_hdReplay_practice_info&&a.on_hdReplay_practice_info(e)}})}};a._swfOk=function(){"function"==typeof a.on_cc_swf_loading_completed&&a.on_cc_swf_loading_completed()},a.cc_loadDotPointsData=function(e){t.ajax({url:"https://view.csslcloud.net/api/replay/mark/search",type:"GET",dataType:"json",data:{replayId:e.recordId,accountId:e.userId},headers:{"X-HD-Token":e.viewer.sessionId},success:function(e){e.success&&e.data.points.length>0&&"function"==typeof a.on_cc_loadDotPointsData&&a.on_cc_loadDotPointsData(e.data.points)},error:function(){}})}}(jQuery,window,document)}]);