public interface MediaPeriod extends SequenceableLoader
Modifier and Type | Interface and Description |
---|---|
static interface |
MediaPeriod.Callback
A callback to be notified of
MediaPeriod events. |
Modifier and Type | Method and Description |
---|---|
long |
getBufferedPositionUs()
Returns an estimate of the position up to which data is buffered for the enabled tracks.
|
TrackGroupArray |
getTrackGroups()
Returns the
TrackGroup s exposed by the period. |
void |
maybeThrowPrepareError()
Throws an error that's preventing the period from becoming prepared.
|
void |
prepare(MediaPeriod.Callback callback)
Prepares this media period asynchronously.
|
long |
readDiscontinuity()
Attempts to read a discontinuity.
|
long |
seekToUs(long positionUs)
Attempts to seek to the specified position in microseconds.
|
long |
selectTracks(TrackSelection[] selections,
boolean[] mayRetainStreamFlags,
SampleStream[] streams,
boolean[] streamResetFlags,
long positionUs)
Performs a track selection.
|
continueLoading, getNextLoadPositionUs
void prepare(MediaPeriod.Callback callback)
callback.onPrepared
is called when preparation completes. If preparation fails,
maybeThrowPrepareError()
will throw an IOException
.
callback
- Callback to receive updates from this period, including being notified when
preparation completes.void maybeThrowPrepareError() throws IOException
This method should only be called before the period has completed preparation.
IOException
- The underlying error.TrackGroupArray getTrackGroups()
TrackGroup
s exposed by the period.
This method should only be called after the period has been prepared.
TrackGroup
s.long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams, boolean[] streamResetFlags, long positionUs)
The call receives track selections
for each renderer, mayRetainStreamFlags
indicating whether the existing SampleStream
can be retained for each selection, and
the existing stream
s themselves. The call will update streams
to reflect the
provided selections, clearing, setting and replacing entries as required. If an existing sample
stream is retained but with the requirement that the consuming renderer be reset, then the
corresponding flag in streamResetFlags
will be set to true. This flag will also be set
if a new sample stream is created.
This method should only be called after the period has been prepared.
selections
- The renderer track selections.mayRetainStreamFlags
- Flags indicating whether the existing sample stream can be retained
for each selection. A true
value indicates that the selection is unchanged, and
that the caller does not require that the sample stream be recreated.streams
- The existing sample streams, which will be updated to reflect the provided
selections.streamResetFlags
- Will be updated to indicate new sample streams, and sample streams that
have been retained but with the requirement that the consuming renderer be reset.positionUs
- The current playback position in microseconds.long readDiscontinuity()
After this method has returned a value other than C.TIME_UNSET
, all
SampleStream
s provided by the period are guaranteed to start from a key frame.
C.TIME_UNSET
.long getBufferedPositionUs()
This method should only be called when at least one track is selected.
C.TIME_END_OF_SOURCE
if the track is fully buffered.long seekToUs(long positionUs)
After this method has been called, all SampleStream
s provided by the period are
guaranteed to start from a key frame.
This method should only be called when at least one track is selected.
positionUs
- The seek position in microseconds.