Java Code Examples for android.view.KeyEvent#KEYCODE_MEDIA_PREVIOUS
The following examples show how to use
android.view.KeyEvent#KEYCODE_MEDIA_PREVIOUS .
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: 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 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: VolumePanel.java From Noyze with Apache License 2.0 | 6 votes |
@Override public void onClick(View v) { LOGD("VolumePanel", "onClick(" + v.getId() + ')'); Integer keyCode = null; switch (v.getId()) { case R.id.media_previous: keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS; break; case R.id.media_play_pause: keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case R.id.media_next: keyCode = KeyEvent.KEYCODE_MEDIA_NEXT; break; default: return; } onUserInteraction(); Message.obtain(mHandler, MSG_DISPATCH_KEYEVENT, keyCode, 0).sendToTarget(); }
Example 4
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 5
Source File: CustomPlayBackController.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
@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; }
Example 6
Source File: ReceiverSelector.java From media-button-router with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()) || Constants.INTENT_ACTION_VIEW_MEDIA_LIST_KEYPRESS.equals(intent.getAction())) { KeyEvent navigationKeyEvent = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); int keyCode = navigationKeyEvent.getKeyCode(); if (Utils.isMediaButton(keyCode)) { /* COMMENTED OUT FOR MARKET RELEASE Log.i(TAG, "Media Button Selector: UI is directly handling key: " + navigationKeyEvent); */ if (navigationKeyEvent.getAction() == KeyEvent.ACTION_UP) { switch (Utils.getAdjustedKeyCode(navigationKeyEvent)) { case KeyEvent.KEYCODE_MEDIA_NEXT: moveSelection(1); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: moveSelection(-1); break; case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: select(); break; case KeyEvent.KEYCODE_MEDIA_STOP: // just cancel finish(); break; default: break; } } if (isOrderedBroadcast()) { abortBroadcast(); } } } }
Example 7
Source File: MediaShortcutActivity.java From Noyze with Apache License 2.0 | 5 votes |
private int getResourceForKeyCode(final int keyCode) { switch (keyCode) { case KeyEvent.KEYCODE_MEDIA_STOP: return R.drawable.ic_media_stop; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: return R.drawable.ic_media_play2; case KeyEvent.KEYCODE_MEDIA_NEXT: return R.drawable.ic_media_ff; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: return R.drawable.ic_media_rew; } return 0; }
Example 8
Source File: ExoVideoPlaybackControlView.java From ExoVideoView with Apache License 2.0 | 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) { 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; }
Example 9
Source File: MediaButtonIntentReceiver.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
public static boolean handleIntent(final Context context, final Intent intent) { final String intentAction = intent.getAction(); if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null) { return false; } final int keycode = event.getKeyCode(); final int action = event.getAction(); String command = null; switch (keycode) { case KeyEvent.KEYCODE_MEDIA_STOP: case KeyEvent.KEYCODE_MEDIA_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: command = ReadAloudService.ActionMediaPlay; break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: command = ReadAloudService.ActionMediaPrev; break; case KeyEvent.KEYCODE_MEDIA_NEXT: command = ReadAloudService.ActionMediaNext; break; default: break; } if (command != null) { if (action == KeyEvent.ACTION_DOWN) { readAloud(context, command); return true; } } } return false; }
Example 10
Source File: AvrcpService.java From Botifier with BSD 2-Clause "Simplified" License | 5 votes |
/** * {@inheritDoc} */ @Override public void onReceive(final Context context, final Intent intent) { Log.d(TAG, "Received action " + intent.getAction()); if (intent.getAction().equals(SERVICECMD) ) { int keycode = intent.getIntExtra(SERVICECMD, 0); Log.d(TAG, "Recieved key" + keycode); switch (keycode) { case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: resetNotify(true); break; case KeyEvent.KEYCODE_MEDIA_STOP: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: case KeyEvent.KEYCODE_MEDIA_PLAY: case KeyEvent.KEYCODE_MEDIA_PAUSE: removeNotification(); break; case KeyEvent.KEYCODE_MEDIA_NEXT: showNotify(1); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: showNotify(-1); break; } } }
Example 11
Source File: CustomizeControlView.java From bcm-android with GNU General Public License v3.0 | 5 votes |
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; }
Example 12
Source File: TabWebContentsDelegateAndroid.java From delion 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 < 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; } }
Example 13
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 14
Source File: MediaSessionReceiver.java From Cheerleader with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); if (!Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { // intent wasn't a MEDIA BUTTON event. return; } KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); int keycode = event.getKeyCode(); int action = event.getAction(); // Switch on keycode and fire action only on KeyDown event. switch (keycode) { case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: case KeyEvent.KEYCODE_HEADSETHOOK: if (action == KeyEvent.ACTION_DOWN) { sendAction(context, MediaSessionWrapper.ACTION_TOGGLE_PLAYBACK); } break; case KeyEvent.KEYCODE_MEDIA_NEXT: if (action == KeyEvent.ACTION_DOWN) { sendAction(context, MediaSessionWrapper.ACTION_NEXT_TRACK); } break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: if (action == KeyEvent.ACTION_DOWN) { sendAction(context, MediaSessionWrapper.ACTION_PREVIOUS_TRACK); } break; default: break; } }
Example 15
Source File: ClementineMediaButtonEventReceiver.java From Android-Remote with GNU General Public License v3.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { // Check if we have an media button intent if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { // Get the key event and obtain a new message KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); Message msg = Message.obtain(); // Only on KeyDown if (event.getAction() == KeyEvent.ACTION_UP) { // Check which key was pressed switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: msg.obj = ClementineMessage.getMessage(MsgType.PLAYPAUSE); break; case KeyEvent.KEYCODE_MEDIA_NEXT: msg.obj = ClementineMessage.getMessage(MsgType.NEXT); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: msg.obj = ClementineMessage.getMessage(MsgType.PREVIOUS); break; case KeyEvent.KEYCODE_VOLUME_DOWN: msg.obj = ClementineMessageFactory .buildVolumeMessage(App.Clementine.getVolume() - 10); break; case KeyEvent.KEYCODE_VOLUME_UP: msg.obj = ClementineMessageFactory .buildVolumeMessage(App.Clementine.getVolume() + 10); break; default: msg = null; break; } // Now send the message if (msg != null && msg.obj != null && App.ClementineConnection != null) { App.ClementineConnection.mHandler.sendMessage(msg); } } } }
Example 16
Source File: MediaButtonReceiver.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { KeyEvent keyEvent = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (keyEvent == null) { return; } int action = keyEvent.getAction(); int keyCode = keyEvent.getKeyCode(); long eventTime = keyEvent.getEventTime(); LogUtil.d(TAG, "carlife: onReceive is triggered!"); if (action == KeyEvent.ACTION_UP) { switch (keyCode) { case KeyEvent.KEYCODE_HEADSETHOOK: break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: LogUtil.d(TAG, "KEYCODE_MEDIA_PREVIOUS"); TouchListenerManager.getInstance().sendHardKeyCodeEvent(CommonParams.KEYCODE_SEEK_SUB); break; case KeyEvent.KEYCODE_MEDIA_NEXT: LogUtil.d(TAG, "KEYCODE_MEDIA_NEXT"); TouchListenerManager.getInstance().sendHardKeyCodeEvent(CommonParams.KEYCODE_SEEK_ADD); break; default: break; } } if (isOrderedBroadcast()) { abortBroadcast(); } } }
Example 17
Source File: MusicPlayerReceiver.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { if (intent.getExtras() == null) { return; } KeyEvent keyEvent = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); if (keyEvent == null) { return; } if (keyEvent.getAction() != KeyEvent.ACTION_DOWN) return; switch (keyEvent.getKeyCode()) { case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if (MediaController.getInstance().isMessagePaused()) { MediaController.getInstance().playMessage(MediaController.getInstance().getPlayingMessageObject()); } else { MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject()); } break; case KeyEvent.KEYCODE_MEDIA_PLAY: MediaController.getInstance().playMessage(MediaController.getInstance().getPlayingMessageObject()); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject()); break; case KeyEvent.KEYCODE_MEDIA_STOP: break; case KeyEvent.KEYCODE_MEDIA_NEXT: MediaController.getInstance().playNextMessage(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: MediaController.getInstance().playPreviousMessage(); break; } } else { if (intent.getAction().equals(MusicPlayerService.NOTIFY_PLAY)) { MediaController.getInstance().playMessage(MediaController.getInstance().getPlayingMessageObject()); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_PAUSE) || intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) { MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject()); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_NEXT)) { MediaController.getInstance().playNextMessage(); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_CLOSE)) { MediaController.getInstance().cleanupPlayer(true, true); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_PREVIOUS)) { MediaController.getInstance().playPreviousMessage(); } } }
Example 18
Source File: DownloadServiceLifecycleSupport.java From Audinaut with GNU General Public License v3.0 | 4 votes |
private void handleKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() > 0) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_PREVIOUS: downloadService.fastForward(); break; case KeyEvent.KEYCODE_MEDIA_NEXT: downloadService.rewind(); break; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if (lastPressTime < (System.currentTimeMillis() - 500)) { lastPressTime = System.currentTimeMillis(); downloadService.togglePlayPause(); } else { downloadService.next(true); } break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: if (lastPressTime < (System.currentTimeMillis() - DEBOUNCE_TIME)) { lastPressTime = System.currentTimeMillis(); downloadService.previous(); } break; 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 KeyEvent.KEYCODE_MEDIA_STOP: downloadService.stop(); break; case KeyEvent.KEYCODE_MEDIA_PLAY: if (downloadService.getPlayerState() != PlayerState.STARTED) { downloadService.start(); } break; case KeyEvent.KEYCODE_MEDIA_PAUSE: downloadService.pause(); default: break; } } }
Example 19
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 20
Source File: MusicPlayerReceiver.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { if (intent.getExtras() == null) { return; } KeyEvent keyEvent = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); if (keyEvent == null) { return; } if (keyEvent.getAction() != KeyEvent.ACTION_DOWN) return; switch (keyEvent.getKeyCode()) { case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if (MediaController.getInstance().isMessagePaused()) { MediaController.getInstance().playMessage(MediaController.getInstance().getPlayingMessageObject()); } else { MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject()); } break; case KeyEvent.KEYCODE_MEDIA_PLAY: MediaController.getInstance().playMessage(MediaController.getInstance().getPlayingMessageObject()); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject()); break; case KeyEvent.KEYCODE_MEDIA_STOP: break; case KeyEvent.KEYCODE_MEDIA_NEXT: MediaController.getInstance().playNextMessage(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: MediaController.getInstance().playPreviousMessage(); break; } } else { if (intent.getAction().equals(MusicPlayerService.NOTIFY_PLAY)) { MediaController.getInstance().playMessage(MediaController.getInstance().getPlayingMessageObject()); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_PAUSE) || intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) { MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject()); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_NEXT)) { MediaController.getInstance().playNextMessage(); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_CLOSE)) { MediaController.getInstance().cleanupPlayer(true, true); } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_PREVIOUS)) { MediaController.getInstance().playPreviousMessage(); } } }