T
- The type of the metadata.public final class MetadataTrackRenderer<T> extends SampleSourceTrackRenderer implements Handler.Callback
TrackRenderer
for metadata embedded in a media stream.Modifier and Type | Class and Description |
---|---|
static interface |
MetadataTrackRenderer.MetadataRenderer<T>
An interface for components that process metadata.
|
END_OF_TRACK_US, MATCH_LONGEST_US, STATE_ENABLED, STATE_PREPARED, STATE_RELEASED, STATE_STARTED, STATE_UNPREPARED, UNKNOWN_TIME_US
Constructor and Description |
---|
MetadataTrackRenderer(SampleSource source,
MetadataParser<T> metadataParser,
MetadataTrackRenderer.MetadataRenderer<T> metadataRenderer,
Looper metadataRendererLooper) |
Modifier and Type | Method and Description |
---|---|
protected void |
doSomeWork(long positionUs,
long elapsedRealtimeUs,
boolean sourceIsReady)
|
protected long |
getBufferedPositionUs()
Returns an estimate of the absolute position in microseconds up to which data is buffered.
|
boolean |
handleMessage(Message msg) |
protected boolean |
handlesTrack(MediaFormat mediaFormat)
Returns whether this renderer is capable of handling the provided track.
|
protected boolean |
isEnded()
Whether the renderer is ready for the
ExoPlayer instance to transition to
ExoPlayer.STATE_ENDED . |
protected boolean |
isReady()
Whether the renderer is able to immediately render media from the current position.
|
protected void |
onDisabled()
Called when the renderer is disabled.
|
protected void |
onDiscontinuity(long positionUs)
Invoked when a discontinuity is encountered.
|
doPrepare, doSomeWork, getDurationUs, getFormat, getTrackCount, maybeThrowError, onEnabled, onReleased, readSource, seekTo, shiftInputPosition
getMediaClock, getState, handleMessage, onStarted, onStopped
public MetadataTrackRenderer(SampleSource source, MetadataParser<T> metadataParser, MetadataTrackRenderer.MetadataRenderer<T> metadataRenderer, Looper metadataRendererLooper)
source
- A source from which samples containing metadata can be read.metadataParser
- A parser for parsing the metadata.metadataRenderer
- The metadata renderer to receive the parsed metadata.metadataRendererLooper
- The looper associated with the thread on which metadataRenderer
should be invoked. If the renderer makes use of standard Android UI components, then this
should normally be the looper associated with the applications' main thread, which can be
obtained using ContextWrapper.getMainLooper()
. Null may be passed if the
renderer should be invoked directly on the player's internal rendering thread.protected boolean handlesTrack(MediaFormat mediaFormat)
SampleSourceTrackRenderer
handlesTrack
in class SampleSourceTrackRenderer
mediaFormat
- The format of the track.protected void onDiscontinuity(long positionUs)
SampleSourceTrackRenderer
onDiscontinuity
in class SampleSourceTrackRenderer
positionUs
- The playback position after the discontinuity, or the position at which
the renderer is being enabled.protected void doSomeWork(long positionUs, long elapsedRealtimeUs, boolean sourceIsReady) throws ExoPlaybackException
SampleSourceTrackRenderer
doSomeWork
in class SampleSourceTrackRenderer
positionUs
- The current media time in microseconds, measured at the start of the
current iteration of the rendering loop.elapsedRealtimeUs
- SystemClock.elapsedRealtime()
in microseconds,
measured at the start of the current iteration of the rendering loop.sourceIsReady
- The result of the most recent call to
SampleSource.SampleSourceReader.continueBuffering(int, long)
.ExoPlaybackException
- If an error occurs.protected void onDisabled() throws ExoPlaybackException
TrackRenderer
The default implementation is a no-op.
onDisabled
in class SampleSourceTrackRenderer
ExoPlaybackException
- If an error occurs.protected long getBufferedPositionUs()
TrackRenderer
This method may be called when the renderer is in the following states:
TrackRenderer.STATE_ENABLED
, TrackRenderer.STATE_STARTED
getBufferedPositionUs
in class SampleSourceTrackRenderer
TrackRenderer.END_OF_TRACK_US
if the track is fully buffered, or TrackRenderer.UNKNOWN_TIME_US
if
no estimate is available.protected boolean isEnded()
TrackRenderer
ExoPlayer
instance to transition to
ExoPlayer.STATE_ENDED
. The player will make this transition as soon as true
is
returned by all of its TrackRenderer
s.
This method may be called when the renderer is in the following states:
TrackRenderer.STATE_ENABLED
, TrackRenderer.STATE_STARTED
isEnded
in class TrackRenderer
protected boolean isReady()
TrackRenderer
If the renderer is in the TrackRenderer.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 TrackRenderer.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:
TrackRenderer.STATE_ENABLED
, TrackRenderer.STATE_STARTED
isReady
in class TrackRenderer
public boolean handleMessage(Message msg)
handleMessage
in interface Handler.Callback