Example usage for android.media RemoteControlClient PLAYSTATE_PLAYING

List of usage examples for android.media RemoteControlClient PLAYSTATE_PLAYING

Introduction

In this page you can find the example usage for android.media RemoteControlClient PLAYSTATE_PLAYING.

Prototype

int PLAYSTATE_PLAYING

To view the source code for android.media RemoteControlClient PLAYSTATE_PLAYING.

Click Source Link

Document

Playback state of a RemoteControlClient which is playing media.

Usage

From source file:air.com.snagfilms.cast.chromecast.VideoChromeCastManager.java

@SuppressLint("InlinedApi")
private void updateRemoteControl(boolean playing) {
    if (!isFeatureEnabled(FEATURE_LOCKSCREEN)) {
        return;/*from w  w  w  .  ja  v  a2 s .  co  m*/
    }
    if (!isConnected()) {
        removeRemoteControlClient();
        return;
    }
    try {
        if (null == mRemoteControlClientCompat && playing) {
            setUpRemoteControl(getRemoteMediaInformation());
        }
        if (mRemoteControlClientCompat != null) {
            int playState = isRemoteStreamLive() ? RemoteControlClient.PLAYSTATE_BUFFERING
                    : RemoteControlClient.PLAYSTATE_PLAYING;
            mRemoteControlClientCompat
                    .setPlaybackState(playing ? playState : RemoteControlClient.PLAYSTATE_PAUSED);
        }
    } catch (TransientNetworkDisconnectionException e) {
        Log.e(TAG, "Failed to setup RCC due to network issues", e);
    } catch (NoConnectionException e) {
        Log.e(TAG, "Failed to setup RCC due to network issues", e);
    }
}

From source file:com.google.sample.castcompanionlibrary.cast.VideoCastManager.java

@SuppressLint("InlinedApi")
private void updateRemoteControl(boolean playing) {
    LOGD(TAG, "updateRemoteControl()");
    if (!isFeatureEnabled(FEATURE_LOCKSCREEN)) {
        return;//  w  w w .j a v  a2 s . co m
    }
    if (!isConnected()) {
        return;
    }
    try {
        if (null == mRemoteControlClientCompat && playing) {
            setUpRemoteControl(getRemoteMediaInformation());
        }
        if (mRemoteControlClientCompat != null) {
            int playState = isRemoteStreamLive() ? RemoteControlClient.PLAYSTATE_BUFFERING
                    : RemoteControlClient.PLAYSTATE_PLAYING;
            mRemoteControlClientCompat
                    .setPlaybackState(playing ? playState : RemoteControlClient.PLAYSTATE_PAUSED);
        }
    } catch (TransientNetworkDisconnectionException e) {
        LOGE(TAG, "Failed to setup RCC due to network issues", e);
    } catch (NoConnectionException e) {
        LOGE(TAG, "Failed to setup RCC due to network issues", e);
    }
}

From source file:com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.java

@SuppressLint("InlinedApi")
private void setUpRemoteControl(final MediaInfo info) {
    if (!isFeatureEnabled(BaseCastManager.FEATURE_LOCKSCREEN)) {
        return;/*from  w  w  w. j a v a2  s .  c  om*/
    }
    LOGD(TAG, "setUpRemoteControl() was called");
    mAudioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);

    mMediaEventReceiver = new ComponentName(mContext, VideoIntentReceiver.class.getName());
    mAudioManager.registerMediaButtonEventReceiver(mMediaEventReceiver);

    if (mRemoteControlClientCompat == null) {
        Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
        intent.setComponent(mMediaButtonReceiverComponent);
        mRemoteControlClientCompat = new RemoteControlClientCompat(
                PendingIntent.getBroadcast(mContext, 0, intent, 0));
        RemoteControlHelper.registerRemoteControlClient(mAudioManager, mRemoteControlClientCompat);
    }
    mRemoteControlClientCompat.addToMediaRouter(mMediaRouter);
    mRemoteControlClientCompat.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE);
    if (info == null) {
        mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
        return;
    } else {
        mRemoteControlClientCompat.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
    }

    // Update the remote control's image
    updateLockScreenImage(info);

    // update the remote control's metadata
    updateLockScreenMetadata();
}

From source file:com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControl(boolean playing) {
    if (!isFeatureEnabled(FEATURE_LOCKSCREEN)) {
        return;//from   w w  w  .j a  va2 s .  c om
    }
    if (!isConnected()) {
        return;
    }
    try {
        if ((mRemoteControlClientCompat == null) && playing) {
            setUpRemoteControl(getRemoteMediaInformation());
        }
        if (mRemoteControlClientCompat != null) {
            int playState = isRemoteStreamLive() ? RemoteControlClient.PLAYSTATE_BUFFERING
                    : RemoteControlClient.PLAYSTATE_PLAYING;
            mRemoteControlClientCompat
                    .setPlaybackState(playing ? playState : RemoteControlClient.PLAYSTATE_PAUSED);
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
        LOGE(TAG, "Failed to set up RCC due to network issues", e);
    }
}