本文整理汇总了Java中android.view.KeyEvent.KEYCODE_MEDIA_REWIND属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_MEDIA_REWIND属性的具体用法?Java KeyEvent.KEYCODE_MEDIA_REWIND怎么用?Java KeyEvent.KEYCODE_MEDIA_REWIND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_MEDIA_REWIND属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchMediaKeyEvent
/**
* Called to process media key events. Any {@link KeyEvent} can be passed but only media key
* events will be handled.
*
* @param event A key event.
* @return Whether the key event was handled.
*/
public boolean dispatchMediaKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
if (player == null || !isHandledMediaKey(keyCode)) {
return false;
}
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
fastForward();
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
rewind();
} else if (event.getRepeatCount() == 0) {
if (player == null) {
return true;
}
switch (keyCode) {
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
controlDispatcher.dispatchSetPlayWhenReady(player, !player.getPlayWhenReady());
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
controlDispatcher.dispatchSetPlayWhenReady(player, true);
break;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
controlDispatcher.dispatchSetPlayWhenReady(player, false);
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
next();
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
previous();
break;
default:
break;
}
}
}
return true;
}
示例2: isHandledMediaKey
@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;
}
示例3: handleMediaKey
/**
* 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,代码行数:30,代码来源:TabWebContentsDelegateAndroid.java
示例4: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
if (mPlayer.isPlaying()) {
mPlayer.pause();
} else {
start();
}
updatePlayPause();
return true;
case KeyEvent.KEYCODE_MEDIA_PLAY:
start();
updatePlayPause();
return true;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
if (mPlayer.isPlaying()) {
mPlayer.pause();
}
updatePlayPause();
return true;
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
case KeyEvent.KEYCODE_MEDIA_NEXT:
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
case KeyEvent.KEYCODE_MEDIA_REWIND:
return true;
case KeyEvent.KEYCODE_MEDIA_STOP:
case KeyEvent.KEYCODE_BACK:
stopPlayback();
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
示例5: onReceive
@Override
public void onReceive(Context context, Intent intent) {
KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
Log.d("MediabuttonReciever " + event);
if (!Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()) || event == null || event.getAction() != KeyEvent.ACTION_DOWN) {
return;
}
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_STOP:
case KeyEvent.KEYCODE_MEDIA_PAUSE:
if (App.afspiller.getAfspillerstatus() != Status.STOPPET) {
App.afspiller.pauseAfspilning();
}
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
case KeyEvent.KEYCODE_MEDIA_REWIND:
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
if (App.afspiller.getAfspillerstatus() == Status.STOPPET) {
App.afspiller.startAfspilning();
}
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
App.afspiller.næste();
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
App.afspiller.forrige();
break;
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
default:
if (App.afspiller.getAfspillerstatus() == Status.STOPPET) {
App.afspiller.startAfspilning();
} else {
App.afspiller.pauseAfspilning();
if (App.afspiller.afspillerlyde) App.afspiller.afspillerlyd.stop.start();
}
}
}