android.view.KeyEvent#KEYCODE_MEDIA_FAST_FORWARD源码实例Demo

下面列出了android.view.KeyEvent#KEYCODE_MEDIA_FAST_FORWARD 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CodenameOne   文件: TransportMediator.java

static boolean isMediaKey(int keyCode) {
    switch (keyCode) {
        case KEYCODE_MEDIA_PLAY:
        case KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MUTE:
        case KeyEvent.KEYCODE_HEADSETHOOK:
        case KeyEvent.KEYCODE_MEDIA_STOP:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KEYCODE_MEDIA_RECORD:
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: {
            return true;
        }
    }
    return false;
}
 

static boolean isMediaKey(int keyCode) {
    switch (keyCode) {
        case KEYCODE_MEDIA_PLAY:
        case KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MUTE:
        case KeyEvent.KEYCODE_HEADSETHOOK:
        case KeyEvent.KEYCODE_MEDIA_STOP:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KEYCODE_MEDIA_RECORD:
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: {
            return true;
        }
    }
    return false;
}
 
源代码3 项目: Noyze   文件: Utils.java

/**
 * @return True if a {@link android.view.KeyEvent} corresponds to a media action.
 */
public static boolean isMediaKeyCode(final int keyCode) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY:
        case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_CLOSE:
        case KeyEvent.KEYCODE_MEDIA_EJECT:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        case KeyEvent.KEYCODE_MEDIA_STOP:
        case KeyEvent.KEYCODE_MEDIA_RECORD:
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            return true;
    }

    return false;
}
 
源代码4 项目: V.FlyoutTest   文件: TransportMediator.java

static boolean isMediaKey(int keyCode) {
    switch (keyCode) {
        case KEYCODE_MEDIA_PLAY:
        case KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MUTE:
        case KeyEvent.KEYCODE_HEADSETHOOK:
        case KeyEvent.KEYCODE_MEDIA_STOP:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KEYCODE_MEDIA_RECORD:
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: {
            return true;
        }
    }
    return false;
}
 

static boolean isMediaKey(int keyCode) {
    switch (keyCode) {
        case KEYCODE_MEDIA_PLAY:
        case KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MUTE:
        case KeyEvent.KEYCODE_HEADSETHOOK:
        case KeyEvent.KEYCODE_MEDIA_STOP:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KEYCODE_MEDIA_RECORD:
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: {
            return true;
        }
    }
    return false;
}
 

/**
 * Code taken from newer version of the support library located in PlaybackStateCompat.toKeyCode
 * Replace this to PlaybackStateCompat.toKeyCode when React Native updates the support library
 */
private int toKeyCode(long action) {
    if (action == PlaybackStateCompat.ACTION_PLAY) {
        return KeyEvent.KEYCODE_MEDIA_PLAY;
    } else if (action == PlaybackStateCompat.ACTION_PAUSE) {
        return KeyEvent.KEYCODE_MEDIA_PAUSE;
    } else if (action == PlaybackStateCompat.ACTION_SKIP_TO_NEXT) {
        return KeyEvent.KEYCODE_MEDIA_NEXT;
    } else if (action == PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) {
        return KeyEvent.KEYCODE_MEDIA_PREVIOUS;
    } else if (action == PlaybackStateCompat.ACTION_STOP) {
        return KeyEvent.KEYCODE_MEDIA_STOP;
    } else if (action == PlaybackStateCompat.ACTION_FAST_FORWARD) {
        return KeyEvent.KEYCODE_MEDIA_FAST_FORWARD;
    } else if (action == PlaybackStateCompat.ACTION_REWIND) {
        return KeyEvent.KEYCODE_MEDIA_REWIND;
    } else if (action == PlaybackStateCompat.ACTION_PLAY_PAUSE) {
        return KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE;
    }
    return KeyEvent.KEYCODE_UNKNOWN;
}
 

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (playerControl.canSeekForward() && (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
            || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            playerControl.seekTo(playerControl.getCurrentPosition() + 15000); // milliseconds
            show();
        }
        return true;
    } else if (playerControl.canSeekBackward() && (keyCode == KeyEvent.KEYCODE_MEDIA_REWIND
            || keyCode == KeyEvent.KEYCODE_DPAD_LEFT)) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            playerControl.seekTo(playerControl.getCurrentPosition() - 5000); // milliseconds
            show();
        }
        return true;
    }
    return super.dispatchKeyEvent(event);
}
 

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (playerControl.canSeekForward() && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            playerControl.seekTo(playerControl.getCurrentPosition() + 15000); // milliseconds
            show();
        }
        return true;
    } else if (playerControl.canSeekBackward() && keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            playerControl.seekTo(playerControl.getCurrentPosition() - 5000); // milliseconds
            show();
        }
        return true;
    }
    return super.dispatchKeyEvent(event);
}
 

