當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.KEYCODE_MEDIA_REWIND屬性代碼示例

本文整理匯總了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;
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:44,代碼來源:PlaybackControlView.java

示例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;
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:10,代碼來源:PlaybackControlView.java

示例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);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:35,代碼來源:AudioPreview.java

示例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();
      }
  }
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:40,代碼來源:FjernbetjeningReciever.java


注:本文中的android.view.KeyEvent.KEYCODE_MEDIA_REWIND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。