当前位置: 首页>>代码示例>>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;未经允许,请勿转载。