Set Session to active

This commit is contained in:
tzugen 2021-04-22 11:47:35 +02:00
parent 205f477b43
commit e6135dc21a
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 4 additions and 0 deletions

View File

@ -584,6 +584,7 @@ public class MediaPlayerService extends Service
Util.getMinDisplayMetric(context), true
);
metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, -1L);
metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.getArtist());
metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.getArtist());
metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.getAlbum());
@ -604,6 +605,9 @@ public class MediaPlayerService extends Service
// If we set the playback position correctly, we can get a nice seek bar :)
playbackState.setState(state, PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0F);
// Set Active state
mediaSession.setActive(playerState == STARTED);
// Save the playback state
mediaSession.setPlaybackState(playbackState.build());
}