本文整理匯總了Java中android.media.session.PlaybackState.STATE_REWINDING屬性的典型用法代碼示例。如果您正苦於以下問題:Java PlaybackState.STATE_REWINDING屬性的具體用法?Java PlaybackState.STATE_REWINDING怎麽用?Java PlaybackState.STATE_REWINDING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.media.session.PlaybackState
的用法示例。
在下文中一共展示了PlaybackState.STATE_REWINDING屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: play
/**
* Resumes playback.
*/
public void play() throws IllegalStateException {
if (DEBUG) Log.d(TAG, "play()");
if (!isPlaybackPrepared()) {
throw new IllegalStateException("Recorded program not set or video not ready yet");
}
switch (mPlaybackState) {
case PlaybackState.STATE_FAST_FORWARDING:
case PlaybackState.STATE_REWINDING:
setPlaybackSpeed(1);
break;
default:
mTvView.timeShiftResume();
}
mPlaybackState = PlaybackState.STATE_PLAYING;
mCallback.onPlaybackStateChanged(mPlaybackState, 1);
}
示例2: pause
/**
* Pauses playback.
*/
public void pause() throws IllegalStateException {
if (DEBUG) Log.d(TAG, "pause()");
if (!isPlaybackPrepared()) {
throw new IllegalStateException("Recorded program not set or playback not started yet");
}
switch (mPlaybackState) {
case PlaybackState.STATE_FAST_FORWARDING:
case PlaybackState.STATE_REWINDING:
setPlaybackSpeed(1);
// falls through
case PlaybackState.STATE_PLAYING:
mTvView.timeShiftPause();
mPlaybackState = PlaybackState.STATE_PAUSED;
break;
default:
break;
}
mCallback.onPlaybackStateChanged(mPlaybackState, 1);
}
示例3: rewind
/**
* Rewinds playback with the given speed. If the given speed is larger than
* {@value #MAX_REWIND_SPEED}, uses {@value #MAX_REWIND_SPEED}.
*/
public void rewind(int speed) throws IllegalStateException {
if (DEBUG) Log.d(TAG, "rewind()");
if (!isPlaybackPrepared()) {
throw new IllegalStateException("Recorded program not set or playback not started yet");
}
if (speed <= 0) {
throw new IllegalArgumentException("Speed cannot be negative or 0");
}
if (mTimeShiftCurrentPositionMs <= REWIND_POSITION_MARGIN_MS) {
return;
}
speed = Math.min(speed, MAX_REWIND_SPEED);
if (DEBUG) Log.d(TAG, "Let's play with speed: " + speed);
setPlaybackSpeed(-speed);
mPlaybackState = PlaybackState.STATE_REWINDING;
mCallback.onPlaybackStateChanged(mPlaybackState, speed);
}
示例4: seekTo
/**
* Seeks playback to the specified position.
*/
public void seekTo(long positionMs) throws IllegalStateException {
if (DEBUG) Log.d(TAG, "seekTo()");
if (!isPlaybackPrepared()) {
throw new IllegalStateException("Recorded program not set or playback not started yet");
}
if (mProgram == null || mPlaybackState == PlaybackState.STATE_NONE) {
return;
}
positionMs = getRealSeekPosition(positionMs, SEEK_POSITION_MARGIN_MS);
if (DEBUG) Log.d(TAG, "Now: " + getPlaybackPosition() + ", shift to: " + positionMs);
mTvView.timeShiftSeekTo(positionMs + mStartPositionMs);
if (mPlaybackState == PlaybackState.STATE_FAST_FORWARDING ||
mPlaybackState == PlaybackState.STATE_REWINDING) {
mPlaybackState = PlaybackState.STATE_PLAYING;
mTvView.timeShiftResume();
mCallback.onPlaybackStateChanged(mPlaybackState, 1);
}
}
示例5: onRewind
@Override
public void onRewind() {
if (!mDvrPlayer.isPlaybackPrepared()) {
return;
}
if (mDvrPlayer.getPlaybackState() == PlaybackState.STATE_REWINDING) {
if (mSpeedLevel < TimeShiftUtils.MAX_SPEED_LEVEL) {
mSpeedLevel++;
} else {
return;
}
} else {
mSpeedLevel = 0;
}
mDvrPlayer.rewind(TimeShiftUtils.getPlaybackSpeed(mSpeedLevel, mProgramDurationMs));
}
示例6: isMediaPlaying
@Override
public boolean isMediaPlaying() {
if (mMediaController.getPlaybackState() == null) {
return false;
}
int state = mMediaController.getPlaybackState().getState();
return (state == PlaybackState.STATE_BUFFERING
|| state == PlaybackState.STATE_CONNECTING
|| state == PlaybackState.STATE_PLAYING
|| state == PlaybackState.STATE_FAST_FORWARDING
|| state == PlaybackState.STATE_REWINDING
|| state == PlaybackState.STATE_SKIPPING_TO_PREVIOUS
|| state == PlaybackState.STATE_SKIPPING_TO_NEXT);
}
示例7: onPause
@Override
public void onPause() {
if (DEBUG) Log.d(TAG, "onPause");
super.onPause();
if (mMediaSessionHelper.getPlaybackState() == PlaybackState.STATE_FAST_FORWARDING
|| mMediaSessionHelper.getPlaybackState() == PlaybackState.STATE_REWINDING) {
getActivity().getMediaController().getTransportControls().pause();
}
if (mMediaSessionHelper.getPlaybackState() == PlaybackState.STATE_NONE) {
getActivity().requestVisibleBehind(false);
} else {
getActivity().requestVisibleBehind(true);
}
}
示例8: onKey
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (mReadyToControl) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE && event.getAction() == KeyEvent.ACTION_DOWN
&& (mPlaybackState == PlaybackState.STATE_FAST_FORWARDING
|| mPlaybackState == PlaybackState.STATE_REWINDING)) {
// Workaround of b/31489271. Clicks play/pause button first to reset play controls
// to "play" state. Then we can pass MEDIA_PAUSE to let playback be paused.
onActionClicked(getControlsRow().getActionForKeyCode(keyCode));
}
return super.onKey(v, keyCode, event);
}
return false;
}
示例9: onPlayerStateChanged
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
Timber.e("onPlayerStateChanged: playWhenReady = " + String.valueOf(playWhenReady)
+ " playbackState = " + playbackState);
switch (playbackState) {
case PlaybackState.STATE_PLAYING:
//初始化播放點擊事件並設置總時長
initPlayVideo();
Timber.e("播放狀態: 準備 playing");
break;
case PlaybackState.STATE_BUFFERING:
Timber.e("播放狀態: 緩存完成 playing");
break;
case PlaybackState.STATE_CONNECTING:
Timber.e("播放狀態: 連接 CONNECTING");
break;
case PlaybackState.STATE_ERROR://錯誤
Timber.e("播放狀態: 錯誤 STATE_ERROR");
startPlay.setBackgroundColor(Color.WHITE);
ToastUtil.showShort("播放錯誤");
break;
case PlaybackState.STATE_FAST_FORWARDING:
Timber.e("播放狀態: 快速傳遞,播放完畢");
pausePlay();//暫停播放
break;
case PlaybackState.STATE_NONE:
Timber.e("播放狀態: 無 STATE_NONE");
break;
case PlaybackState.STATE_PAUSED:
Timber.e("播放狀態: 暫停 PAUSED");
break;
case PlaybackState.STATE_REWINDING:
Timber.e("播放狀態: 倒回 REWINDING");
break;
case PlaybackState.STATE_SKIPPING_TO_NEXT:
Timber.e("播放狀態: 跳到下一個");
break;
case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
Timber.e("播放狀態: 跳到上一個");
break;
case PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM:
Timber.e("播放狀態: 跳到指定的Item");
break;
case PlaybackState.STATE_STOPPED:
Timber.e("播放狀態: 停止的 STATE_STOPPED");
break;
}
}
示例10: onStateChanged
private void onStateChanged(int state, long positionMs, int speedLevel) {
if (DEBUG) Log.d(TAG, "onStateChanged");
getControlsRow().setCurrentTime((int) positionMs);
if (state == mPlaybackState && mPlaybackSpeedLevel == speedLevel) {
// Only position is changed, no need to update controls row
return;
}
// NOTICE: The below two variables should only be used in this method.
// The only usage of them is to confirm if the state is changed or not.
mPlaybackState = state;
mPlaybackSpeedLevel = speedLevel;
switch (state) {
case PlaybackState.STATE_PLAYING:
mPlaybackSpeedId = PLAYBACK_SPEED_NORMAL;
setFadingEnabled(true);
mReadyToControl = true;
break;
case PlaybackState.STATE_PAUSED:
mPlaybackSpeedId = PLAYBACK_SPEED_PAUSED;
setFadingEnabled(true);
mReadyToControl = true;
break;
case PlaybackState.STATE_FAST_FORWARDING:
mPlaybackSpeedId = PLAYBACK_SPEED_FAST_L0 + speedLevel;
setFadingEnabled(false);
mReadyToControl = true;
break;
case PlaybackState.STATE_REWINDING:
mPlaybackSpeedId = -PLAYBACK_SPEED_FAST_L0 - speedLevel;
setFadingEnabled(false);
mReadyToControl = true;
break;
case PlaybackState.STATE_CONNECTING:
setFadingEnabled(false);
mReadyToControl = false;
break;
case PlaybackState.STATE_NONE:
mReadyToControl = false;
break;
default:
setFadingEnabled(true);
break;
}
onStateChanged();
}