Java Code Examples for com.google.android.gms.cast.MediaStatus#PLAYER_STATE_PAUSED
The following examples show how to use
com.google.android.gms.cast.MediaStatus#PLAYER_STATE_PAUSED .
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 |
@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 3
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 4
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 5
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 6
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 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: 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 9
Source File: QueueListAdapter.java From CastVideos-android with Apache License 2.0 | 6 votes |
private void updatePlayPauseButtonImageResource(ImageButton button) { CastSession castSession = CastContext.getSharedInstance(mAppContext) .getSessionManager().getCurrentCastSession(); RemoteMediaClient remoteMediaClient = (castSession == null) ? null : castSession.getRemoteMediaClient(); if (remoteMediaClient == null) { button.setVisibility(View.GONE); return; } int status = remoteMediaClient.getPlayerState(); switch (status) { case MediaStatus.PLAYER_STATE_PLAYING: button.setImageResource(PAUSE_RESOURCE); break; case MediaStatus.PLAYER_STATE_PAUSED: button.setImageResource(PLAY_RESOURCE); break; default: button.setVisibility(View.GONE); } }
Example 10
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 11
Source File: ChromecastControllerFragment.java From SkyTube with GNU General Public License v3.0 | 5 votes |
@Override public void onStopTrackingTouch(SeekBar seekBar) { isSeeking = false; remoteMediaClient.seek(seekBar.getProgress()); if(remoteMediaClient.getPlayerState() == MediaStatus.PLAYER_STATE_PAUSED) remoteMediaClient.play(); }
Example 12
Source File: VideoCastManager.java From android with Apache License 2.0 | 5 votes |
@Override public void onPlayPauseClicked(View v) throws CastException, TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); if (mState == MediaStatus.PLAYER_STATE_PLAYING) { pause(); } else { boolean isLive = isRemoteStreamLive(); if ((mState == MediaStatus.PLAYER_STATE_PAUSED && !isLive) || (mState == MediaStatus.PLAYER_STATE_IDLE && isLive)) { play(); } } }
Example 13
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 5 votes |
@Override public void onPlayPauseClicked(View v) throws CastException, TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); if (mState == MediaStatus.PLAYER_STATE_PLAYING) { pause(); } else { boolean isLive = isRemoteStreamLive(); if ((mState == MediaStatus.PLAYER_STATE_PAUSED && !isLive) || (mState == MediaStatus.PLAYER_STATE_IDLE && isLive)) { play(); } } }
Example 14
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 15
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 16
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 17
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 18
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 19
Source File: VideoCastManager.java From UTubeTV with The Unlicense | 4 votes |
/** * Returns <code>true</code> if the remote connected device is playing a movie. */ public boolean isRemoteMoviePaused() throws TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); return mState == MediaStatus.PLAYER_STATE_PAUSED; }
Example 20
Source File: VideoCastManager.java From android with Apache License 2.0 | 2 votes |
/** * Returns <code>true</code> if the remote connected device is playing a movie. * * @return * @throws NoConnectionException * @throws TransientNetworkDisconnectionException */ public boolean isRemoteMoviePaused() throws TransientNetworkDisconnectionException, NoConnectionException { checkConnectivity(); return mState == MediaStatus.PLAYER_STATE_PAUSED; }