android.support.v7.media.MediaSessionStatus Java Examples
The following examples show how to use
android.support.v7.media.MediaSessionStatus.
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: SampleMediaRouteProvider.java From V.FlyoutTest with MIT License | 6 votes |
private boolean handleEndSession(Intent intent, ControlRequestCallback callback) { String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID); boolean success = (sid != null) && sid.equals(mSessionManager.getSessionId()) && mSessionManager.endSession(); if (callback != null) { if (success) { Bundle result = new Bundle(); MediaSessionStatus sessionStatus = new MediaSessionStatus.Builder( MediaSessionStatus.SESSION_STATE_ENDED).build(); result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS, sessionStatus.asBundle()); callback.onResult(result); handleSessionStatusChange(sid); mSessionReceiver = null; } else { callback.onError("Failed to end session, sid=" + sid, null); } } return success; }
Example #2
Source File: SampleMediaRouteProvider.java From android-MediaRouter with Apache License 2.0 | 6 votes |
private boolean handleEndSession(Intent intent, ControlRequestCallback callback) { String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID); boolean success = (sid != null) && sid.equals(mSessionManager.getSessionId()) && mSessionManager.endSession(); if (callback != null) { if (success) { Bundle result = new Bundle(); MediaSessionStatus sessionStatus = new MediaSessionStatus.Builder( MediaSessionStatus.SESSION_STATE_ENDED).build(); result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS, sessionStatus.asBundle()); callback.onResult(result); handleSessionStatusChange(sid); mSessionReceiver = null; } else { callback.onError("Failed to end session, sid=" + sid, null); } } return success; }
Example #3
Source File: SampleMediaRouteProvider.java From V.FlyoutTest with MIT License | 6 votes |
private boolean handleGetSessionStatus(Intent intent, ControlRequestCallback callback) { String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID); MediaSessionStatus sessionStatus = mSessionManager.getSessionStatus(sid); if (callback != null) { if (sessionStatus != null) { Bundle result = new Bundle(); result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS, mSessionManager.getSessionStatus(sid).asBundle()); callback.onResult(result); } else { callback.onError("Failed to get session status, sid=" + sid, null); } } return (sessionStatus != null); }
Example #4
Source File: SampleMediaRouteProvider.java From android-MediaRouter with Apache License 2.0 | 6 votes |
private boolean handleGetSessionStatus(Intent intent, ControlRequestCallback callback) { String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID); MediaSessionStatus sessionStatus = mSessionManager.getSessionStatus(sid); if (callback != null) { if (sessionStatus != null) { Bundle result = new Bundle(); result.putBundle(MediaControlIntent.EXTRA_SESSION_STATUS, mSessionManager.getSessionStatus(sid).asBundle()); callback.onResult(result); } else { callback.onError("Failed to get session status, sid=" + sid, null); } } return (sessionStatus != null); }
Example #5
Source File: RemotePlayer.java From android-MediaRouter with Apache License 2.0 | 5 votes |
@Override public void onItemStatusChanged(Bundle data, String sessionId, MediaSessionStatus sessionStatus, String itemId, MediaItemStatus itemStatus) { logStatus("onItemStatusChanged", sessionId, sessionStatus, itemId, itemStatus); if (mCallback != null) { if (itemStatus.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_FINISHED) { mCallback.onCompletion(); } else if (itemStatus.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_ERROR) { mCallback.onError(); } } }
Example #6
Source File: SessionManager.java From V.FlyoutTest with MIT License | 5 votes |
MediaSessionStatus getSessionStatus(String sid) { int sessionState = (sid != null && sid.equals(mSessionId)) ? MediaSessionStatus.SESSION_STATE_ACTIVE : MediaSessionStatus.SESSION_STATE_INVALIDATED; return new MediaSessionStatus.Builder(sessionState) .setQueuePaused(mPaused) .build(); }
Example #7
Source File: RemotePlayer.java From V.FlyoutTest with MIT License | 5 votes |
private void logStatus(String message, String sessionId, MediaSessionStatus sessionStatus, String itemId, MediaItemStatus itemStatus) { if (DEBUG) { String result = ""; if (sessionId != null && sessionStatus != null) { result += "sessionId=" + sessionId + ", sessionStatus=" + sessionStatus; } if (itemId != null & itemStatus != null) { result += (result.isEmpty() ? "" : ", ") + "itemId=" + itemId + ", itemStatus=" + itemStatus; } Log.d(TAG, message + ": " + result); } }
Example #8
Source File: RemotePlayer.java From V.FlyoutTest with MIT License | 5 votes |
@Override public void onSessionStatusChanged(Bundle data, String sessionId, MediaSessionStatus sessionStatus) { logStatus("onSessionStatusChanged", sessionId, sessionStatus, null, null); if (mCallback != null) { mCallback.onPlaylistChanged(); } }
Example #9
Source File: RemotePlayer.java From V.FlyoutTest with MIT License | 5 votes |
@Override public void onItemStatusChanged(Bundle data, String sessionId, MediaSessionStatus sessionStatus, String itemId, MediaItemStatus itemStatus) { logStatus("onItemStatusChanged", sessionId, sessionStatus, itemId, itemStatus); if (mCallback != null) { if (itemStatus.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_FINISHED) { mCallback.onCompletion(); } else if (itemStatus.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_ERROR) { mCallback.onError(); } } }
Example #10
Source File: SessionManager.java From android-MediaRouter with Apache License 2.0 | 5 votes |
public MediaSessionStatus getSessionStatus(String sid) { int sessionState = (sid != null && sid.equals(mSessionId)) ? MediaSessionStatus.SESSION_STATE_ACTIVE : MediaSessionStatus.SESSION_STATE_INVALIDATED; return new MediaSessionStatus.Builder(sessionState) .setQueuePaused(mPaused) .build(); }
Example #11
Source File: RemotePlayer.java From android-MediaRouter with Apache License 2.0 | 5 votes |
private void logStatus(String message, String sessionId, MediaSessionStatus sessionStatus, String itemId, MediaItemStatus itemStatus) { if (DEBUG) { String result = ""; if (sessionId != null && sessionStatus != null) { result += "sessionId=" + sessionId + ", sessionStatus=" + sessionStatus; } if (itemId != null & itemStatus != null) { result += (result.isEmpty() ? "" : ", ") + "itemId=" + itemId + ", itemStatus=" + itemStatus; } Log.d(TAG, message + ": " + result); } }
Example #12
Source File: RemotePlayer.java From android-MediaRouter with Apache License 2.0 | 5 votes |
@Override public void onSessionStatusChanged(Bundle data, String sessionId, MediaSessionStatus sessionStatus) { logStatus("onSessionStatusChanged", sessionId, sessionStatus, null, null); if (mCallback != null) { mCallback.onPlaylistChanged(); } }
Example #13
Source File: DefaultMediaRouteController.java From 365browser with Apache License 2.0 | 5 votes |
@RemovableInRelease private void logMediaSessionStatus(Bundle data) { MediaSessionStatus status = MediaSessionStatus.fromBundle( data.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); int sessionState = status.getSessionState(); Log.d(TAG, "Session state after ending session: %s", sessionState); }
Example #14
Source File: DefaultMediaRouteController.java From 365browser with Apache License 2.0 | 5 votes |
private void processSessionStatusBundle(Bundle statusBundle) { MediaSessionStatus status = MediaSessionStatus.fromBundle( statusBundle.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); int sessionState = status.getSessionState(); // If no change do nothing if (sessionState == mSessionState) return; mSessionState = sessionState; switch (sessionState) { case MediaSessionStatus.SESSION_STATE_ACTIVE: if (mLocalVideoUri != null) { startPlayback(mPreferredTitle, mStartPositionMillis); } break; case MediaSessionStatus.SESSION_STATE_ENDED: case MediaSessionStatus.SESSION_STATE_INVALIDATED: for (UiListener listener : getUiListeners()) { listener.onPlaybackStateChanged(PlayerState.INVALIDATED); } if (getMediaStateListener() != null) { getMediaStateListener().onPlaybackStateChanged(PlayerState.INVALIDATED); } // Record the remaining time UMA first, otherwise the playback state will be cleared // in release(). recordRemainingTimeUMA(); // Set the current session id to null so we don't send the stop intent. mCurrentSessionId = null; release(); break; default: break; } }
Example #15
Source File: DefaultMediaRouteController.java From AndroidChromium with Apache License 2.0 | 5 votes |
@RemovableInRelease private void logMediaSessionStatus(Bundle data) { MediaSessionStatus status = MediaSessionStatus.fromBundle( data.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); int sessionState = status.getSessionState(); Log.d(TAG, "Session state after ending session: %s", sessionState); }
Example #16
Source File: DefaultMediaRouteController.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void processSessionStatusBundle(Bundle statusBundle) { MediaSessionStatus status = MediaSessionStatus.fromBundle( statusBundle.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); int sessionState = status.getSessionState(); // If no change do nothing if (sessionState == mSessionState) return; mSessionState = sessionState; switch (sessionState) { case MediaSessionStatus.SESSION_STATE_ACTIVE: if (mLocalVideoUri != null) { startPlayback(mPreferredTitle, mStartPositionMillis); } break; case MediaSessionStatus.SESSION_STATE_ENDED: case MediaSessionStatus.SESSION_STATE_INVALIDATED: for (UiListener listener : getUiListeners()) { listener.onPlaybackStateChanged(PlayerState.INVALIDATED); } if (getMediaStateListener() != null) { getMediaStateListener().onPlaybackStateChanged(PlayerState.INVALIDATED); } // Record the remaining time UMA first, otherwise the playback state will be cleared // in release(). recordRemainingTimeUMA(); // Set the current session id to null so we don't send the stop intent. mCurrentSessionId = null; release(); break; default: break; } }
Example #17
Source File: DefaultMediaRouteController.java From delion with Apache License 2.0 | 5 votes |
@RemovableInRelease private void logMediaSessionStatus(Bundle data) { MediaSessionStatus status = MediaSessionStatus.fromBundle( data.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); int sessionState = status.getSessionState(); Log.d(TAG, "Session state after ending session: %s", sessionState); }
Example #18
Source File: DefaultMediaRouteController.java From delion with Apache License 2.0 | 5 votes |
private void processSessionStatusBundle(Bundle statusBundle) { MediaSessionStatus status = MediaSessionStatus.fromBundle( statusBundle.getBundle(MediaControlIntent.EXTRA_SESSION_STATUS)); int sessionState = status.getSessionState(); // If no change do nothing if (sessionState == mSessionState) return; mSessionState = sessionState; switch (sessionState) { case MediaSessionStatus.SESSION_STATE_ACTIVE: if (mLocalVideoUri != null) { startPlayback(mPreferredTitle, mStartPositionMillis); } break; case MediaSessionStatus.SESSION_STATE_ENDED: case MediaSessionStatus.SESSION_STATE_INVALIDATED: for (UiListener listener : getUiListeners()) { listener.onPlaybackStateChanged(PlayerState.INVALIDATED); } if (getMediaStateListener() != null) { getMediaStateListener().onPlaybackStateChanged(PlayerState.INVALIDATED); } // Record the remaining time UMA first, otherwise the playback state will be cleared // in release(). recordRemainingTimeUMA(); // Set the current session id to null so we don't send the stop intent. mCurrentSessionId = null; release(); break; default: break; } }
Example #19
Source File: MediaSessionStatusAssert.java From assertj-android with Apache License 2.0 | 4 votes |
public MediaSessionStatusAssert(MediaSessionStatus actual) { super(actual, MediaSessionStatusAssert.class); }
Example #20
Source File: DefaultMediaRouteController.java From 365browser with Apache License 2.0 | 4 votes |
private void configureNewSession(Bundle data) { mCurrentSessionId = data.getString(MediaControlIntent.EXTRA_SESSION_ID); mSessionState = MediaSessionStatus.SESSION_STATE_INVALIDATED; Log.d(TAG, "Got a session id: %s", mCurrentSessionId); }
Example #21
Source File: DefaultMediaRouteController.java From AndroidChromium with Apache License 2.0 | 4 votes |
private void configureNewSession(Bundle data) { mCurrentSessionId = data.getString(MediaControlIntent.EXTRA_SESSION_ID); mSessionState = MediaSessionStatus.SESSION_STATE_INVALIDATED; Log.d(TAG, "Got a session id: %s", mCurrentSessionId); }
Example #22
Source File: DefaultMediaRouteController.java From delion with Apache License 2.0 | 4 votes |
private void configureNewSession(Bundle data) { mCurrentSessionId = data.getString(MediaControlIntent.EXTRA_SESSION_ID); mSessionState = MediaSessionStatus.SESSION_STATE_INVALIDATED; Log.d(TAG, "Got a session id: %s", mCurrentSessionId); }