public boolean dispatchMediaKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (player == null || !isHandledMediaKey(keyCode)) {
        return false;
    }
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
            fastForward();
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
            rewind();
        } else if (event.getRepeatCount() == 0) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                    controlDispatcher.dispatchSetPlayWhenReady(player, !player.getPlayWhenReady());
                    break;
                case KeyEvent.KEYCODE_MEDIA_PLAY:
                    controlDispatcher.dispatchSetPlayWhenReady(player, true);
                    break;
                case KeyEvent.KEYCODE_MEDIA_PAUSE:
                    controlDispatcher.dispatchSetPlayWhenReady(player, false);
                    break;
                case KeyEvent.KEYCODE_MEDIA_NEXT:
                    next();
                    break;
                case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                    previous();
                    break;
                default:
                    break;
            }
        }
    }
    return true;
}
 
源代码10 项目: bcm-android   文件: CustomizeControlView.java

@SuppressLint("InlinedApi")
private static boolean isHandledMediaKey(int keyCode) {
    return keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
            || keyCode == KeyEvent.KEYCODE_MEDIA_REWIND
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE
            || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT
            || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS;
}
 

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (player == null || event.getAction() != KeyEvent.ACTION_DOWN) {
        return super.dispatchKeyEvent(event);
    }
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            fastForward();
            break;
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KeyEvent.KEYCODE_DPAD_LEFT:
            rewind();
            break;
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            player.setPlayWhenReady(!player.getPlayWhenReady());
            break;
        case KeyEvent.KEYCODE_MEDIA_PLAY:
            player.setPlayWhenReady(true);
            break;
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
            player.setPlayWhenReady(false);
            break;
        case KeyEvent.KEYCODE_MEDIA_NEXT:
            next();
            break;
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
            previous();
            break;
        default:
            return false;
    }
    show();
    return true;
}
 

public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (getReactNativeHost().hasInstance()
    && getReactNativeHost().getUseDeveloperSupport()
    && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
    event.startTracking();
    return true;
  }
  return false;
}
 

@SuppressLint("InlinedApi")
private static boolean isHandledMediaKey(int keyCode) {
    return keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
            || keyCode == KeyEvent.KEYCODE_MEDIA_REWIND
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE
            || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT
            || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS;
}
 

/**
 * Redispatches unhandled media keys. This allows bluetooth headphones with play/pause or
 * other buttons to function correctly.
 */
@TargetApi(19)
private void handleMediaKey(KeyEvent e) {
    if (Build.VERSION.SDK_INT < 19) return;
    switch (e.getKeyCode()) {
        case KeyEvent.KEYCODE_MUTE:
        case KeyEvent.KEYCODE_HEADSETHOOK:
        case KeyEvent.KEYCODE_MEDIA_PLAY:
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_STOP:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        case KeyEvent.KEYCODE_MEDIA_REWIND:
        case KeyEvent.KEYCODE_MEDIA_RECORD:
        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
        case KeyEvent.KEYCODE_MEDIA_CLOSE:
        case KeyEvent.KEYCODE_MEDIA_EJECT:
        case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
            AudioManager am = (AudioManager) mTab.getApplicationContext().getSystemService(
                    Context.AUDIO_SERVICE);
            am.dispatchMediaKeyEvent(e);
            break;
        default:
            break;
    }
}
 
源代码15 项目: Beats   文件: GUIListeners.java

