Commit 3d3c90b8 by samrobinson Committed by Oliver Woodman

Add getMediaMetadata to Player and SimpleExoPlayer.

PiperOrigin-RevId: 366240390
parent a317746e
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
* Core: * Core:
* Move `getRendererCount` and `getRendererType` methods from `Player` to * Move `getRendererCount` and `getRendererType` methods from `Player` to
`ExoPlayer`. `ExoPlayer`.
* Add `getMediaMetadata` to `Player` interface.
* Reset playback speed when live playback speed control becomes unused * Reset playback speed when live playback speed control becomes unused
([#8664](https://github.com/google/ExoPlayer/issues/8664)). ([#8664](https://github.com/google/ExoPlayer/issues/8664)).
* Fix playback position issue when re-preparing playback after a * Fix playback position issue when re-preparing playback after a
......
...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.C; ...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
...@@ -567,6 +568,12 @@ public final class CastPlayer extends BasePlayer { ...@@ -567,6 +568,12 @@ public final class CastPlayer extends BasePlayer {
} }
@Override @Override
public MediaMetadata getMediaMetadata() {
// CastPlayer does not currently support metadata.
return MediaMetadata.EMPTY;
}
@Override
public Timeline getCurrentTimeline() { public Timeline getCurrentTimeline() {
return currentTimeline; return currentTimeline;
} }
......
...@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.text.Cue; ...@@ -35,6 +35,7 @@ import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.text.TextOutput;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.util.ExoFlags; import com.google.android.exoplayer2.util.ExoFlags;
import com.google.android.exoplayer2.util.StableApiCandidate;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener; import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoListener; import com.google.android.exoplayer2.video.VideoListener;
...@@ -1750,6 +1751,16 @@ public interface Player { ...@@ -1750,6 +1751,16 @@ public interface Player {
List<Metadata> getCurrentStaticMetadata(); List<Metadata> getCurrentStaticMetadata();
/** /**
* Returns the current combined {@link MediaMetadata}, or {@link MediaMetadata#EMPTY} if not
* supported.
*
* <p>This {@link MediaMetadata} is a combination of the {@link MediaItem#mediaMetadata} and the
* static and dynamic metadata sourced from {@link EventListener#onStaticMetadataChanged(List)}
* and {@link MetadataOutput#onMetadata(Metadata)}.
*/
MediaMetadata getMediaMetadata();
/**
* Returns the current manifest. The type depends on the type of media being played. May be null. * Returns the current manifest. The type depends on the type of media being played. May be null.
*/ */
@Nullable @Nullable
......
...@@ -975,6 +975,12 @@ import java.util.concurrent.CopyOnWriteArraySet; ...@@ -975,6 +975,12 @@ import java.util.concurrent.CopyOnWriteArraySet;
} }
@Override @Override
public MediaMetadata getMediaMetadata() {
// Unsupported operation.
return MediaMetadata.EMPTY;
}
@Override
public Timeline getCurrentTimeline() { public Timeline getCurrentTimeline() {
return playbackInfo.timeline; return playbackInfo.timeline;
} }
......
...@@ -609,6 +609,7 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -609,6 +609,7 @@ public class SimpleExoPlayer extends BasePlayer
private boolean isPriorityTaskManagerRegistered; private boolean isPriorityTaskManagerRegistered;
private boolean playerReleased; private boolean playerReleased;
private DeviceInfo deviceInfo; private DeviceInfo deviceInfo;
private MediaMetadata currentMediaMetadata;
/** @deprecated Use the {@link Builder} and pass it to {@link #SimpleExoPlayer(Builder)}. */ /** @deprecated Use the {@link Builder} and pass it to {@link #SimpleExoPlayer(Builder)}. */
@Deprecated @Deprecated
...@@ -716,6 +717,7 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -716,6 +717,7 @@ public class SimpleExoPlayer extends BasePlayer
wifiLockManager = new WifiLockManager(builder.context); wifiLockManager = new WifiLockManager(builder.context);
wifiLockManager.setEnabled(builder.wakeMode == C.WAKE_MODE_NETWORK); wifiLockManager.setEnabled(builder.wakeMode == C.WAKE_MODE_NETWORK);
deviceInfo = createDeviceInfo(streamVolumeManager); deviceInfo = createDeviceInfo(streamVolumeManager);
currentMediaMetadata = MediaMetadata.EMPTY;
sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId); sendRendererMessage(C.TRACK_TYPE_AUDIO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId);
sendRendererMessage(C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId); sendRendererMessage(C.TRACK_TYPE_VIDEO, Renderer.MSG_SET_AUDIO_SESSION_ID, audioSessionId);
...@@ -1621,6 +1623,11 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -1621,6 +1623,11 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public MediaMetadata getMediaMetadata() {
return currentMediaMetadata;
}
@Override
public Timeline getCurrentTimeline() { public Timeline getCurrentTimeline() {
verifyApplicationThread(); verifyApplicationThread();
return player.getCurrentTimeline(); return player.getCurrentTimeline();
...@@ -2276,6 +2283,12 @@ public class SimpleExoPlayer extends BasePlayer ...@@ -2276,6 +2283,12 @@ public class SimpleExoPlayer extends BasePlayer
} }
@Override @Override
public void onMediaItemTransition(
@Nullable MediaItem mediaItem, @MediaItemTransitionReason int reason) {
currentMediaMetadata = mediaItem == null ? MediaMetadata.EMPTY : mediaItem.mediaMetadata;
}
@Override
public void onPlaybackStateChanged(@State int playbackState) { public void onPlaybackStateChanged(@State int playbackState) {
updateWakeAndWifiLock(); updateWakeAndWifiLock();
} }
......
...@@ -21,6 +21,7 @@ import com.google.android.exoplayer2.BasePlayer; ...@@ -21,6 +21,7 @@ import com.google.android.exoplayer2.BasePlayer;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.PlayerMessage; import com.google.android.exoplayer2.PlayerMessage;
...@@ -357,6 +358,11 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer { ...@@ -357,6 +358,11 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
} }
@Override @Override
public MediaMetadata getMediaMetadata() {
throw new UnsupportedOperationException();
}
@Override
public Timeline getCurrentTimeline() { public Timeline getCurrentTimeline() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
......
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