예제 #1
0
파일: VideoView.java 프로젝트: avenwu/vplus
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported =
        keyCode != KeyEvent.KEYCODE_BACK
            && keyCode != KeyEvent.KEYCODE_VOLUME_UP
            && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN
            && keyCode != KeyEvent.KEYCODE_MENU
            && keyCode != KeyEvent.KEYCODE_CALL
            && keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
      if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
          || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
          || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (mMediaPlayer.isPlaying()) {
          pause();
          mMediaController.show();
        } else {
          start();
          mMediaController.hide();
        }
        return true;
      } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP && mMediaPlayer.isPlaying()) {
        pause();
        mMediaController.show();
      } else {
        toggleMediaControlsVisiblity();
      }
    }

    return super.onKeyDown(keyCode, event);
  }
예제 #2
0
파일: VideoView.java 프로젝트: avenwu/vplus
 @Override
 public void pause() {
   if (isInPlaybackState()) {
     if (mMediaPlayer.isPlaying()) {
       mMediaPlayer.pause();
       mCurrentState = STATE_PAUSED;
     }
   }
   mTargetState = STATE_PAUSED;
 }
예제 #3
0
파일: VideoView.java 프로젝트: avenwu/vplus
 @Override
 public boolean isPlaying() {
   return isInPlaybackState() && mMediaPlayer.isPlaying();
 }