Java Code Examples for android.view.KeyEvent#KEYCODE_MEDIA_NEXT
The following examples show how to use
android.view.KeyEvent#KEYCODE_MEDIA_NEXT .
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 CodenameOne with GNU General Public License v2.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 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 5
Source File: HeadsetNotificationBroadcast.java From Rey-MusicPlayer with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { mApp = (Common) context.getApplicationContext(); if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { KeyEvent keyEvent = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); if (keyEvent.getAction() != KeyEvent.ACTION_DOWN) return; switch (keyEvent.getKeyCode()) { case KeyEvent.KEYCODE_HEADSETHOOK: mApp.getPlayBackStarter().playSongs(); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: mApp.getPlayBackStarter().pauseSong(); break; case KeyEvent.KEYCODE_MEDIA_PLAY: mApp.getPlayBackStarter().playSongs(); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: mApp.getPlayBackStarter().pauseSong(); break; case KeyEvent.KEYCODE_MEDIA_STOP: mApp.getPlayBackStarter().pauseSong(); break; case KeyEvent.KEYCODE_MEDIA_NEXT: mApp.getPlayBackStarter().nextSong(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: mApp.getPlayBackStarter().previousSong(); break; default: break; } } }
Example 6
Source File: MediaControlReceiver.java From IdealMedia with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null) return; if (event.getAction() != KeyEvent.ACTION_DOWN) return; switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_STOP: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY: sendMessage(context, PlayerService.PLAY); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: sendMessage(context, PlayerService.PLAY); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: sendMessage(context, PlayerService.PLAY); break; case KeyEvent.KEYCODE_MEDIA_NEXT: sendMessage(context, PlayerService.NEXT); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: sendMessage(context, PlayerService.PREV); break; case KeyEvent.KEYCODE_VOLUME_UP: sendMessage(context, PlayerService.VOLUME_UP); break; case KeyEvent.KEYCODE_VOLUME_DOWN: sendMessage(context, PlayerService.VOLUME_DOWN); break; } } }
Example 7
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 8
Source File: MediaController2KitKat.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public void sendMediaAction(int action) { if (mService == null) { Log.w(TAG, "Sending a media action on stopped controller."); return; } int keyCode; switch (action) { case ACTION_PLAY_PAUSE: keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE; break; case ACTION_STOP: keyCode = KeyEvent.KEYCODE_MEDIA_STOP; break; case ACTION_SKIP_TO_NEXT: keyCode = KeyEvent.KEYCODE_MEDIA_NEXT; break; case ACTION_SKIP_TO_PREVIOUS: keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS; break; default: throw new IllegalArgumentException(); } // TODO We should think about sending these up/down events accurately with touch up/down // on the buttons, but in the near term this will interfere with the long press behavior. RemoteController rc = mService.getRemoteController(); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode)); rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyCode)); }
Example 9
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 10
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 11
Source File: VideoPlayActivity.java From dtube-mobile-unofficial with Apache License 2.0 | 4 votes |
@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); }
Example 12
Source File: RcvMediaControl.java From freemp with Apache License 2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) { 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_STOP: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY: sendMessage(context, "play"); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: sendMessage(context, "play"); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: sendMessage(context, "play"); break; case KeyEvent.KEYCODE_MEDIA_NEXT: sendMessage(context, "next"); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: sendMessage(context, "prev"); break; case KeyEvent.KEYCODE_VOLUME_UP: sendMessage(context, "voup"); break; case KeyEvent.KEYCODE_VOLUME_DOWN: sendMessage(context, "vodn"); break; } } }
Example 13
Source File: MediaBottomReciver.java From iGap-Android with GNU Affero General Public License v3.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { if (!MusicPlayer.isMusicPlyerEnable) { return; } 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: MusicPlayer.playAndPause(); break; case KeyEvent.KEYCODE_MEDIA_PLAY: if (MusicPlayer.isPause) { MusicPlayer.playAndPause(); } break; case KeyEvent.KEYCODE_MEDIA_PAUSE: if (!MusicPlayer.isPause) { MusicPlayer.playAndPause(); } break; case KeyEvent.KEYCODE_MEDIA_STOP: MusicPlayer.stopSound(); break; case KeyEvent.KEYCODE_MEDIA_NEXT: MusicPlayer.nextMusic(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: MusicPlayer.previousMusic(); break; } } }
Example 14
Source File: MediaButtonIntentReceiver.java From MusicPlayer with GNU General Public License v3.0 | 4 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(); final long eventTime = event.getEventTime() != 0 ? event.getEventTime() : System.currentTimeMillis(); // Fallback to system time if event time was not available. String command = null; switch (keycode) { case KeyEvent.KEYCODE_MEDIA_STOP: command = MusicService.ACTION_STOP; break; case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: command = MusicService.ACTION_TOGGLE_PAUSE; break; case KeyEvent.KEYCODE_MEDIA_NEXT: command = MusicService.ACTION_SKIP; break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: command = MusicService.ACTION_REWIND; break; case KeyEvent.KEYCODE_MEDIA_PAUSE: command = MusicService.ACTION_PAUSE; break; case KeyEvent.KEYCODE_MEDIA_PLAY: command = MusicService.ACTION_PLAY; break; } if (command != null) { if (action == KeyEvent.ACTION_DOWN) { if (event.getRepeatCount() == 0) { // Only consider the first event in a sequence, not the repeat events, // so that we don't trigger in cases where the first event went to // a different app (e.g. when the user ends a phone call by // long pressing the headset button) // The service may or may not be running, but we need to send it // a command. if (keycode == KeyEvent.KEYCODE_HEADSETHOOK || keycode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (eventTime - mLastClickTime >= DOUBLE_CLICK) { mClickCounter = 0; } mClickCounter++; if (DEBUG) Log.v(TAG, "Got headset click, count = " + mClickCounter); mHandler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT); Message msg = mHandler.obtainMessage( MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context); long delay = mClickCounter < 3 ? DOUBLE_CLICK : 0; if (mClickCounter >= 3) { mClickCounter = 0; } mLastClickTime = eventTime; acquireWakeLockAndSendMessage(context, msg, delay); } else { startService(context, command); } return true; } } } } return false; }
Example 15
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 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: MediaButtonIntentReceiver.java From Muzesto with GNU General Public License v3.0 | 4 votes |
@Override public void onReceive(final Context context, final Intent intent) { final String intentAction = intent.getAction(); if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intentAction)) { if (PreferencesUtility.getInstance(context).pauseEnabledOnDetach()) startService(context, MusicService.CMDPAUSE); } else if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) { final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event == null) { return; } final int keycode = event.getKeyCode(); final int action = event.getAction(); final long eventtime = event.getEventTime(); String command = null; switch (keycode) { case KeyEvent.KEYCODE_MEDIA_STOP: command = MusicService.CMDSTOP; break; case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: command = MusicService.CMDTOGGLEPAUSE; break; case KeyEvent.KEYCODE_MEDIA_NEXT: command = MusicService.CMDNEXT; break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: command = MusicService.CMDPREVIOUS; break; case KeyEvent.KEYCODE_MEDIA_PAUSE: command = MusicService.CMDPAUSE; break; case KeyEvent.KEYCODE_MEDIA_PLAY: command = MusicService.CMDPLAY; break; } if (command != null) { if (action == KeyEvent.ACTION_DOWN) { if (mDown) { if (MusicService.CMDTOGGLEPAUSE.equals(command) || MusicService.CMDPLAY.equals(command)) { if (mLastClickTime != 0 && eventtime - mLastClickTime > LONG_PRESS_DELAY) { acquireWakeLockAndSendMessage(context, mHandler.obtainMessage(MSG_LONGPRESS_TIMEOUT, context), 0); } } } else if (event.getRepeatCount() == 0) { if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) { if (eventtime - mLastClickTime >= DOUBLE_CLICK) { mClickCounter = 0; } mClickCounter++; if (DEBUG) Log.v(TAG, "Got headset click, count = " + mClickCounter); mHandler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT); Message msg = mHandler.obtainMessage( MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context); long delay = mClickCounter < 3 ? DOUBLE_CLICK : 0; if (mClickCounter >= 3) { mClickCounter = 0; } mLastClickTime = eventtime; acquireWakeLockAndSendMessage(context, msg, delay); } else { startService(context, command); } mLaunched = false; mDown = true; } } else { mHandler.removeMessages(MSG_LONGPRESS_TIMEOUT); mDown = false; } if (isOrderedBroadcast()) { abortBroadcast(); } releaseWakeLockIfHandlerIdle(); } } }
Example 18
Source File: MediaButtonIntentReceiver.java From Orin with GNU General Public License v3.0 | 4 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(); final long eventTime = event.getEventTime(); String command = null; switch (keycode) { case KeyEvent.KEYCODE_MEDIA_STOP: command = MusicService.ACTION_STOP; break; case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: command = MusicService.ACTION_TOGGLE_PAUSE; break; case KeyEvent.KEYCODE_MEDIA_NEXT: command = MusicService.ACTION_SKIP; break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: command = MusicService.ACTION_REWIND; break; case KeyEvent.KEYCODE_MEDIA_PAUSE: command = MusicService.ACTION_PAUSE; break; case KeyEvent.KEYCODE_MEDIA_PLAY: command = MusicService.ACTION_PLAY; break; } if (command != null) { if (action == KeyEvent.ACTION_DOWN) { if (event.getRepeatCount() == 0) { // Only consider the first event in a sequence, not the repeat events, // so that we don't trigger in cases where the first event went to // a different app (e.g. when the user ends a phone call by // long pressing the headset button) // The service may or may not be running, but we need to send it // a command. if (keycode == KeyEvent.KEYCODE_HEADSETHOOK) { if (eventTime - mLastClickTime >= DOUBLE_CLICK) { mClickCounter = 0; } mClickCounter++; if (DEBUG) Log.v(TAG, "Got headset click, count = " + mClickCounter); mHandler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT); Message msg = mHandler.obtainMessage( MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context); long delay = mClickCounter < 3 ? DOUBLE_CLICK : 0; if (mClickCounter >= 3) { mClickCounter = 0; } mLastClickTime = eventTime; acquireWakeLockAndSendMessage(context, msg, delay); } else { startService(context, command); } return true; } } } } return false; }
Example 19
Source File: AudioStreamingReceiver.java From DMAudioStreamer with Apache License 2.0 | 4 votes |
@Override public void onReceive(Context context, Intent intent) { this.audioStreamingManager = AudioStreamingManager.getInstance(context); if(this.audioStreamingManager ==null){ return; } 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 (this.audioStreamingManager .isPlaying()) { this.audioStreamingManager .onPause(); } else { this.audioStreamingManager .onPlay(this.audioStreamingManager .getCurrentAudio()); } break; case KeyEvent.KEYCODE_MEDIA_PLAY: this.audioStreamingManager .onPlay(this.audioStreamingManager .getCurrentAudio()); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: this.audioStreamingManager .onPause(); break; case KeyEvent.KEYCODE_MEDIA_STOP: break; case KeyEvent.KEYCODE_MEDIA_NEXT: this.audioStreamingManager .onSkipToNext(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: this.audioStreamingManager .onSkipToPrevious(); break; } } else { this.audioStreamingManager = AudioStreamingManager.getInstance(context); if (intent.getAction().equals(AudioStreamingService.NOTIFY_PLAY)) { this.audioStreamingManager.onPlay(this.audioStreamingManager.getCurrentAudio()); } else if (intent.getAction().equals(AudioStreamingService.NOTIFY_PAUSE) || intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) { this.audioStreamingManager.onPause(); } else if (intent.getAction().equals(AudioStreamingService.NOTIFY_NEXT)) { this.audioStreamingManager.onSkipToNext(); } else if (intent.getAction().equals(AudioStreamingService.NOTIFY_CLOSE)) { this.audioStreamingManager.cleanupPlayer(context, true, true); } else if (intent.getAction().equals(AudioStreamingService.NOTIFY_PREVIOUS)) { this.audioStreamingManager.onSkipToPrevious(); } } }
Example 20
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(); } } }