static public int keyCode2Direction(int keyCode) {
	/* interprets a keyCode as a direction
	 * input:   keyCode  - a key code passed to handler           
	 * output: [0 1 2 3] -> [left down up right]; -1 -> unknown
	 */
	switch (keyCode) {
	// WASD, ZX-NM spread, AS-KL spread
	// 12-90 spread, D-Pad
	// Headphone music controller
	case KeyEvent.KEYCODE_A: case KeyEvent.KEYCODE_Z:
	case KeyEvent.KEYCODE_1: case KeyEvent.KEYCODE_DPAD_LEFT:
	case KeyEvent.KEYCODE_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_REWIND:
	case KeyEvent.KEYCODE_BUTTON_X:
		return 0;
	case KeyEvent.KEYCODE_S: case KeyEvent.KEYCODE_X:
	case KeyEvent.KEYCODE_2: case KeyEvent.KEYCODE_DPAD_DOWN:
	case KeyEvent.KEYCODE_MEDIA_STOP:
	case KeyEvent.KEYCODE_BUTTON_A:
		return 1;
	case KeyEvent.KEYCODE_W: case KeyEvent.KEYCODE_N: case KeyEvent.KEYCODE_K:
	case KeyEvent.KEYCODE_9: case KeyEvent.KEYCODE_DPAD_UP:
	case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
	case KeyEvent.KEYCODE_BUTTON_Y:
		return 2;
	case KeyEvent.KEYCODE_D: case KeyEvent.KEYCODE_M: case KeyEvent.KEYCODE_L:
	case KeyEvent.KEYCODE_0: case KeyEvent.KEYCODE_DPAD_RIGHT:
	case KeyEvent.KEYCODE_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
	case KeyEvent.KEYCODE_BUTTON_B:
		return 3;
	default:
		return -1;
	}
}
 
源代码16 项目: K-Sonic   文件: PlaybackControlView.java

/**
 * Called to process media key events. Any {@link KeyEvent} can be passed but only media key
 * events will be handled.
 *
 * @param event A key event.
 * @return Whether the key event was handled.
 */
public boolean dispatchMediaKeyEvent(KeyEvent event) {
  int keyCode = event.getKeyCode();
  if (player == null || !isHandledMediaKey(keyCode)) {
    return false;
  }
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
        fastForward();
        break;
      case KeyEvent.KEYCODE_MEDIA_REWIND:
        rewind();
        break;
      case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        player.setPlayWhenReady(!player.getPlayWhenReady());
        break;
      case KeyEvent.KEYCODE_MEDIA_PLAY:
        player.setPlayWhenReady(true);
        break;
      case KeyEvent.KEYCODE_MEDIA_PAUSE:
        player.setPlayWhenReady(false);
        break;
      case KeyEvent.KEYCODE_MEDIA_NEXT:
        next();
        break;
      case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        previous();
        break;
      default:
        break;
    }
  }
  show();
  return true;
}
 

