List of usage examples for android.view KeyEvent KEYCODE_HEADSETHOOK
int KEYCODE_HEADSETHOOK
To view the source code for android.view KeyEvent KEYCODE_HEADSETHOOK.
Click Source Link
From source file:com.mobilevue.vod.VideoControllerView.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (mPlayer == null) { return true; }/* w w w . j ava 2 s . c o m*/ 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(sDefaultTimeout); if (mPauseButton != null) { mPauseButton.requestFocus(); } } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) { if (uniqueDown && !mPlayer.isPlaying()) { mPlayer.start(); updatePausePlay(); show(sDefaultTimeout); } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) { if (uniqueDown && mPlayer.isPlaying()) { mPlayer.pause(); updatePausePlay(); show(sDefaultTimeout); } return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) { // 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(sDefaultTimeout); return super.dispatchKeyEvent(event); }
From source file:CookieVideoView.java
@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();//from ww w . j av a2s.com 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); }
From source file:com.ll.myapplication.vitamio.widget.VideoView.java
@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_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 || keyCode == KeyEvent.KEYCODE_SPACE) { if (mMediaPlayer.isPlaying()) { pause();/*from w ww.j a v a 2 s.c om*/ 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); }
From source file:com.lybeat.lilyplayer.widget.media.IjkVideoView.java
@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();//from w w w .j a va 2 s .co m 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 { toggleMediaControlsVisibility(); } } return super.onKeyDown(keyCode, event); }
From source file:com.xnxs.mediaplayer.widget.media.VRVideoView.java
@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();/*from w w w. jav a 2 s. c om*/ 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); }
From source file:com.yangtsaosoftware.pebblemessenger.services.PebbleCenter.java
private void answerCall(boolean isSpeakon) { Context context = getApplicationContext(); AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // ??//from w ww. j a v a2 s . co m if (!(audioManager.isWiredHeadsetOn() || audioManager.isBluetoothA2dpOn())) { // 4.1??? 4.1??Permission Denial: not allowed to // send broadcast android.intent.action.HEADSET_PLUG from pid=1324, // uid=10017 // ??????android.permission.CALL_PRIVLEGED?????4.1??????????NULL?? Constants.log("speakerset", String.format("AudioManager before mode:%d speaker mod:%s", audioManager.getMode(), String.valueOf(audioManager.isSpeakerphoneOn()))); Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK); meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent); context.sendOrderedBroadcast(meidaButtonIntent, "android.permission.CALL_PRIVILEGED"); /*TelephonyManager telMag = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Class<TelephonyManager> c = TelephonyManager.class; Method mthAnswerCall; try { mthAnswerCall = c.getDeclaredMethod("getITelephony", (Class[]) null); mthAnswerCall.setAccessible(true); ITelephony iTel = (ITelephony) mthAnswerCall.invoke(telMag, (Object[]) null); iTel.answerRingingCall(); } catch (Exception e) { e.printStackTrace(); }*/ if (isSpeakon) { try { Thread.sleep(500); } catch (InterruptedException e) { Constants.log("speakerset", "Problem while sleeping"); } Constants.log("speakerset", "AudioManager answer mode:" + audioManager.getMode() + " speaker mod:" + String.valueOf(audioManager.isSpeakerphoneOn())); while (audioManager.getMode() != AudioManager.MODE_IN_CALL) { try { Thread.sleep(300); } catch (InterruptedException e) { Constants.log("speakerset", "Problem while sleeping"); } } // audioManager.setMicrophoneMute(true); audioManager.setSpeakerphoneOn(true); // audioManager.setMode(AudioManager.MODE_IN_CALL); Constants.log("speakerset", String.format("AudioManager set mode:%d speaker mod:%s", audioManager.getMode(), String.valueOf(audioManager.isSpeakerphoneOn()))); } } else { Constants.log("speakerset", String.format("AudioManager before mode:%d speaker mod:%s", audioManager.getMode(), String.valueOf(audioManager.isSpeakerphoneOn()))); Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK); meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent); context.sendOrderedBroadcast(meidaButtonIntent, "android.permission.CALL_PRIVILEGED"); } }
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
void onMediaButtonEvent(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.KEYCODE_HEADSETHOOK) { if (ev.getAction() == KeyEvent.ACTION_UP) { if (currentState == STATE_WAITING_INCOMING) { acceptIncomingCall();/*from ww w . j a v a 2 s .c o m*/ } else { setMicMute(!isMicMute()); for (StateListener l : stateListeners) l.onAudioSettingsChanged(); } } } }
From source file:com.rfo.basic.Run.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // The user hit a key // Log.v(LOGTAG, "onKeyDown" + keyCode); // Eat the MENU key Down event, will handle the Up event. if (keyCode == KeyEvent.KEYCODE_MENU) return true; // If event is null, we called this directly from runLoop(), // so the return value does not matter. if (event == null) return true; // Alternate: if the user program has set mBlockVolKeys, block everything but BACK // if (mBlockVolKeys && (keyCode != KeyEvent.KEYCODE_BACK)) return true; // If the user program has set mBlockVolKeys, block volume and headset keys. if (mBlockVolKeys && ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) || (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) || (keyCode == KeyEvent.KEYCODE_MUTE) || (keyCode == KeyEvent.KEYCODE_HEADSETHOOK))) { return true; }/*from w w w . java 2s .c o m*/ // Otherwise pass the KeyEvent up the chain. return super.onKeyDown(keyCode, event); }