Thursday, 31 October 2019

android keeping Cast Volume notification in pause state

I noticed that when setting a playback state to PlaybackStateCompat.STATE_PLAYING, I get the cast volume control as the main one. So when the user clicks on the phone volume control buttons, the cast volume changes. However, when the playback state is PlaybackStateCompat.STATE_PAUSED, when the user clicks on the volume button, the main volume notification is the default media one and the Cast volume is still in the list, but it is not the main one. The following code is how things are initialised:

mMediaSession = new MediaSessionCompat(getApplicationContext(), tag);
        final PlaybackStateCompat.Builder builder = new PlaybackStateCompat.Builder();
        builder.setState(PlaybackStateCompat.STATE_PAUSED,
                PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);
        mMediaSession.setPlaybackState(builder.build());
        mMediaSession.setActive(true);
        mMediaSession.setPlaybackToRemote(volumeProvider);

I would like to have the Cast volume control to be the main one in PAUSED state. How to achieve that?

Thanks!



from android keeping Cast Volume notification in pause state

No comments:

Post a Comment