@VisibleForTesting
void processAction(Intent intent, MediaNotificationManager manager) {
    String action = intent.getAction();

    // Before Android L, instead of using the MediaSession callback, the system will fire
    // ACTION_MEDIA_BUTTON intents which stores the information about the key event.
    if (Intent.ACTION_MEDIA_BUTTON.equals(action)) {
        KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
        if (event == null) return;
        if (event.getAction() != KeyEvent.ACTION_DOWN) return;

        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_MEDIA_PLAY:
                manager.onPlay(
                        MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
                break;
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
                manager.onPause(
                        MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
                break;
            case KeyEvent.KEYCODE_HEADSETHOOK:
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                if (manager.mMediaNotificationInfo.isPaused) {
                    manager.onPlay(MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
                } else {
                    manager.onPause(
                            MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
                }
                break;
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                manager.onMediaSessionAction(MediaSessionAction.PREVIOUS_TRACK);
                break;
            case KeyEvent.KEYCODE_MEDIA_NEXT:
                manager.onMediaSessionAction(MediaSessionAction.NEXT_TRACK);
                break;
            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
                manager.onMediaSessionAction(MediaSessionAction.SEEK_FORWARD);
                break;
            case KeyEvent.KEYCODE_MEDIA_REWIND:
                manager.onMediaSessionAction(MediaSessionAction.SEEK_BACKWARD);
                break;
            default:
                break;
        }
    } else if (ACTION_STOP.equals(action)
            || ACTION_SWIPE.equals(action)
            || ACTION_CANCEL.equals(action)) {
        manager.onStop(
                MediaNotificationListener.ACTION_SOURCE_MEDIA_NOTIFICATION);
        stopListenerService();
    } else if (ACTION_PLAY.equals(action)) {
        manager.onPlay(MediaNotificationListener.ACTION_SOURCE_MEDIA_NOTIFICATION);
    } else if (ACTION_PAUSE.equals(action)) {
        manager.onPause(MediaNotificationListener.ACTION_SOURCE_MEDIA_NOTIFICATION);
    } else if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(action)) {
        manager.onPause(MediaNotificationListener.ACTION_SOURCE_HEADSET_UNPLUG);
    } else if (ACTION_PREVIOUS_TRACK.equals(action)) {
        manager.onMediaSessionAction(MediaSessionAction.PREVIOUS_TRACK);
    } else if (ACTION_NEXT_TRACK.equals(action)) {
        manager.onMediaSessionAction(MediaSessionAction.NEXT_TRACK);
    } else if (ACTION_SEEK_FORWARD.equals(action)) {
        manager.onMediaSessionAction(MediaSessionAction.SEEK_FORWARD);
    } else if (ACTION_SEEK_BACKWARD.equals(action)) {
        manager.onMediaSessionAction(MediaSessionAction.SEEK_BACKWARD);
    }
}
 
源代码18 项目: ExoMedia   文件: VideoControlsLeanback.java

/**
 * NOTE: the view is not always the currently focused view, thus the
 * {@link #currentFocus} variable
 */
@Override
public boolean onKey(View view, int keyCode, KeyEvent event) {
    if (event.getAction() != KeyEvent.ACTION_DOWN) {
        return false;
    }

    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            if (isVisible && canViewHide && !isLoading) {
                hide();
                return true;
            } else if (controlsParent.getAnimation() != null) {
                //This occurs if we are animating the hide or show of the controls
                return true;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_UP:
            showTemporary();
            return true;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            hide();
            return true;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            showTemporary();
            focusPrevious(currentFocus);
            return true;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            showTemporary();
            focusNext(currentFocus);
            return true;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            showTemporary();
            currentFocus.callOnClick();
            return true;

        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            onPlayPauseClick();
            return true;

        case KeyEvent.KEYCODE_MEDIA_PLAY:
            if (videoView != null && !videoView.isPlaying()) {
                videoView.start();
                return true;
            }
            break;

        case KeyEvent.KEYCODE_MEDIA_PAUSE:
            if (videoView != null && videoView.isPlaying()) {
                videoView.pause();
                return true;
            }
            break;

        case KeyEvent.KEYCODE_MEDIA_NEXT:
            onNextClick();
            return true;

        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
            onPreviousClick();
            return true;

        case KeyEvent.KEYCODE_MEDIA_REWIND:
            onRewindClick();
            return true;

        case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            onFastForwardClick();
            return true;
    }

    return false;
}
 

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        Log.d("dtube","Key event "+event.getKeyCode()+"VS"+KeyEvent.KEYCODE_MEDIA_REWIND);
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_ENTER:
            case KeyEvent.KEYCODE_DPAD_CENTER:
                if (getCurrentFocus() != null && getCurrentFocus() instanceof  ViewGroup) {
                    //Open a dialog for options on a comment
                    if (getCurrentFocus().getId() == R.id.comments_lv) {

                        final View commentView = commentsListView.getSelectedView();
                        final AlertDialog.Builder builderSingle = new AlertDialog.Builder(VideoPlayActivity.this);

                        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(VideoPlayActivity.this, android.R.layout.select_dialog_item);
                        arrayAdapter.add(getResources().getString(R.string.like_comment));
                        arrayAdapter.add(getResources().getString(R.string.dislike_comment));

                        builderSingle.setNegativeButton("cancel", null);

                        builderSingle.setAdapter(arrayAdapter, (dialog, which) -> {
                            switch (which) {
                                case 0:
                                commentView.findViewById(R.id.comment_like).performClick();
                                break;

                                case 1:
                                    commentView.findViewById(R.id.comment_dislike).performClick();
                                    break;

                                case 2:
                                    commentView.findViewById(R.id.comment_reply).performClick();
                                    break;
                            }
                        });

                        //dialog display is delayed to prevent misfocus
                        commentView.postDelayed(builderSingle::show,10);

                        Log.d("dtube", "dispatch" + ((ViewGroup) getCurrentFocus()).getChildAt(0).getId() + "VS" + R.id.comment_item);
                    }else if (getCurrentFocus().getId() == R.id.suggestions_lv) {
                        //select the suggested video
                        onItemClick(suggestedVideosListView.getSelectedItemPosition());
                    }
                }
                break;
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                wakeMediaControls();
                MediaPlayerSingleton.getInstance(this).togglePlayPause();
                break;

            case KeyEvent.KEYCODE_MEDIA_REWIND:
            case KeyEvent.KEYCODE_MEDIA_STEP_BACKWARD:
            case KeyEvent.KEYCODE_MEDIA_SKIP_BACKWARD:
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                wakeMediaControls();
                MediaPlayerSingleton.getInstance(this).rewind();
                break;

            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            case KeyEvent.KEYCODE_MEDIA_SKIP_FORWARD:
            case KeyEvent.KEYCODE_MEDIA_STEP_FORWARD:
            case KeyEvent.KEYCODE_MEDIA_NEXT:
                wakeMediaControls();
                MediaPlayerSingleton.getInstance(this).fastForward();
                break;

        }
    }
    return super.dispatchKeyEvent(event);
}
 
