Java Code Examples for android.view.KeyEvent#KEYCODE_MEDIA_PLAY_PAUSE
The following examples show how to use
android.view.KeyEvent#KEYCODE_MEDIA_PLAY_PAUSE .
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 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 2
Source File: MediaController.java From video-player with MIT License | 6 votes |
@Override public boolean dispatchKeyEvent(KeyEvent event) { int keyCode = event.getKeyCode(); if (event.getRepeatCount() == 0 && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) { doPauseResume(); show(sDefaultTimeout); if (mPauseButton != null) mPauseButton.requestFocus(); return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) { if (mPlayer.isPlaying()) { mPlayer.pause(); updatePausePlay(); } return true; } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { hide(); return true; } else { show(sDefaultTimeout); } return super.dispatchKeyEvent(event); }
Example 3
Source File: MediaButtonIntentReceiver.java From HaoReader with GNU General Public License v3.0 | 6 votes |
public static boolean handleIntent(final Intent intent) { if (DEBUG) Log.d(TAG, "Received 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.ActionMediaButton; break; default: break; } if (command != null) { if (action == KeyEvent.ACTION_DOWN) { RxBus.get().post(RxBusTag.MEDIA_BUTTON, command); return true; } } } return false; }
Example 4
Source File: MainTvActivity.java From VCL-Android with Apache License 2.0 | 6 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_BUTTON_Y) && mSelectedItem instanceof MediaWrapper) { MediaWrapper media = (MediaWrapper) mSelectedItem; if (media.getType() != MediaWrapper.TYPE_DIR) return false; Intent intent = new Intent(this, DetailsActivity.class); // pass the item information intent.putExtra("media", (MediaWrapper) mSelectedItem); intent.putExtra("item", new MediaItemDetails(media.getTitle(), media.getArtist(), media.getAlbum(), media.getLocation())); startActivity(intent); return true; } return super.onKeyDown(keyCode, event); }
Example 5
Source File: IjkVideoView.java From talk-android with MIT License | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL; if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } else { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (!mMediaPlayer.isPlaying()) { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } return true; } else { toggleMediaControlsVisiblity(); } } return super.onKeyDown(keyCode, event); }
Example 6
Source File: VoIPService.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
void onMediaButtonEvent(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK || ev.getKeyCode()==KeyEvent.KEYCODE_MEDIA_PAUSE || ev.getKeyCode()==KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (ev.getAction() == KeyEvent.ACTION_UP) { if (currentState == STATE_WAITING_INCOMING) { acceptIncomingCall(); } else { setMicMute(!isMicMute()); for (StateListener l : stateListeners) l.onAudioSettingsChanged(); } } } }
Example 7
Source File: AssetVideoView.java From ResearchStack with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL; if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } else { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (!mMediaPlayer.isPlaying()) { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } return true; } else { toggleMediaControlsVisiblity(); } } return super.onKeyDown(keyCode, event); }
Example 8
Source File: IjkVideoView.java From ShareBox with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL; if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } else { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (!mMediaPlayer.isPlaying()) { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } return true; } else { toggleMediaControlsVisiblity(); } } return super.onKeyDown(keyCode, event); }
Example 9
Source File: PlaybackAndroidService.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
private void onActionMediaButton(@NonNull final Intent intent) { final KeyEvent keyEvent = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { switch (keyEvent.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_PLAY: onActionPlayPause(); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: onActionPause(); break; case KeyEvent.KEYCODE_MEDIA_NEXT: onActionNext(); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: onActionPrev(); break; case KeyEvent.KEYCODE_MEDIA_STOP: onActionStop(); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: onActionPlayPause(); break; } } }
Example 10
Source File: VideoView.java From GifAssistant with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mIsPrepared && keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL && mMediaPlayer != null && mMediaController != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } else { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP && mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } else { toggleMediaControlsVisiblity(); } } return super.onKeyDown(keyCode, event); }
Example 11
Source File: RemoteReceiver.java From vk_music_android with GNU General Public License v3.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) { final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: context.startService(new Intent(context, MusicService.class)); break; } } } }
Example 12
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 13
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 14
Source File: ActionReceiver.java From MediaNotification with Apache License 2.0 | 5 votes |
public void sendKeyPressBroadcastString(Context context, int keycode, String packageName) { Intent intent = new Intent("com.android.music.musicservicecommand"); switch (keycode) { case KeyEvent.KEYCODE_MEDIA_PREVIOUS: intent.putExtra("command", "previous"); break; case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: intent.putExtra("command", "togglepause"); break; case KeyEvent.KEYCODE_MEDIA_PAUSE: intent.putExtra("command", "pause"); break; case KeyEvent.KEYCODE_MEDIA_PLAY: intent.putExtra("command", "play"); break; case KeyEvent.KEYCODE_MEDIA_NEXT: intent.putExtra("command", "next"); break; case KeyEvent.KEYCODE_MEDIA_STOP: intent.putExtra("command", "stop"); break; default: return; } if (packageName != null) intent.setPackage(packageName); context.sendOrderedBroadcast(intent, null); }
Example 15
Source File: VoIPService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
void onMediaButtonEvent(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK || ev.getKeyCode()==KeyEvent.KEYCODE_MEDIA_PAUSE || ev.getKeyCode()==KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (ev.getAction() == KeyEvent.ACTION_UP) { if (currentState == STATE_WAITING_INCOMING) { acceptIncomingCall(); } else { setMicMute(!isMicMute()); for (StateListener l : stateListeners) l.onAudioSettingsChanged(); } } } }
Example 16
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 17
Source File: LiveTvGuideActivity.java From jellyfin-androidtv with GNU General Public License v2.0 | 4 votes |
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_MENU: // bring up filter selection showFilterOptions(); break; case KeyEvent.KEYCODE_MEDIA_PLAY: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: if ((mDetailPopup == null || !mDetailPopup.isShowing()) && (mFilterPopup == null || !mFilterPopup.isShowing()) && (mOptionsPopup == null || !mOptionsPopup.isShowing()) && mSelectedProgram != null && mSelectedProgram.getChannelId() != null) { // tune to the current channel Utils.beep(); PlaybackHelper.retrieveAndPlay(mSelectedProgram.getChannelId(), false, this); return true; } case KeyEvent.KEYCODE_DPAD_RIGHT: if (getCurrentFocus() instanceof ProgramGridCell && mSelectedProgramView != null && mSelectedProgramView.isLast() && System.currentTimeMillis() - mLastFocusChanged > 1000) { requestGuidePage(mCurrentLocalGuideEnd); } break; case KeyEvent.KEYCODE_DPAD_LEFT: if (getCurrentFocus() instanceof ProgramGridCell && mSelectedProgramView != null && mSelectedProgramView.isFirst() && TimeUtils.convertToLocalDate(mSelectedProgram.getStartDate()).getTime() > System.currentTimeMillis() && System.currentTimeMillis() - mLastFocusChanged > 1000) { focusAtEnd = true; requestGuidePage(mCurrentLocalGuideStart - (getGuideHours()*60*60000)); } break; } return super.onKeyUp(keyCode, event); }
Example 18
Source File: ContentVideoView.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_SEARCH && keyCode != KeyEvent.KEYCODE_ENDCALL; if (isInPlaybackState() && isKeyCodeSupported && mControls != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (isPlaying()) { pause(); mControls.show(); } else { start(); mControls.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (!isPlaying()) { start(); mControls.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (isPlaying()) { pause(); mControls.show(); } return true; } else { toggleMediaControlsVisiblity(); } } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { exitFullscreen(false); return true; } else if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_SEARCH) { return true; } return super.onKeyDown(keyCode, event); }
Example 19
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 20
Source File: VideoView.java From Alite with GNU General Public License v3.0 | 4 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_VOLUME_MUTE && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL; if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) { if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } else { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (!mMediaPlayer.isPlaying()) { start(); mMediaController.hide(); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (mMediaPlayer.isPlaying()) { pause(); mMediaController.show(); } return true; } else { toggleMediaControlsVisiblity(); } } return super.onKeyDown(keyCode, event); }