Example usage for android.media.session PlaybackState STATE_BUFFERING

List of usage examples for android.media.session PlaybackState STATE_BUFFERING

Introduction

In this page you can find the example usage for android.media.session PlaybackState STATE_BUFFERING.

Prototype

int STATE_BUFFERING

To view the source code for android.media.session PlaybackState STATE_BUFFERING.

Click Source Link

Document

State indicating this item is currently buffering and will begin playing when enough data has buffered.

Usage

From source file:com.orangesoft.jook.CastPlayback.java

private void safeStatusChangeNotification(int playbackState) {
    state = playbackState;//from   w  w w .  ja  v  a2  s  .  c  o  m
    if (state != PlaybackState.STATE_BUFFERING)
        updateMetadata();
    if (callback != null)
        callback.onPlaybackStatusChanged(state);
}

From source file:com.example.android.supportv4.media.Playback.java

/**
 * Called when MediaPlayer has completed a seek
 *
 * @see android.media.MediaPlayer.OnSeekCompleteListener
 *///from  w  w w  .  j  a va 2s .com
@Override
public void onSeekComplete(MediaPlayer mp) {
    Log.d(TAG, "onSeekComplete from MediaPlayer:" + mp.getCurrentPosition());
    mCurrentPosition = mp.getCurrentPosition();
    if (mState == PlaybackState.STATE_BUFFERING) {
        mMediaPlayer.start();
        mState = PlaybackState.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlaybackStatusChanged(mState);
    }
}

From source file:com.appdevper.mediaplayer.app.LocalPlayback.java

/**
 * Called when MediaPlayer has completed a seek
 *
 * @see OnSeekCompleteListener/*from  www .j  a v  a  2  s .co  m*/
 */
@Override
public void onSeekComplete(MediaPlayer mp) {
    LogHelper.d(TAG, "onSeekComplete from MediaPlayer:", mp.getCurrentPosition());
    mCurrentPosition = mp.getCurrentPosition();
    if (mState == PlaybackState.STATE_BUFFERING) {
        mMediaPlayer.start();
        mState = PlaybackState.STATE_PLAYING;
    }
    if (mCallback != null) {
        mCallback.onPlaybackStatusChanged(mState);
    }
}

From source file:com.appdevper.mediaplayer.activity.FullScreenPlayerActivity.java

private void updatePlaybackState(PlaybackStateCompat state) {
    if (state == null) {
        return;//  www .  j a v  a2 s. c o  m
    }
    mLastPlaybackState = state;
    if (getSupportMediaController() != null && getSupportMediaController().getExtras() != null) {
        String castName = getSupportMediaController().getExtras().getString(MusicService.EXTRA_CONNECTED_CAST);
        String line3Text = castName == null ? ""
                : getResources().getString(R.string.casting_to_device, castName);
        mLine3.setText(line3Text);
    }

    switch (state.getState()) {
    case PlaybackState.STATE_PLAYING:
        mLoading.setVisibility(INVISIBLE);
        mPlayPause.setVisibility(VISIBLE);
        mPlayPause.setImageDrawable(mPauseDrawable);
        mControllers.setVisibility(VISIBLE);
        scheduleSeekbarUpdate();
        break;
    case PlaybackState.STATE_PAUSED:
        mControllers.setVisibility(VISIBLE);
        mLoading.setVisibility(INVISIBLE);
        mPlayPause.setVisibility(VISIBLE);
        mPlayPause.setImageDrawable(mPlayDrawable);
        stopSeekbarUpdate();
        break;
    case PlaybackState.STATE_NONE:
    case PlaybackState.STATE_STOPPED:
        mLoading.setVisibility(INVISIBLE);
        mPlayPause.setVisibility(VISIBLE);
        mPlayPause.setImageDrawable(mPlayDrawable);
        stopSeekbarUpdate();
        break;
    case PlaybackState.STATE_BUFFERING:
        mPlayPause.setVisibility(INVISIBLE);
        mLoading.setVisibility(VISIBLE);
        mLine3.setText(R.string.loading);
        stopSeekbarUpdate();
        break;
    default:
        LogHelper.d(TAG, "Unhandled state ", state.getState());
    }

    mSkipNext
            .setVisibility((state.getActions() & PlaybackState.ACTION_SKIP_TO_NEXT) == 0 ? INVISIBLE : VISIBLE);
    mSkipPrev.setVisibility(
            (state.getActions() & PlaybackState.ACTION_SKIP_TO_PREVIOUS) == 0 ? INVISIBLE : VISIBLE);
}