源代码20 项目: VCL-Android   文件: VideoPlayerActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B)
        return super.onKeyDown(keyCode, event);
    if (mIsLoading) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_S:
            case KeyEvent.KEYCODE_MEDIA_STOP:
                exitOK();
                return true;
        }
        return false;
    }
    showOverlayTimeout(OVERLAY_TIMEOUT);
    switch (keyCode) {
    case KeyEvent.KEYCODE_F:
    case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
    case KeyEvent.KEYCODE_MEDIA_NEXT:
        seekDelta(10000);
        return true;
    case KeyEvent.KEYCODE_R:
    case KeyEvent.KEYCODE_MEDIA_REWIND:
    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        seekDelta(-10000);
        return true;
    case KeyEvent.KEYCODE_BUTTON_R1:
        seekDelta(60000);
        return true;
    case KeyEvent.KEYCODE_BUTTON_L1:
        seekDelta(-60000);
        return true;
    case KeyEvent.KEYCODE_BUTTON_A:
        if (mOverlayProgress.getVisibility() == View.VISIBLE)
            return false;
    case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
    case KeyEvent.KEYCODE_MEDIA_PLAY:
    case KeyEvent.KEYCODE_MEDIA_PAUSE:
    case KeyEvent.KEYCODE_SPACE:
        if (mIsNavMenu)
            return navigateDvdMenu(keyCode);
        else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) //prevent conflict with remote control
            return super.onKeyDown(keyCode, event);
        else
            doPlayPause();
        return true;
    case KeyEvent.KEYCODE_O:
    case KeyEvent.KEYCODE_BUTTON_Y:
    case KeyEvent.KEYCODE_MENU:
        showAdvancedOptions(mAdvOptions);
        return true;
    case KeyEvent.KEYCODE_V:
    case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
    case KeyEvent.KEYCODE_BUTTON_X:
        onAudioSubClick(mTracks);
        return true;
    case KeyEvent.KEYCODE_N:
        showNavMenu();
        return true;
    case KeyEvent.KEYCODE_A:
        resizeVideo();
        return true;
    case KeyEvent.KEYCODE_M:
    case KeyEvent.KEYCODE_VOLUME_MUTE:
        updateMute();
        return true;
    case KeyEvent.KEYCODE_S:
    case KeyEvent.KEYCODE_MEDIA_STOP:
        exitOK();
        return true;
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
        if (mIsNavMenu)
            return navigateDvdMenu(keyCode);
        else
            return super.onKeyDown(keyCode, event);
    case KeyEvent.KEYCODE_J:
        delayAudio(-50000l);
        return true;
    case KeyEvent.KEYCODE_K:
        delayAudio(50000l);
        return true;
    case KeyEvent.KEYCODE_G:
        delaySubs(-50000l);
        return true;
    case KeyEvent.KEYCODE_H:
        delaySubs(50000l);
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (mMute) {
            updateMute();
            return true;
        } else
            return false;
    }
    return super.onKeyDown(keyCode, event);
}
 
 方法所在类
 同类方法