本文整理汇总了Java中android.media.AudioManager.dispatchMediaKeyEvent方法的典型用法代码示例。如果您正苦于以下问题:Java AudioManager.dispatchMediaKeyEvent方法的具体用法?Java AudioManager.dispatchMediaKeyEvent怎么用?Java AudioManager.dispatchMediaKeyEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.AudioManager
的用法示例。
在下文中一共展示了AudioManager.dispatchMediaKeyEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MediaButtonControl
import android.media.AudioManager; //导入方法依赖的package包/类
private static void MediaButtonControl(Context ctx, int Keycode) {
KeyEvent ky_down = new KeyEvent(KeyEvent.ACTION_DOWN, Keycode);
KeyEvent ky_up = new KeyEvent(KeyEvent.ACTION_UP, Keycode);
AudioManager am = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
am.dispatchMediaKeyEvent(ky_down);
am.dispatchMediaKeyEvent(ky_up);
}
示例2: handleMediaKey
import android.media.AudioManager; //导入方法依赖的package包/类
/**
* 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;
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:31,代码来源:TabWebContentsDelegateAndroid.java
示例3: sendKeyPressAudioManager
import android.media.AudioManager; //导入方法依赖的package包/类
public void sendKeyPressAudioManager(Context context, int action, int keycode) {
long uptime = SystemClock.uptimeMillis();
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.dispatchMediaKeyEvent(new KeyEvent(uptime, uptime, action, keycode, 0));
}