private void doPauseResume() { if (mFensterPlayer.isPlaying()) { mFensterPlayer.pause(); } else { mFensterPlayer.start(); } updatePausePlay(); }
@Override public boolean dispatchKeyEvent(final KeyEvent event) { int keyCode = event.getKeyCode(); final boolean uniqueDown = event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_DOWN; if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE) { if (uniqueDown) { doPauseResume(); show(DEFAULT_TIMEOUT); if (mPauseButton != null) { mPauseButton.requestFocus(); } } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (uniqueDown && !mFensterPlayer.isPlaying()) { mFensterPlayer.start(); updatePausePlay(); show(DEFAULT_TIMEOUT); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (uniqueDown && mFensterPlayer.isPlaying()) { mFensterPlayer.pause(); updatePausePlay(); show(DEFAULT_TIMEOUT); } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE || keyCode == KeyEvent.KEYCODE_CAMERA) { // don't show the controls for volume adjustment return super.dispatchKeyEvent(event); } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { if (uniqueDown) { hide(); } return true; } show(DEFAULT_TIMEOUT); return super.dispatchKeyEvent(event); }