var EnumFPlayerType={PREVIEW_PLAYER:0,PLAYBACK_PLAYER:1},BufferTimeConfig={FLUENT_BUFFER:1.6,BALANCE_BUFFER:.8,CLEAR_BUFFER:.6};function FPlayer(e,t){var n,r,i=e,s=t,a=!1,o=["ready"],u={play:"onPlay",error:"onError",pause:"onPause",idle:"onIdle",buffer:"onBuffer",ready:"onReady",walking:"onTime"};function l(e){return"fplayer"+s+"-"+e}function h(e){return l(e)+"_wrapper"}this.getStream=function(){return FPlayer.getCurrentStreamType()},EventListener.apply(this),this._on=this.on,this.on=function(e,t){var n;return u[e]&&o.indexOf(e)<0&&(n=this,o.push(e),r[u[e]]((function(t){n.trigger(e,t)}))),this._on(e,t)},n=$("#"+h(i)),this.isReady=function(){return null!==r},this.getMode=this.getType=function(){return s},this.getChannel=function(){return i},this.isPlaying=function(){if(!r)return!1;var e=r.getState();return console.dbg(e),r.getState&&"PLAYING"==r.getState()},this.isIdle=function(){return r.getState&&"IDLE"==r.getState()},this.setVolume=function(e){return r.setVolume(e)},this.isBuffering=function(){return"BUFFERING"==r.getState()},this.isPaused=function(){return"PAUSED"==r.getState()},this.load=function(e){return r.load([{file:e}]),this},this.destroy=function(){this.stop(),$("#"+h(i)).remove(),$("#"+l(i)).remove()},this.play=function(){return this.isReady()?(this.isPlaying()||(this.getType()==EnumCurState.PREVIEW&&FPlayer.setCurrentStreamType(null==FPlayer.tempStream?this.getStream():FPlayer.tempStream),r.play(),this._setVol()),this):this},this._setVol=function(){FPlayer.getMode()==EnumCurState.PLAYBACK?r.setVolume(PlayerPlayback.getVolume()):r.setVolume(PlayerPreview.getVolume())},this.pause=function(){return this.isReady()?(this.isPlaying()&&r.pause(),this):this},this.stop=function(){return this.isReady()?(r&&r.stop(),this.getType()==EnumCurState.PREVIEW&&(FPlayer.tempStream=this.getStream()),this):this},this.hide=function(){var e=$("#"+l(i));return e.css({width:"0px"}),e.css({height:"0px"}),this.trigger("hide")},this.show=function(){$("#"+l(i));return this.trigger("show")},this.seek=function(e){r.seek(e)},this.playUrl=function(e){r.playUrl(e)},this.setPosition=function(){var e;return 0==n.length?this:(e=ViewManager.getViewObject(ChannelManager.get(i).getViewId(),EnumCurState.PREVIEW).getClientArea(),$("#channelitem"+i),r?(r.setSize(e.width,e.height,e.left,0),$("#"+l(i)).css({height:e.height,width:e.width,left:e.left,top:e.top}),this):this)},this.playStream=function(e,t){console.dbg("Flash.playStream: ",t),this.getStream()!=e?(FPlayer.setCurrentStreamType(e),this.playUrl(t),this.setPosition()):this.play()},this.isExactFit=function(){return r&&r.stretching()},this.setExactFit=function(e){r.setExactFit(e),e?this.params&&(this.params.stretching="exactfit"):this.params&&(this.params.stretching="screen")},this.getPlaylist=function(){return r.getPlaylist()},this.getSafeRegion=function(){return r.getSafeRegion()},this.continuePlay=function(){return r.continuePlay()},this.setBufferTime=function(e){return r.setBufferTime(e)},this.updateEncode=function(){r.destroy(),r.continuePlay()},this.setup=function(e){var t,s=this;return 0==$("#"+h(i)).length&&0==$("#"+l(i)).length?($("#preview_plugin_container").append('
'),$("#"+l(i)).css({position:"relative","z-index":"99",height:"1200px"}),console.dbg("Flash Player: Opened Video URL ",e.url),(n=$("#"+l(i))).append(''),(t=this).params||(t.params={file:e.url,flashplayer:"swf/BcFlashPlayer.swf",fallback:"false",stretching:"exactfit",autostart:!0,rtmp:{bufferlength:t.getType()==EnumCurState.PLAYBACK?1.5:.6},skin:"swf/five.xml?timeVersion="+(new Date).getTime(),modes:"flash"}),FPlayer.setCurrentStreamType(e.stream),t.getType()==EnumCurState.PLAYBACK&&(t.params.seekTo=e.seekTo,console.dbg("Flash Player