关闭

JW Player 播放器双击全屏

标签: jwplayer
1009人阅读 评论(0) 收藏 举报
分类:
这里双击全屏仍然采用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));
     }
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1024次
    • 积分:21
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档
    阅读排行