Java Code Examples for com.google.android.gms.cast.MediaStatus#PLAYER_STATE_BUFFERING
The following examples show how to use
com.google.android.gms.cast.MediaStatus#PLAYER_STATE_BUFFERING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CastPlayback.java From klingar with Apache License 2.0 | 6 votes |
private static String getPlayerState(int state) { switch (state) { case MediaStatus.PLAYER_STATE_UNKNOWN: return "PLAYER_STATE_UNKNOWN"; case MediaStatus.PLAYER_STATE_IDLE: return "PLAYER_STATE_IDLE"; case MediaStatus.PLAYER_STATE_BUFFERING: return "PLAYER_STATE_BUFFERING"; case MediaStatus.PLAYER_STATE_PAUSED: return "PLAYER_STATE_PAUSED"; case MediaStatus.PLAYER_STATE_PLAYING: return "PLAYER_STATE_PLAYING"; default: return "UNKNOWN"; } }
Example 2
Source File: VideoCastControllerFragment.java From UTubeTV with The Unlicense | 6 votes |
private void togglePlayback() throws CastException, TransientNetworkDisconnectionException, NoConnectionException { switch (mPlaybackState) { case MediaStatus.PLAYER_STATE_PAUSED: mCastManager.play(); mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; restartTrickplayTimer(); break; case MediaStatus.PLAYER_STATE_PLAYING: mCastManager.pause(); mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; break; case MediaStatus.PLAYER_STATE_IDLE: if ((mSelectedMedia.getStreamType() == MediaInfo.STREAM_TYPE_LIVE) && (mCastManager.getIdleReason() == MediaStatus.IDLE_REASON_CANCELED)) { mCastManager.play(); } else { mCastManager.loadMedia(mSelectedMedia, true, 0); } mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; restartTrickplayTimer(); break; default: break; } mCastController.setPlaybackStatus(mPlaybackState); }
Example 3
Source File: VideoCastManager.java From android with Apache License 2.0 | 6 votes |
/** * A helper method to determine if, given a player state and an idle reason (if the state is * idle) will warrant having a UI for remote presentation of the remote content. * * @param state * @param idleReason * @return * @throws TransientNetworkDisconnectionException * @throws NoConnectionException */ public boolean shouldRemoteUiBeVisible(int state, int idleReason) throws TransientNetworkDisconnectionException, NoConnectionException { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: case MediaStatus.PLAYER_STATE_PAUSED: case MediaStatus.PLAYER_STATE_BUFFERING: return true; case MediaStatus.PLAYER_STATE_IDLE: if (!isRemoteStreamLive()) { return false; } return idleReason == MediaStatus.IDLE_REASON_CANCELED; default: break; } return false; }
Example 4
Source File: VideoCastControllerFragment.java From UTubeTV with The Unlicense | 6 votes |
@Override public void onStopTrackingTouch(SeekBar seekBar) { try { if (mPlaybackState == MediaStatus.PLAYER_STATE_PLAYING) { mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; mCastController.setPlaybackStatus(mPlaybackState); mCastManager.play(seekBar.getProgress()); } else if (mPlaybackState == MediaStatus.PLAYER_STATE_PAUSED) { mCastManager.seek(seekBar.getProgress()); } restartTrickplayTimer(); } catch (Exception e) { CastUtils.LOGE(TAG, "Failed to complete seek", e); mCastController.closeActivity(); } }
Example 5
Source File: VideoCastControllerFragment.java From UTubeTV with The Unlicense | 6 votes |
public void onReady(MediaInfo mediaInfo, boolean shouldStartPlayback, int startPoint) { mSelectedMedia = mediaInfo; try { mCastController.setStreamType(mSelectedMedia.getStreamType()); if (shouldStartPlayback) { // need to start remote playback mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; mCastController.setPlaybackStatus(mPlaybackState); mCastManager.loadMedia(mSelectedMedia, true, startPoint); } else { // we don't change the status of remote playback if (mCastManager.isRemoteMoviePlaying()) { mPlaybackState = MediaStatus.PLAYER_STATE_PLAYING; } else { mPlaybackState = MediaStatus.PLAYER_STATE_PAUSED; } mCastController.setPlaybackStatus(mPlaybackState); } } catch (Exception e) { CastUtils.LOGE(TAG, "Failed to get playback and media information", e); mCastController.closeActivity(); } updateMetadata(); restartTrickplayTimer(); }
Example 6
Source File: VideoCastControllerFragment.java From android with Apache License 2.0 | 6 votes |
private void onReady(MediaInfo mediaInfo, boolean shouldStartPlayback, int startPoint, JSONObject customData) { mSelectedMedia = mediaInfo; try { mCastController.setStreamType(mSelectedMedia.getStreamType()); if (shouldStartPlayback) { // need to start remote playback mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; mCastController.setPlaybackStatus(mPlaybackState); mCastManager.loadMedia(mSelectedMedia, true, startPoint, customData); } else { // we don't change the status of remote playback if (mCastManager.isRemoteMoviePlaying()) { mPlaybackState = MediaStatus.PLAYER_STATE_PLAYING; } else { mPlaybackState = MediaStatus.PLAYER_STATE_PAUSED; } mCastController.setPlaybackStatus(mPlaybackState); } } catch (Exception e) { LOGE(TAG, "Failed to get playback and media information", e); mCastController.closeActivity(); } updateMetadata(); restartTrickplayTimer(); }
Example 7
Source File: VideoCastControllerFragment.java From android with Apache License 2.0 | 6 votes |
@Override public void onStopTrackingTouch(SeekBar seekBar) { try { if (mPlaybackState == MediaStatus.PLAYER_STATE_PLAYING) { mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; mCastController.setPlaybackStatus(mPlaybackState); mCastManager.play(seekBar.getProgress()); } else if (mPlaybackState == MediaStatus.PLAYER_STATE_PAUSED) { mCastManager.seek(seekBar.getProgress()); } restartTrickplayTimer(); } catch (Exception e) { LOGE(TAG, "Failed to complete seek", e); mCastController.closeActivity(); } }
Example 8
Source File: ChromecastBaseControllerFragment.java From SkyTube with GNU General Public License v3.0 | 6 votes |
/** * Change the visibility of the play/pause/buffering buttons depending on the current playback state. */ protected void updateButtons() { if(currentPlayerState == MediaStatus.PLAYER_STATE_PLAYING) { playButton.setVisibility(View.GONE); pauseButton.setVisibility(View.VISIBLE); bufferingSpinner.setVisibility(View.GONE); } else if(currentPlayerState == MediaStatus.PLAYER_STATE_PAUSED) { pauseButton.setVisibility(View.GONE); playButton.setVisibility(View.VISIBLE); bufferingSpinner.setVisibility(View.GONE); } else if(currentPlayerState == MediaStatus.PLAYER_STATE_BUFFERING) { pauseButton.setVisibility(View.GONE); playButton.setVisibility(View.GONE); bufferingSpinner.setVisibility(View.VISIBLE); } }
Example 9
Source File: ChromeCastMediaPlayerProfile.java From DeviceConnect-Android with MIT License | 6 votes |
/** * 再生状態を文字列に変換する. * * @param playState 再生状態 * @return 再生状態の文字列を返す */ public String getPlayStatus(final int playState) { switch (playState) { case MediaStatus.PLAYER_STATE_BUFFERING: return MESSAGE_BUFFERING; case MediaStatus.PLAYER_STATE_IDLE: return MESSAGE_STOP; case MediaStatus.PLAYER_STATE_PAUSED: return MESSAGE_PAUSED; case MediaStatus.PLAYER_STATE_PLAYING: return MESSAGE_PALYING; case MediaStatus.PLAYER_STATE_UNKNOWN: default: return MESSAGE_UNKNOWN; } }
Example 10
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 6 votes |
/** * A helper method to determine if, given a player state and an idle reason (if the state is * idle) will warrant having a UI for remote presentation of the remote content. * * @param state * @param idleReason * @return * @throws TransientNetworkDisconnectionException * @throws NoConnectionException */ public boolean shouldRemoteUiBeVisible(int state, int idleReason) throws TransientNetworkDisconnectionException, NoConnectionException { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: case MediaStatus.PLAYER_STATE_PAUSED: case MediaStatus.PLAYER_STATE_BUFFERING: return true; case MediaStatus.PLAYER_STATE_IDLE: if (!isRemoteStreamLive()) { return false; } return idleReason == MediaStatus.IDLE_REASON_CANCELED; default: break; } return false; }
Example 11
Source File: VideoCastControllerFragment.java From android with Apache License 2.0 | 5 votes |
private void togglePlayback() throws CastException, TransientNetworkDisconnectionException, NoConnectionException { switch (mPlaybackState) { case MediaStatus.PLAYER_STATE_PAUSED: mCastManager.play(); mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; restartTrickplayTimer(); break; case MediaStatus.PLAYER_STATE_PLAYING: mCastManager.pause(); mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; break; case MediaStatus.PLAYER_STATE_IDLE: if ((mSelectedMedia.getStreamType() == MediaInfo.STREAM_TYPE_LIVE) && (mCastManager.getIdleReason() == MediaStatus.IDLE_REASON_CANCELED)) { mCastManager.play(); } else { mCastManager.loadMedia(mSelectedMedia, true, 0); } mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING; restartTrickplayTimer(); break; default: break; } mCastController.setPlaybackStatus(mPlaybackState); }
Example 12
Source File: VideoCastControllerActivity.java From UTubeTV with The Unlicense | 5 votes |
@Override public void setPlaybackStatus(int state) { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: mLoading.setVisibility(View.INVISIBLE); mPlayPause.setVisibility(View.VISIBLE); if (mStreamType == MediaInfo.STREAM_TYPE_LIVE) { mPlayPause.setImageDrawable(mStopDrawable); } else { mPlayPause.setImageDrawable(mPauseDrawable); } mLine2.setText(getString(R.string.casting_to_device, mCastManager.getDeviceName())); mControllers.setVisibility(View.VISIBLE); break; case MediaStatus.PLAYER_STATE_PAUSED: mControllers.setVisibility(View.VISIBLE); mLoading.setVisibility(View.INVISIBLE); mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); mLine2.setText(getString(R.string.casting_to_device, mCastManager.getDeviceName())); break; case MediaStatus.PLAYER_STATE_IDLE: mLoading.setVisibility(View.INVISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); mPlayPause.setVisibility(View.VISIBLE); mLine2.setText(getString(R.string.casting_to_device, mCastManager.getDeviceName())); break; case MediaStatus.PLAYER_STATE_BUFFERING: mPlayPause.setVisibility(View.INVISIBLE); mLoading.setVisibility(View.VISIBLE); mLine2.setText(getString(R.string.loading)); break; default: break; } }
Example 13
Source File: MiniController.java From UTubeTV with The Unlicense | 4 votes |
@Override public void setPlaybackStatus(int state, int idleReason) { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(getPauseStopButton()); setLoadingVisibility(false); break; case MediaStatus.PLAYER_STATE_PAUSED: mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); setLoadingVisibility(false); break; case MediaStatus.PLAYER_STATE_IDLE: switch (mStreamType) { case MediaInfo.STREAM_TYPE_BUFFERED: mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(false); break; case MediaInfo.STREAM_TYPE_LIVE: if (idleReason == MediaStatus.IDLE_REASON_CANCELED) { mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); setLoadingVisibility(false); } else { mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(false); } break; } break; case MediaStatus.PLAYER_STATE_BUFFERING: mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(true); break; default: mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(false); break; } }
Example 14
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 4 votes |
/** * Indicates if the remote movie is currently playing (or buffering). */ public boolean isRemoteMoviePlaying() throws TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); return mState == MediaStatus.PLAYER_STATE_BUFFERING || mState == MediaStatus.PLAYER_STATE_PLAYING; }
Example 15
Source File: VideoMediaRouteControllerDialog.java From UTubeTV with The Unlicense | 4 votes |
private void updatePlayPauseState(int state) { if (null != mPausePlay) { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: mPausePlay.setVisibility(View.VISIBLE); mPausePlay.setImageDrawable(getPauseStopButton()); setLoadingVisibility(false); break; case MediaStatus.PLAYER_STATE_PAUSED: mPausePlay.setVisibility(View.VISIBLE); mPausePlay.setImageDrawable(mPlayDrawable); setLoadingVisibility(false); break; case MediaStatus.PLAYER_STATE_IDLE: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); if (mState == MediaStatus.PLAYER_STATE_IDLE && mCastManager.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) { hideControls(true, R.string.no_media_info); } else { switch (mStreamType) { case MediaInfo.STREAM_TYPE_BUFFERED: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); break; case MediaInfo.STREAM_TYPE_LIVE: int idleReason = mCastManager.getIdleReason(); if (idleReason == MediaStatus.IDLE_REASON_CANCELED) { mPausePlay.setVisibility(View.VISIBLE); mPausePlay.setImageDrawable(mPlayDrawable); setLoadingVisibility(false); } else { mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); } break; } } break; case MediaStatus.PLAYER_STATE_BUFFERING: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(true); break; default: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); } } }
Example 16
Source File: MiniController.java From android with Apache License 2.0 | 4 votes |
@Override public void setPlaybackStatus(int state, int idleReason) { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(getPauseStopButton()); setLoadingVisibility(false); break; case MediaStatus.PLAYER_STATE_PAUSED: mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); setLoadingVisibility(false); break; case MediaStatus.PLAYER_STATE_IDLE: switch (mStreamType) { case MediaInfo.STREAM_TYPE_BUFFERED: mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(false); break; case MediaInfo.STREAM_TYPE_LIVE: if (idleReason == MediaStatus.IDLE_REASON_CANCELED) { mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); setLoadingVisibility(false); } else { mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(false); } break; } break; case MediaStatus.PLAYER_STATE_BUFFERING: mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(true); break; default: mPlayPause.setVisibility(View.INVISIBLE); setLoadingVisibility(false); break; } }
Example 17
Source File: VideoCastControllerActivity.java From android with Apache License 2.0 | 4 votes |
@Override public void setPlaybackStatus(int state) { LOGD(TAG, "setPlaybackStatus(): state = " + state); switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: mLoading.setVisibility(View.INVISIBLE); mPlayPause.setVisibility(View.VISIBLE); if (mStreamType == MediaInfo.STREAM_TYPE_LIVE) { mPlayPause.setImageDrawable(mStopDrawable); } else { mPlayPause.setImageDrawable(mPauseDrawable); } mLine2.setText(getString(R.string.casting_to_device, mCastManager.getDeviceName())); mControllers.setVisibility(View.VISIBLE); break; case MediaStatus.PLAYER_STATE_PAUSED: mControllers.setVisibility(View.VISIBLE); mLoading.setVisibility(View.INVISIBLE); mPlayPause.setVisibility(View.VISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); mLine2.setText(getString(R.string.casting_to_device, mCastManager.getDeviceName())); break; case MediaStatus.PLAYER_STATE_IDLE: mLoading.setVisibility(View.INVISIBLE); mPlayPause.setImageDrawable(mPlayDrawable); mPlayPause.setVisibility(View.VISIBLE); mLine2.setText(getString(R.string.casting_to_device, mCastManager.getDeviceName())); break; case MediaStatus.PLAYER_STATE_BUFFERING: mPlayPause.setVisibility(View.INVISIBLE); mLoading.setVisibility(View.VISIBLE); mLine2.setText(getString(R.string.loading)); break; default: break; } }
Example 18
Source File: VideoMediaRouteControllerDialog.java From android with Apache License 2.0 | 4 votes |
private void updatePlayPauseState(int state) { if (null != mPausePlay) { switch (state) { case MediaStatus.PLAYER_STATE_PLAYING: mPausePlay.setImageDrawable(getPauseStopButton()); adjustControlsVisibility(true); break; case MediaStatus.PLAYER_STATE_PAUSED: mPausePlay.setImageDrawable(mPlayDrawable); adjustControlsVisibility(true); break; case MediaStatus.PLAYER_STATE_IDLE: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); if (mState == MediaStatus.PLAYER_STATE_IDLE && mCastManager.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) { hideControls(true, R.string.no_media_info); } else { switch (mStreamType) { case MediaInfo.STREAM_TYPE_BUFFERED: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); break; case MediaInfo.STREAM_TYPE_LIVE: int idleReason = mCastManager.getIdleReason(); if (idleReason == MediaStatus.IDLE_REASON_CANCELED) { mPausePlay.setImageDrawable(mPlayDrawable); adjustControlsVisibility(true); } else { mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); } break; } } break; case MediaStatus.PLAYER_STATE_BUFFERING: adjustControlsVisibility(false); break; default: mPausePlay.setVisibility(View.INVISIBLE); setLoadingVisibility(false); } } }
Example 19
Source File: CastPlayback.java From klingar with Apache License 2.0 | 4 votes |
private void updatePlaybackState() { int newPlayerState = remoteMediaClient.getPlayerState(); int idleReason = remoteMediaClient.getIdleReason(); Timber.d("updatePlaybackState %s %s", getPlayerState(playerState), getIdleReason(idleReason)); if (newPlayerState == playerState) { return; } playerState = newPlayerState; switch (playerState) { case MediaStatus.PLAYER_STATE_IDLE: if (idleReason == MediaStatus.IDLE_REASON_FINISHED) { if (callback != null) { currentPosition = 0; callback.onCompletion(); } } break; case MediaStatus.PLAYER_STATE_BUFFERING: state = PlaybackStateCompat.STATE_BUFFERING; if (callback != null) { callback.onPlaybackStatusChanged(); } break; case MediaStatus.PLAYER_STATE_PLAYING: state = PlaybackStateCompat.STATE_PLAYING; setMetadataFromRemote(); if (callback != null) { callback.onPlaybackStatusChanged(); } break; case MediaStatus.PLAYER_STATE_PAUSED: state = PlaybackStateCompat.STATE_PAUSED; setMetadataFromRemote(); if (callback != null) { callback.onPlaybackStatusChanged(); } break; default: } }
Example 20
Source File: VideoCastManager.java From android with Apache License 2.0 | 3 votes |
/** * Indicates if the remote movie is currently playing (or buffering). * * @return * @throws NoConnectionException * @throws TransientNetworkDisconnectionException */ public boolean isRemoteMoviePlaying() throws TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); return mState == MediaStatus.PLAYER_STATE_BUFFERING || mState == MediaStatus.PLAYER_STATE_PLAYING; }