Java Code Examples for android.view.KeyEvent#KEYCODE_MEDIA_REWIND
The following examples show how to use
android.view.KeyEvent#KEYCODE_MEDIA_REWIND .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransportMediator.java From android-recipes-app with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: TransportMediator.java From adt-leanback-support with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: VideoPlayerActivity.java From droidkaigi2016 with Apache License 2.0 | 6 votes |
@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); }
Example 4
Source File: MusicControlNotification.java From react-native-music-control with MIT License | 6 votes |
/** * 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; }
Example 5
Source File: TransportMediator.java From guideshow with MIT License | 6 votes |
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; }
Example 6
Source File: Utils.java From Noyze with Apache License 2.0 | 6 votes |
/** * @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; }
Example 7
Source File: TransportMediator.java From V.FlyoutTest with MIT License | 6 votes |
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; }
Example 8
Source File: VideoPlayerActivity.java From droidkaigi2016 with Apache License 2.0 | 6 votes |
@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); }
Example 9
Source File: GUIListeners.java From Beats with BSD 3-Clause "New" or "Revised" License | 5 votes |
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; } }
Example 10
Source File: TabWebContentsDelegateAndroid.java From 365browser with Apache License 2.0 | 5 votes |
/** * 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 < Build.VERSION_CODES.KITKAT) 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; } }
Example 11
Source File: PlaybackControlView.java From K-Sonic with MIT License | 5 votes |
/** * 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; }
Example 12
Source File: PlaybackControlView.java From K-Sonic with MIT License | 5 votes |
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; }
Example 13
Source File: RemoteControlReceiver.java From jellyfin-androidtv with GNU General Public License v2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { //TvApp.getApplication().getLogger().Debug("****** In remote receiver. "); if ((TvApp.getApplication().getCurrentActivity() == null || !(TvApp.getApplication().getCurrentActivity() instanceof AudioNowPlayingActivity )) && MediaManager.isPlayingAudio()) { //Respond to media button presses if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); Timber.d("****** In remote receiver. Keycode: %d", event.getKeyCode()); switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: //if the current activity is null then we must not be the foreground app - process play/pause here if (TvApp.getApplication().getCurrentActivity() == null) { MediaManager.pauseAudio(); } break; case KeyEvent.KEYCODE_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: MediaManager.nextAudioItem(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_REWIND: MediaManager.prevAudioItem(); break; } abortBroadcast(); // we handled it - don't pass it on } } //Otherwise don't do anything here //We trap the keypresses in the activities because our actions are contextual //We just need this to obtain focus for all media button presses }
Example 14
Source File: Utils.java From media-button-router with Apache License 2.0 | 5 votes |
/** * Whether the keyCode represents a media button that we handle. * * @param keyCode * @return */ public static boolean isMediaButton(int keyCode) { return keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS || keyCode == KeyEvent.KEYCODE_MEDIA_REWIND || keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KEYCODE_MEDIA_PLAY || keyCode == KEYCODE_MEDIA_PAUSE || keyCode == KeyEvent.KEYCODE_HEADSETHOOK; }
Example 15
Source File: CustomizeControlView.java From bcm-android with GNU General Public License v3.0 | 5 votes |
@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; }
Example 16
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 4 votes |
@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); }
Example 17
Source File: MediaNotificationManager.java From 365browser with Apache License 2.0 | 4 votes |
@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); } }
Example 18
Source File: AudioNowPlayingActivity.java From jellyfin-androidtv with GNU General Public License v2.0 | 4 votes |
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { lastUserInteraction = System.currentTimeMillis(); switch (keyCode) { case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY: if (MediaManager.isPlayingAudio()) MediaManager.pauseAudio(); else MediaManager.resumeAudio(); if (ssActive) { stopScreenSaver(); } return true; case KeyEvent.KEYCODE_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: MediaManager.nextAudioItem(); return true; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_REWIND: MediaManager.prevAudioItem(); return true; case KeyEvent.KEYCODE_DPAD_RIGHT: if (ssActive) { MediaManager.nextAudioItem(); return true; } break; case KeyEvent.KEYCODE_DPAD_LEFT: if (ssActive) { MediaManager.prevAudioItem(); return true; } } if (ssActive) { stopScreenSaver(); return true; } return super.onKeyUp(keyCode, event); }
Example 19
Source File: VideoControlsLeanback.java From ExoMedia with Apache License 2.0 | 4 votes |
/** * 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; }
Example 20
Source File: DownloadServiceLifecycleSupport.java From Popeens-DSub with GNU General Public License v3.0 | 4 votes |
public void handleKeyEvent(KeyEvent event) { if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() > 0) { switch (event.getKeyCode()) { case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_PREVIOUS: downloadService.fastForward(); break; case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_NEXT: downloadService.rewind(); break; } } else if(event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE: downloadService.togglePlayPause(); break; case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if(lastPressTime < (System.currentTimeMillis() - 500)) { lastPressTime = System.currentTimeMillis(); downloadService.togglePlayPause(); } else { downloadService.next(false, true); } break; case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: case KeyEvent.KEYCODE_MEDIA_PREVIOUS: if(lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) { lastPressTime = System.currentTimeMillis(); downloadService.previous(); } break; case RemoteControlClient.FLAG_KEY_MEDIA_NEXT: case KeyEvent.KEYCODE_MEDIA_NEXT: if(lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) { lastPressTime = System.currentTimeMillis(); downloadService.next(); } break; case KeyEvent.KEYCODE_MEDIA_REWIND: downloadService.rewind(); break; case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: downloadService.fastForward(); break; case RemoteControlClient.FLAG_KEY_MEDIA_STOP: case KeyEvent.KEYCODE_MEDIA_STOP: downloadService.stop(); break; case RemoteControlClient.FLAG_KEY_MEDIA_PLAY: case KeyEvent.KEYCODE_MEDIA_PLAY: if(downloadService.getPlayerState() != PlayerState.STARTED) { downloadService.start(); } break; case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE: case KeyEvent.KEYCODE_MEDIA_PAUSE: downloadService.pause(); default: break; } } }