Java Code Examples for android.support.v7.media.MediaSessionStatus#SESSION_STATE_ACTIVE

The following examples show how to use android.support.v7.media.MediaSessionStatus#SESSION_STATE_ACTIVE . 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 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 3
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 4
Source File: SessionManager.java    From android-MediaRouter with Apache License 2.0 5 votes vote down vote up
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 5
Source File: SessionManager.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
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();
}