mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add getMediaMetadata to Player and SimpleExoPlayer.
PiperOrigin-RevId: 366240390
This commit is contained in:
parent
a317746eff
commit
3d3c90b89d
6 changed files with 44 additions and 0 deletions
|
|
@ -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;
|
||||||
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;
|
||||||
|
|
@ -566,6 +567,12 @@ public final class CastPlayer extends BasePlayer {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MediaMetadata getMediaMetadata() {
|
||||||
|
// CastPlayer does not currently support metadata.
|
||||||
|
return MediaMetadata.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timeline getCurrentTimeline() {
|
public Timeline getCurrentTimeline() {
|
||||||
return currentTimeline;
|
return currentTimeline;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -1749,6 +1750,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.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -974,6 +974,12 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
return playbackInfo.staticMetadata;
|
return playbackInfo.staticMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MediaMetadata getMediaMetadata() {
|
||||||
|
// Unsupported operation.
|
||||||
|
return MediaMetadata.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timeline getCurrentTimeline() {
|
public Timeline getCurrentTimeline() {
|
||||||
return playbackInfo.timeline;
|
return playbackInfo.timeline;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
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);
|
||||||
|
|
@ -1620,6 +1622,11 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
return player.getCurrentStaticMetadata();
|
return player.getCurrentStaticMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MediaMetadata getMediaMetadata() {
|
||||||
|
return currentMediaMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timeline getCurrentTimeline() {
|
public Timeline getCurrentTimeline() {
|
||||||
verifyApplicationThread();
|
verifyApplicationThread();
|
||||||
|
|
@ -2275,6 +2282,12 @@ public class SimpleExoPlayer extends BasePlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMediaItemTransition(
|
||||||
|
@Nullable MediaItem mediaItem, @MediaItemTransitionReason int reason) {
|
||||||
|
currentMediaMetadata = mediaItem == null ? MediaMetadata.EMPTY : mediaItem.mediaMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
||||||
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;
|
||||||
|
|
@ -356,6 +357,11 @@ public class StubExoPlayer extends BasePlayer implements ExoPlayer {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MediaMetadata getMediaMetadata() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timeline getCurrentTimeline() {
|
public Timeline getCurrentTimeline() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue