WrappingMediaSource
@UnstableApi
abstract class WrappingMediaSource : CompositeMediaSource
| kotlin.Any | |||
| ↳ | androidx.media3.exoplayer.source.BaseMediaSource | ||
| ↳ | androidx.media3.exoplayer.source.CompositeMediaSource | ||
| ↳ | androidx.media3.exoplayer.source.WrappingMediaSource |
ClippingMediaSource |
|
FilteringMediaSource |
A |
LoopingMediaSource |
This class is deprecated. To loop a |
MaskingMediaSource |
A |
PreloadMediaSource |
Preloads a |
An abstract MediaSource wrapping a single child MediaSource.
The implementation may want to override the following methods as needed:
getMediaItem: Amend theMediaItemfor this media source. This is only used before the child source is prepared. You may also want to overridecanUpdateMediaItemorupdateMediaItemto intercept further updates to theMediaItem.onChildSourceInfoRefreshed: Called whenever the child source'sTimelinechanged. ThisTimelinecan be amended if needed, for example usingForwardingTimeline. TheTimelinefor the wrapping source needs to be published withrefreshSourceInfo.createPeriod/releasePeriod: These methods create and releaseMediaPeriodinstances. They typically forward to the wrapped media source and optionally wrap the returnedMediaPeriod.
Other methods like prepareSourceInternal, enableInternal, disableInternal or releaseSourceInternal only need to be overwritten if required for resource management.
Summary
Protected constructors |
|---|
WrappingMediaSource(mediaSource: MediaSource!)Creates the wrapping |
Public functions |
|
|---|---|
Boolean |
canUpdateMediaItem(mediaItem: MediaItem!)Returns whether the for this source can be updated with the provided item. |
MediaPeriod! |
createPeriod(Creates the requested |
Timeline? |
Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline. |
MediaItem! |
Returns the whose media is provided by the source. |
Boolean |
Returns true if the media source is guaranteed to never have zero or more than one window. |
Unit |
releasePeriod(mediaPeriod: MediaPeriod!)Releases a |
Unit |
updateMediaItem(mediaItem: MediaItem!)Updates the for this source. |
Protected functions |
|
|---|---|
Unit |
Disables the child source. |
Unit |
Enables the child source. |
MediaSource.MediaPeriodId? |
getMediaPeriodIdForChildMediaPeriodId(Returns the |
MediaSource.MediaPeriodId? |
getMediaPeriodIdForChildMediaPeriodId(Returns the |
Long |
getMediaTimeForChildMediaTime(Returns the media time in the |
Long |
getMediaTimeForChildMediaTime(Returns the media time in the |
Int |
getWindowIndexForChildWindowIndex(windowIndex: Int)Returns the window index in the wrapping source corresponding to the specified window index in a child source. |
Int |
getWindowIndexForChildWindowIndex(childSourceId: Void!, windowIndex: Int)Returns the window index in the composite source corresponding to the specified window index in a child source. |
Unit |
onChildSourceInfoRefreshed(newTimeline: Timeline!)Called when the child source info has been refreshed. |
Unit |
onChildSourceInfoRefreshed(Called when the source info of a child source has been refreshed. |
Unit |
Prepares the wrapped child source. |
Unit |
Starts source preparation and enables the source, see |
Unit |
prepareSourceInternal(mediaTransferListener: TransferListener?)Starts source preparation and enables the source, see |
Unit |
Releases the child source. |
Protected properties |
|
|---|---|
MediaSource! |
The wrapped child |
Inherited functions |
||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||
|
Protected constructors
WrappingMediaSource
protected WrappingMediaSource(mediaSource: MediaSource!)
Creates the wrapping MediaSource.
| Parameters | |
|---|---|
mediaSource: MediaSource! |
The wrapped child |
Public functions
canUpdateMediaItem
fun canUpdateMediaItem(mediaItem: MediaItem!): Boolean
Returns whether the for this source can be updated with the provided item.
Should not be called directly from application code.
This method must be called on the application thread.
This method can be overridden to change whether the MediaItem of the child source can be updated.
createPeriod
fun createPeriod(
id: MediaSource.MediaPeriodId!,
allocator: Allocator!,
startPositionUs: Long
): MediaPeriod!
Creates the requested MediaPeriod.
This method typically forwards to the wrapped media source and optionally wraps the returned MediaPeriod.
| See also | |
|---|---|
createPeriod |
getInitialTimeline
fun getInitialTimeline(): Timeline?
Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline.
Should not be called directly from application code.
The initial timeline must use the same uids for windows and periods that the real timeline will use. It also must provide windows which are marked as dynamic to indicate that the window is expected to change when the real timeline arrives.
Any media source which has multiple windows should typically provide such an initial timeline to make sure the player reports the correct number of windows immediately.
This method must be called on the application thread.
getMediaItem
fun getMediaItem(): MediaItem!
Returns the whose media is provided by the source.
Should not be called directly from application code.
This method must be called on the application thread.
This method can be overridden to amend the MediaItem of the child source. It is only used before the child source is prepared.
isSingleWindow
fun isSingleWindow(): Boolean
Returns true if the media source is guaranteed to never have zero or more than one window.
Should not be called directly from application code.
The default implementation returns true.
This method must be called on the application thread.
| Returns | |
|---|---|
Boolean |
true if the source has exactly one window. |
releasePeriod
fun releasePeriod(mediaPeriod: MediaPeriod!): Unit
Releases a MediaPeriod.
This method typically forwards to the wrapped media source and optionally unwraps the provided MediaPeriod.
| See also | |
|---|---|
releasePeriod |
updateMediaItem
fun updateMediaItem(mediaItem: MediaItem!): Unit
Updates the for this source.
Should not be called directly from application code.
This method must be called on the playback thread and only if #canUpdateMediaItem returns true} for the new .
This method can be overridden to change how the MediaItem of the child source is updated.
Protected functions
getMediaPeriodIdForChildMediaPeriodId
protected fun getMediaPeriodIdForChildMediaPeriodId(
mediaPeriodId: MediaSource.MediaPeriodId!
): MediaSource.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 | |
|---|---|
mediaPeriodId: MediaSource.MediaPeriodId! |
A |
| Returns | |
|---|---|
MediaSource.MediaPeriodId? |
The corresponding |
getMediaPeriodIdForChildMediaPeriodId
protected fun getMediaPeriodIdForChildMediaPeriodId(
childSourceId: Void!,
mediaPeriodId: MediaSource.MediaPeriodId!
): MediaSource.MediaPeriodId?
Returns the MediaPeriodId in the composite source corresponding to the specified MediaPeriodId in a child source. The default implementation does not change the media period id.
| Parameters | |
|---|---|
childSourceId: Void! |
The unique id used to prepare the child source. |
mediaPeriodId: MediaSource.MediaPeriodId! |
A |
| Returns | |
|---|---|
MediaSource.MediaPeriodId? |
The corresponding |
getMediaTimeForChildMediaTime
protected fun getMediaTimeForChildMediaTime(
mediaTimeMs: Long,
mediaPeriodId: MediaSource.MediaPeriodId?
): Long
Returns the media time in the MediaPeriod of the wrapping source corresponding to the specified media time in the MediaPeriod of the child source. The default implementation does not change the media time.
| Parameters | |
|---|---|
mediaTimeMs: Long |
A media time in the |
mediaPeriodId: MediaSource.MediaPeriodId? |
The |
| Returns | |
|---|---|
Long |
The corresponding media time in the |
getMediaTimeForChildMediaTime
protected fun getMediaTimeForChildMediaTime(
childSourceId: Void!,
mediaTimeMs: Long,
mediaPeriodId: MediaSource.MediaPeriodId?
): Long
Returns the media time in the MediaPeriod of the composite source corresponding to the specified media time in the MediaPeriod of the child source. The default implementation does not change the media time.
| Parameters | |
|---|---|
childSourceId: Void! |
The unique id used to prepare the child source. |
mediaTimeMs: Long |
A media time in the |
mediaPeriodId: MediaSource.MediaPeriodId? |
The |
| Returns | |
|---|---|
Long |
The corresponding media time in the |
getWindowIndexForChildWindowIndex
protected fun getWindowIndexForChildWindowIndex(windowIndex: Int): Int
Returns the window index in the wrapping source corresponding to the specified window index in a child source. The default implementation does not change the window index.
| Parameters | |
|---|---|
windowIndex: Int |
A window index of the child source. |
| Returns | |
|---|---|
Int |
The corresponding window index in the wrapping source. |
getWindowIndexForChildWindowIndex
protected fun getWindowIndexForChildWindowIndex(childSourceId: Void!, windowIndex: Int): Int
Returns the window index in the composite source corresponding to the specified window index in a child source. The default implementation does not change the window index.
| Parameters | |
|---|---|
childSourceId: Void! |
The unique id used to prepare the child source. |
windowIndex: Int |
A window index of the child source. |
| Returns | |
|---|---|
Int |
The corresponding window index in the composite source. |
onChildSourceInfoRefreshed
protected fun onChildSourceInfoRefreshed(newTimeline: Timeline!): Unit
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 | |
|---|---|
newTimeline: Timeline! |
The timeline of the child source. |
onChildSourceInfoRefreshed
protected fun onChildSourceInfoRefreshed(
childSourceId: Void!,
mediaSource: MediaSource!,
newTimeline: Timeline!
): Unit
Called when the source info of a child source has been refreshed.
| Parameters | |
|---|---|
childSourceId: Void! |
The unique id used to prepare the child source. |
mediaSource: MediaSource! |
The child source whose source info has been refreshed. |
newTimeline: Timeline! |
The timeline of the child source. |
prepareChildSource
protected fun prepareChildSource(): Unit
Prepares the wrapped child source.
onChildSourceInfoRefreshed will be called when the child source updates its timeline.
If sources aren't explicitly released with releaseChildSource they will be released in releaseSourceInternal.
prepareSourceInternal
protected fun prepareSourceInternal(): Unit
Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.
prepareSourceInternal
protected fun prepareSourceInternal(mediaTransferListener: TransferListener?): Unit
Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.
This method is called on the playback thread.
| Parameters | |
|---|---|
mediaTransferListener: TransferListener? |
The transfer listener which should be informed of any media data transfers. May be null if no listener is available. Note that this listener should usually be only informed of transfers related to the media loads and not of auxiliary loads for manifests and other data. |