JW Player 播放器双击全屏

这里双击全屏仍然采用ActionScript2.0中通常的做法,即通过时间差来判断。

项目源码包下修改文件:

src\com\longtailvideo\jwplayer\view\components\DisplayComponent.as

1、增加一个计时器来监听双击:
protected var _clickTimer:Timer = new Timer(300, 1);

2、在addListeners()方法中添加监听事件:
private function addListeners():void {
     player.addEventListener(MediaEvent.JWPLAYER_MEDIA_MUTE, stateHandler);
     player.addEventListener(PlayerStateEvent.JWPLAYER_PLAYER_STATE, stateHandler);
     player.addEventListener(PlayerEvent.JWPLAYER_ERROR, errorHandler);
     player.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_ITEM, itemHandler);
     //添加双击计时探测监听
     _clickTimer.addEventListener(TimerEvent.TIMER, clickTimerHandler);
     addEventListener(MouseEvent.CLICK, clickHandler);
     this.buttonMode = true;
}

3、修改和添加相应事件:
protected function clickHandler(event:MouseEvent):void {
     if(_clickTimer.running) {
           _clickTimer.stop();
           dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_FULLSCREEN, !_player.config.fullscreen));
     } else {
           _clickTimer.start();
     }
}

protected function clickTimerHandler(event:TimerEvent):void {
     dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_CLICK));
     if(_player.config.displayclick == 'link') {
          var link:String = _player.playlist.currentItem.link;
          if(link) {
               navigateToURL(new URLRequest(Strings.cleanLink(link)),_player.config.linktarget);
          }
     } else if (currentState == PlayerState.PLAYING || currentState == PlayerState.BUFFERING) {
          dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_PAUSE));
     } else {
          dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_PLAY));
     }
}
阅读更多
文章标签: jwplayer
个人分类: jwplayer java
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