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


Java PlaybackState.STATE_NONE屬性代碼示例

本文整理匯總了Java中android.media.session.PlaybackState.STATE_NONE屬性的典型用法代碼示例。如果您正苦於以下問題:Java PlaybackState.STATE_NONE屬性的具體用法?Java PlaybackState.STATE_NONE怎麽用?Java PlaybackState.STATE_NONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.media.session.PlaybackState的用法示例。


在下文中一共展示了PlaybackState.STATE_NONE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
    }
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:21,代碼來源:DvrPlayer.java

示例2: onClick

@Override
public void onClick(View v) {
    PlaybackState stateObj = getActivity().getMediaController().getPlaybackState();
    final int state = stateObj == null ?
            PlaybackState.STATE_NONE : stateObj.getState();
    LogHelper.d(TAG, "Button pressed, in state " + state);
    switch (v.getId()) {
        case R.id.play_pause:
            LogHelper.d(TAG, "Play button pressed, in state " + state);
            if (state == PlaybackState.STATE_PAUSED ||
                    state == PlaybackState.STATE_STOPPED ||
                    state == PlaybackState.STATE_NONE) {
                playMedia();
            } else if (state == PlaybackState.STATE_PLAYING ||
                    state == PlaybackState.STATE_BUFFERING ||
                    state == PlaybackState.STATE_CONNECTING) {
                pauseMedia();
            }
            break;
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:21,代碼來源:PlaybackControlsFragment.java

示例3: shouldShowControls

/**
 * Check if the MediaSession is active and in a "playback-able" state
 * (not NONE and not STOPPED).
 *
 * @return true if the MediaSession's state requires playback controls to be visible.
 */
protected boolean shouldShowControls() {
    MediaController mediaController = getMediaController();
    if (mediaController == null ||
        mediaController.getMetadata() == null ||
        mediaController.getPlaybackState() == null) {
        return false;
    }
    switch (mediaController.getPlaybackState().getState()) {
        case PlaybackState.STATE_ERROR:
        case PlaybackState.STATE_NONE:
        case PlaybackState.STATE_STOPPED:
            return false;
        default:
            return true;
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:22,代碼來源:BaseActivity.java

示例4: getView

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    MediaBrowser.MediaItem item = getItem(position);
    int itemState = MediaItemViewHolder.STATE_NONE;
    if (item.isPlayable()) {
        String itemMediaId = item.getDescription().getMediaId();
        int playbackState = PlaybackState.STATE_NONE;
        if (mCurrentState != null) {
            playbackState = mCurrentState.getState();
        }
        if (mCurrentMetadata != null &&
                itemMediaId.equals(mCurrentMetadata.getDescription().getMediaId())) {
            if (playbackState == PlaybackState.STATE_PLAYING ||
                playbackState == PlaybackState.STATE_BUFFERING) {
                itemState = MediaItemViewHolder.STATE_PLAYING;
            } else if (playbackState != PlaybackState.STATE_ERROR) {
                itemState = MediaItemViewHolder.STATE_PAUSED;
            }
        }
    }
    return MediaItemViewHolder.setupView((Activity) getContext(), convertView, parent,
        item.getDescription(), itemState);
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:23,代碼來源:MusicPlayerActivity.java

示例5: onClick

@Override
public void onClick(View v) {
    final int state = mCurrentState == null ?
            PlaybackState.STATE_NONE : mCurrentState.getState();
    if (state == PlaybackState.STATE_PAUSED ||
            state == PlaybackState.STATE_STOPPED ||
            state == PlaybackState.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata = MusicLibrary.getMetadata(MusicPlayerActivity.this,
                    MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }
        getMediaController().getTransportControls().playFromMediaId(
                mCurrentMetadata.getDescription().getMediaId(), null);

    } else {
        getMediaController().getTransportControls().pause();
    }
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:20,代碼來源:MusicPlayerActivity.java

示例6: onClick

@Override
public void onClick(View v) {
    final int state =
            mCurrentState == null
                    ? PlaybackStateCompat.STATE_NONE
                    : mCurrentState.getState();
    if (state == PlaybackState.STATE_PAUSED
            || state == PlaybackState.STATE_STOPPED
            || state == PlaybackState.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata =
                    MusicLibrary.getMetadata(
                            MusicPlayerActivity.this,
                            MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .playFromMediaId(
                        mCurrentMetadata.getDescription().getMediaId(), null);
    } else {
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .pause();
    }
}
 
開發者ID:googlecodelabs,項目名稱:musicplayer-devices,代碼行數:27,代碼來源:MusicPlayerActivity.java

示例7: getPlaybackState

private int getPlaybackState() {
	Activity activity = getActivity();

	if (activity != null) {
		PlaybackState state = activity.getMediaController().getPlaybackState();
		if (state != null) {
			return state.getState();
		} else {
			return PlaybackState.STATE_NONE;
		}
	}
	return PlaybackState.STATE_NONE;
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:13,代碼來源:OverlayFragment.java

示例8: onPlaybackStateChanged

@Override
public void onPlaybackStateChanged(@NonNull PlaybackState state) {
	if (state.getState() != PlaybackState.STATE_NONE) {
		updateProgress();
	}
	onStateChanged();
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:7,代碼來源:PlaybackHelper.java

示例9: onPlaybackStateChanged

@Override
public void onPlaybackStateChanged(@NonNull PlaybackState state) {
    // Update your UI to reflect the new state. Do not change media playback here.
    if (DEBUG) Log.d(TAG, "Playback state changed: " + state.getState());

    int nextState = state.getState();
    if (nextState != PlaybackState.STATE_NONE) {
        updateProgress();
    }
    onStateChanged();
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:11,代碼來源:PlaybackControlHelper.java

示例10: getPlaybackState

private int getPlaybackState() {
    Activity activity = getActivity();

    if (activity != null) {
        PlaybackState state = activity.getMediaController().getPlaybackState();
        if (state != null) {
            return state.getState();
        } else {
            return PlaybackState.STATE_NONE;
        }
    }
    return PlaybackState.STATE_NONE;
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:13,代碼來源:PlaybackOverlayFragment.java

示例11: prepare

/**
 * Prepares playback.
 *
 * @param doPlay indicates DVR player do or do not start playback after media is prepared.
 */
public void prepare(boolean doPlay) throws IllegalStateException {
    if (DEBUG) Log.d(TAG, "prepare()");
    if (mProgram == null) {
        throw new IllegalStateException("Recorded program not set");
    } else if (mPlaybackState != PlaybackState.STATE_NONE) {
        throw new IllegalStateException("Playback is already prepared");
    }
    mTvView.timeShiftPlay(mProgram.getInputId(), mProgram.getUri());
    mPlaybackState = PlaybackState.STATE_CONNECTING;
    mPauseOnPrepared = !doPlay;
    mCallback.onPlaybackStateChanged(mPlaybackState, 1);
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:17,代碼來源:DvrPlayer.java

示例12: reset

/**
 * Resets playback.
 */
public void reset() {
    if (DEBUG) Log.d(TAG, "reset()");
    mCallback.onPlaybackStateChanged(PlaybackState.STATE_NONE, 1);
    mPlaybackState = PlaybackState.STATE_NONE;
    mTvView.reset();
    mTimeShiftPlayAvailable = false;
    mStartPositionMs = TvInputManager.TIME_SHIFT_INVALID_TIME;
    mTimeShiftCurrentPositionMs = 0;
    mPlaybackParams.setSpeed(1.0f);
    mProgram = null;
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:14,代碼來源:DvrPlayer.java

示例13: setProgram

/**
 * Sets recorded programs for playback. If the player is playing another program, stops it.
 */
public void setProgram(RecordedProgram program, long initialSeekPositionMs) {
    if (mProgram != null && mProgram.equals(program)) {
        return;
    }
    if (mPlaybackState != PlaybackState.STATE_NONE) {
        reset();
    }
    mInitialSeekPositionMs = initialSeekPositionMs;
    mProgram = program;
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:13,代碼來源:DvrPlayer.java

示例14: 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);
    }
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:14,代碼來源:DvrPlaybackOverlayFragment.java

示例15: isMediaPlaying

@Override
public boolean isMediaPlaying() {
    PlaybackState playbackState = mMediaController.getPlaybackState();
    if (playbackState == null) {
        return false;
    }
    int state = playbackState.getState();
    return state != PlaybackState.STATE_NONE && state != PlaybackState.STATE_CONNECTING
            && state != PlaybackState.STATE_PAUSED;
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:10,代碼來源:DvrPlaybackControlHelper.java


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