mirror of
https://github.com/androidx/media.git
synced 2025-05-03 21:57:46 +08:00
Add mediaId to PlaybackStateCompat extras
It provides a way to associate PlaybackState with the current media item. Startblock: <unknown commit> is submitted PiperOrigin-RevId: 368354775
This commit is contained in:
parent
0b3a3e6aa8
commit
1ad56e96c2
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.google.android.exoplayer2.ext.mediasession;
|
||||
|
||||
import static androidx.media.utils.MediaConstants.PLAYBACK_STATE_EXTRAS_KEY_MEDIA_ID;
|
||||
import static com.google.android.exoplayer2.Player.EVENT_IS_PLAYING_CHANGED;
|
||||
import static com.google.android.exoplayer2.Player.EVENT_PLAYBACK_PARAMETERS_CHANGED;
|
||||
import static com.google.android.exoplayer2.Player.EVENT_PLAYBACK_STATE_CHANGED;
|
||||
@ -45,6 +46,7 @@ import com.google.android.exoplayer2.ControlDispatcher;
|
||||
import com.google.android.exoplayer2.DefaultControlDispatcher;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.Timeline;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
@ -783,6 +785,10 @@ public final class MediaSessionConnector {
|
||||
float playbackSpeed = player.getPlaybackParameters().speed;
|
||||
extras.putFloat(EXTRAS_SPEED, playbackSpeed);
|
||||
float sessionPlaybackSpeed = player.isPlaying() ? playbackSpeed : 0f;
|
||||
@Nullable MediaItem currentMediaItem = player.getCurrentMediaItem();
|
||||
if (currentMediaItem != null && !MediaItem.DEFAULT_MEDIA_ID.equals(currentMediaItem.mediaId)) {
|
||||
extras.putString(PLAYBACK_STATE_EXTRAS_KEY_MEDIA_ID, currentMediaItem.mediaId);
|
||||
}
|
||||
builder
|
||||
.setActions(buildPrepareActions() | buildPlaybackActions(player))
|
||||
.setActiveQueueItemId(activeQueueItemId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user