MetadataRenderer
@UnstableApi
public final class MetadataRenderer extends BaseRenderer implements Handler.Callback
| java.lang.Object | ||
| ↳ | androidx.media3.exoplayer.BaseRenderer | |
| ↳ | androidx.media3.exoplayer.metadata.MetadataRenderer |
A renderer for metadata.
The renderer can be configured to render metadata as soon as they are available using MetadataRenderer.
Summary
Public constructors |
|---|
MetadataRenderer(MetadataOutput output, @Nullable Looper outputLooper)Creates an instance that uses |
MetadataRenderer(Creates an instance. |
MetadataRenderer(Creates an instance. |
Public methods |
|
|---|---|
String |
getName()Returns the name of this renderer, for logging and debugging purposes. |
boolean |
handleMessage(Message msg) |
boolean |
isEnded()Whether the renderer is ready for the |
boolean |
isReady()Whether the renderer is able to immediately render media from the current position. |
void |
render(long positionUs, long elapsedRealtimeUs)Incrementally renders the |
int |
Returns the extent to which the |
Protected methods |
|
|---|---|
void |
Called when the renderer is disabled. |
void |
onPositionReset(Called when the position is reset. |
void |
onStreamChanged(Called when the renderer's stream has changed. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited fields |
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Public constructors
MetadataRenderer
public MetadataRenderer(MetadataOutput output, @Nullable Looper outputLooper)
Creates an instance that uses DEFAULT to create MetadataDecoder instances.
| Parameters | |
|---|---|
MetadataOutput output |
The output. |
@Nullable Looper outputLooper |
The looper associated with the thread on which the output should be called. If the output makes use of standard Android UI components, then this should normally be the looper associated with the application's main thread, which can be obtained using |
MetadataRenderer
public MetadataRenderer(
MetadataOutput output,
@Nullable Looper outputLooper,
MetadataDecoderFactory decoderFactory
)
Creates an instance.
| Parameters | |
|---|---|
MetadataOutput output |
The output. |
@Nullable Looper outputLooper |
The looper associated with the thread on which the output should be called. If the output makes use of standard Android UI components, then this should normally be the looper associated with the application's main thread, which can be obtained using |
MetadataDecoderFactory decoderFactory |
A factory from which to obtain |
MetadataRenderer
public MetadataRenderer(
MetadataOutput output,
@Nullable Looper outputLooper,
MetadataDecoderFactory decoderFactory,
boolean outputMetadataEarly
)
Creates an instance.
| Parameters | |
|---|---|
MetadataOutput output |
The output. |
@Nullable Looper outputLooper |
The looper associated with the thread on which the output should be called. If the output makes use of standard Android UI components, then this should normally be the looper associated with the application's main thread, which can be obtained using |
MetadataDecoderFactory decoderFactory |
A factory from which to obtain |
boolean outputMetadataEarly |
Whether the renderer outputs metadata early. When |
Public methods
getName
public String getName()
Returns the name of this renderer, for logging and debugging purposes. Should typically be the renderer's (un-obfuscated) class name.
| Returns | |
|---|---|
String |
The name of this renderer. |
isEnded
public boolean isEnded()
Whether the renderer is ready for the ExoPlayer instance to transition to STATE_ENDED. The player will make this transition as soon as true is returned by all of its renderers.
This method may be called when the renderer is in the following states: STATE_ENABLED, STATE_STARTED.
| Returns | |
|---|---|
boolean |
Whether the renderer is ready for the player to transition to the ended state. |
isReady
public boolean isReady()
Whether the renderer is able to immediately render media from the current position.
If the renderer is in the STATE_STARTED state then returning true indicates that the renderer has everything that it needs to continue playback. Returning false indicates that the player should pause until the renderer is ready.
If the renderer is in the STATE_ENABLED state then returning true indicates that the renderer is ready for playback to be started. Returning false indicates that it is not.
This method may be called when the renderer is in the following states: STATE_ENABLED, STATE_STARTED.
| Returns | |
|---|---|
boolean |
Whether the renderer is ready to render media. |
render
public void render(long positionUs, long elapsedRealtimeUs)
Incrementally renders the SampleStream.
If the renderer is in the STATE_ENABLED state then each call to this method will do work toward being ready to render the SampleStream when the renderer is started. If the renderer is in the STATE_STARTED state then calls to this method will render the SampleStream in sync with the specified media positions.
The renderer may also render the very start of the media at the current position (e.g. the first frame of a video stream) while still in the STATE_ENABLED state, unless it's the initial start of the media after calling enable with
mayRenderStartOfStream set to false.
This method should return quickly, and should not block if the renderer is unable to make useful progress.
This method may be called when the renderer is in the following states: STATE_ENABLED, STATE_STARTED.
| Parameters | |
|---|---|
long positionUs |
The current media time in microseconds, measured at the start of the current iteration of the rendering loop. |
long elapsedRealtimeUs |
|
| Throws | |
|---|---|
androidx.media3.exoplayer.ExoPlaybackException |
If an error occurs. |
supportsFormat
@RendererCapabilities.Capabilities
public int supportsFormat(Format format)
Returns the extent to which the Renderer supports a given format.
| Parameters | |
|---|---|
Format format |
The format. |
| Returns | |
|---|---|
int |
The |
| Throws | |
|---|---|
androidx.media3.exoplayer.ExoPlaybackException |
If an error occurs. |
Protected methods
onDisabled
protected void onDisabled()
Called when the renderer is disabled.
The default implementation is a no-op.
onPositionReset
protected void onPositionReset(
long positionUs,
boolean joining,
boolean sampleStreamIsResetToKeyFrame
)
Called when the position is reset. This occurs when the renderer is enabled after onStreamChanged has been called, and also when a position discontinuity is encountered.
After a position reset, the renderer's SampleStream is guaranteed to provide samples starting from a key frame if sampleStreamIsResetToKeyFrame is true.
sampleStreamIsResetToKeyFrame is guaranteed to be true unless the implementation overrides supportsResetPositionWithoutKeyFrameReset to return
true.
The default implementation is a no-op.
| Parameters | |
|---|---|
long positionUs |
The new playback position in microseconds. |
boolean joining |
Whether this renderer is being enabled to join an ongoing playback. |
boolean sampleStreamIsResetToKeyFrame |
Whether the renderer's |
| Throws | |
|---|---|
androidx.media3.exoplayer.ExoPlaybackException |
If an error occurs. |
onStreamChanged
protected void onStreamChanged(
Format[] formats,
long startPositionUs,
long offsetUs,
MediaSource.MediaPeriodId mediaPeriodId
)
Called when the renderer's stream has changed. This occurs when the renderer is enabled after onEnabled has been called, and also when the stream has been replaced whilst the renderer is enabled or started.
The default implementation is a no-op.
| Parameters | |
|---|---|
Format[] formats |
The enabled formats. |
long startPositionUs |
The start position of the new stream in renderer time (microseconds). |
long offsetUs |
The offset that will be added to the timestamps of buffers read via |
MediaSource.MediaPeriodId mediaPeriodId |
The |
| Throws | |
|---|---|
androidx.media3.exoplayer.ExoPlaybackException |
If an error occurs. |