Search in sources :

Example 1 with PlayerState

use of org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState in project AndroidChromium by JackyAndroid.

the class AbstractMediaRouteController method updateState.

protected void updateState(int state) {
    Log.d(TAG, "updateState oldState: %s player state: %s", mRemotePlayerState, state);
    PlayerState oldState = mRemotePlayerState;
    setPlayerStateForMediaItemState(state);
    Log.d(TAG, "updateState newState: %s", mRemotePlayerState);
    if (oldState != mRemotePlayerState) {
        setDisplayedPlayerState(mRemotePlayerState);
        switch(mRemotePlayerState) {
            case PLAYING:
                onCasting();
                break;
            case PAUSED:
                onCasting();
                break;
            case FINISHED:
                release();
                break;
            case INVALIDATED:
                clearItemState();
                break;
            case ERROR:
                sendErrorToListeners(CastMediaControlIntent.ERROR_CODE_REQUEST_FAILED);
                release();
                break;
            default:
                break;
        }
    }
}
Also used : PlayerState(org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState)

Example 2 with PlayerState

use of org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState in project AndroidChromium by JackyAndroid.

the class AbstractMediaRouteController method setPlayerStateForMediaItemState.

@VisibleForTesting
void setPlayerStateForMediaItemState(int state) {
    PlayerState playerState = PlayerState.STOPPED;
    switch(state) {
        case MediaItemStatus.PLAYBACK_STATE_BUFFERING:
            playerState = PlayerState.LOADING;
            break;
        case MediaItemStatus.PLAYBACK_STATE_CANCELED:
            playerState = PlayerState.FINISHED;
            break;
        case MediaItemStatus.PLAYBACK_STATE_ERROR:
            playerState = PlayerState.ERROR;
            break;
        case MediaItemStatus.PLAYBACK_STATE_FINISHED:
            playerState = PlayerState.FINISHED;
            break;
        case MediaItemStatus.PLAYBACK_STATE_INVALIDATED:
            playerState = PlayerState.INVALIDATED;
            break;
        case MediaItemStatus.PLAYBACK_STATE_PAUSED:
            if (isAtEndOfVideo(getPosition(), getDuration())) {
                playerState = PlayerState.FINISHED;
            } else {
                playerState = PlayerState.PAUSED;
            }
            break;
        case MediaItemStatus.PLAYBACK_STATE_PENDING:
            playerState = PlayerState.PAUSED;
            break;
        case MediaItemStatus.PLAYBACK_STATE_PLAYING:
            playerState = PlayerState.PLAYING;
            break;
        default:
            break;
    }
    mRemotePlayerState = playerState;
}
Also used : PlayerState(org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState) VisibleForTesting(org.chromium.base.VisibleForTesting)

Aggregations

PlayerState (org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState)2 VisibleForTesting (org.chromium.base.VisibleForTesting)1