PreloadMediaSource
@UnstableApi
public final class PreloadMediaSource extends WrappingMediaSource
Preloads a MediaSource and provides a MediaPeriod that has data loaded before playback.
Summary
Nested types |
|---|
public final class PreloadMediaSource.Factory implements MediaSource.FactoryFactory for |
public interface PreloadMediaSource.PreloadControlControls preloading of |
Public methods |
|
|---|---|
void |
clear()Clears the preloading |
PreloadMediaPeriod |
createPeriod(Creates the requested |
void |
preload(long startPositionUs)Preloads the |
void |
releasePeriod(MediaPeriod mediaPeriod)Releases a |
void |
Releases the preloaded resources in |
Protected methods |
|
|---|---|
MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(Returns the |
void |
onChildSourceInfoRefreshed(Timeline newTimeline)Called when the child source info has been refreshed. |
void |
Starts source preparation and enables the source, see |
void |
Releases the source, see |
Inherited fields |
||
|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
Public methods
clear
public void clear()
Clears the preloading PreloadMediaPeriod in PreloadMediaSource.
Can be called from any thread.
createPeriod
public PreloadMediaPeriod createPeriod(
MediaSource.MediaPeriodId id,
Allocator allocator,
long startPositionUs
)
Creates the requested MediaPeriod.
This method typically forwards to the wrapped media source and optionally wraps the returned MediaPeriod.
| See also | |
|---|---|
createPeriod |
preload
public void preload(long startPositionUs)
Preloads the PreloadMediaSource for an expected start position startPositionUs.
Can be called from any thread.
| Parameters | |
|---|---|
long startPositionUs |
The expected starting position in microseconds, or |
releasePeriod
public void releasePeriod(MediaPeriod mediaPeriod)
Releases a MediaPeriod.
This method typically forwards to the wrapped media source and optionally unwraps the provided MediaPeriod.
| See also | |
|---|---|
releasePeriod |
releasePreloadMediaSource
public void releasePreloadMediaSource()
Releases the preloaded resources in PreloadMediaSource.
Can be called from any thread.
Protected methods
getMediaPeriodIdForChildMediaPeriodId
protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
MediaSource.MediaPeriodId mediaPeriodId
)
Returns the MediaPeriodId in the wrapping source corresponding to the specified MediaPeriodId in a child source. The default implementation does not change the media period id.
| Parameters | |
|---|---|
MediaSource.MediaPeriodId mediaPeriodId |
A |
| Returns | |
|---|---|
MediaSource.MediaPeriodId |
The corresponding |
onChildSourceInfoRefreshed
protected void onChildSourceInfoRefreshed(Timeline newTimeline)
Called when the child source info has been refreshed.
This Timeline can be amended if needed, for example using ForwardingTimeline. The Timeline for the wrapping source needs to be published with refreshSourceInfo.
| Parameters | |
|---|---|
Timeline newTimeline |
The timeline of the child source. |
prepareSourceInternal
protected void prepareSourceInternal()
Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.
releaseSourceInternal
protected void releaseSourceInternal()
Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.
This method is called on the playback thread.