本文整理匯總了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);
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例8: onPlaybackStateChanged
@Override
public void onPlaybackStateChanged(@NonNull PlaybackState state) {
if (state.getState() != PlaybackState.STATE_NONE) {
updateProgress();
}
onStateChanged();
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}