Java Code Examples for android.support.v7.media.MediaSessionStatus#getSessionState()

The following examples show how to use android.support.v7.media.MediaSessionStatus#getSessionState() . 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: DefaultMediaRouteController.java    From delion with Apache License 2.0 5 votes vote down vote up
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 2
Source File: DefaultMediaRouteController.java    From delion with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: DefaultMediaRouteController.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
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 4
Source File: DefaultMediaRouteController.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: DefaultMediaRouteController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
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 6
Source File: DefaultMediaRouteController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@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);
}