Commit 44ad4774 by bachinger Committed by Oliver Woodman

Never set null as a session meta data object.

Issue: #5810
PiperOrigin-RevId: 245745646
parent 1fb128df
......@@ -146,6 +146,9 @@ public final class MediaSessionConnector {
private static final int EDITOR_MEDIA_SESSION_FLAGS =
BASE_MEDIA_SESSION_FLAGS | MediaSessionCompat.FLAG_HANDLES_QUEUE_COMMANDS;
private static final MediaMetadataCompat METADATA_EMPTY =
new MediaMetadataCompat.Builder().build();
/** Receiver of media commands sent by a media controller. */
public interface CommandReceiver {
/**
......@@ -639,8 +642,8 @@ public final class MediaSessionConnector {
MediaMetadataCompat metadata =
mediaMetadataProvider != null && player != null
? mediaMetadataProvider.getMetadata(player)
: null;
mediaSession.setMetadata(metadata);
: METADATA_EMPTY;
mediaSession.setMetadata(metadata != null ? metadata : METADATA_EMPTY);
}
/**
......@@ -888,7 +891,7 @@ public final class MediaSessionConnector {
@Override
public MediaMetadataCompat getMetadata(Player player) {
if (player.getCurrentTimeline().isEmpty()) {
return null;
return METADATA_EMPTY;
}
MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
if (player.isPlayingAd()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment