MaskingMediaSource


@UnstableApi
class MaskingMediaSource : WrappingMediaSource


A MediaSource that masks the Timeline with a placeholder until the actual media structure is known.

Summary

Nested types

A timeline with one dynamic window with a period of indeterminate duration.

Public constructors

MaskingMediaSource(mediaSource: MediaSource!, useLazyPreparation: Boolean)

Creates the masking media source.

Public functions

Boolean

Returns whether the for this source can be updated with the provided item.

MaskingMediaPeriod!
createPeriod(
    id: MediaSource.MediaPeriodId!,
    allocator: Allocator!,
    startPositionUs: Long
)

Creates the requested MediaPeriod.

Timeline!

Returns the Timeline.

Unit

Throws any pending error encountered while loading or refreshing source information.

Unit

Starts source preparation and enables the source, see prepareSource.

Unit
releasePeriod(mediaPeriod: MediaPeriod!)

Releases a MediaPeriod.

Unit

Releases the source, see releaseSource.

Unit

Updates the for this source.

Protected functions

MediaSource.MediaPeriodId?

Returns the MediaPeriodId in the wrapping source corresponding to the specified in a child source.

Unit

Called when the child source info has been refreshed.

Inherited functions

From androidx.media3.exoplayer.source.BaseMediaSource
Unit
@UnstableApi
addDrmEventListener(
    handler: Handler!,
    eventListener: DrmSessionEventListener!
)

Adds a DrmSessionEventListener to the list of listeners which are notified of DRM events for this media source.

Unit
@UnstableApi
addEventListener(
    handler: Handler!,
    eventListener: MediaSourceEventListener!
)

Adds a MediaSourceEventListener to the list of listeners which are notified of media source events.

DrmSessionEventListener.EventDispatcher!

Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId

DrmSessionEventListener.EventDispatcher!
createDrmEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaPeriodId.

MediaSourceEventListener.EventDispatcher!

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaPeriodId.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    mediaPeriodId: MediaSource.MediaPeriodId!,
    mediaTimeOffsetMs: Long
)

This function is deprecated.

Use createEventDispatcher instead.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaPeriodId.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    mediaTimeOffsetMs: Long
)

This function is deprecated.

Use createEventDispatcher instead.

Unit

Disables the source for the creation of MediaPeriods.

Unit

Enables the source for the creation of MediaPeriods.

Boolean

Returns whether the source is enabled.

Unit
@UnstableApi
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    mediaTransferListener: TransferListener?
)

This function is deprecated.

Implement prepareSource instead.

Unit
@UnstableApi
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    mediaTransferListener: TransferListener?,
    playerId: PlayerId!
)

Registers a MediaSourceCaller.

Boolean

Returns whether the source has prepareSource called.

Unit

Updates timeline and manifest and notifies all listeners of the update.

Unit

Unregisters a caller, and disables and releases the source if no longer required.

Unit

Removes a DrmSessionEventListener from the list of listeners which are notified of DRM events for this media source.

Unit

Removes a MediaSourceEventListener from the list of listeners which are notified of media source events.

From androidx.media3.exoplayer.source.CompositeMediaSource
Unit

Disables a child source.

Unit

Disables the source, see disable.

Unit

Enables a child source.

Unit

Enables the source, see enable.

MediaSource.MediaPeriodId?
getMediaPeriodIdForChildMediaPeriodId(
    @UnknownNull childSourceId: T!,
    mediaPeriodId: MediaSource.MediaPeriodId!
)

Returns the MediaPeriodId in the composite source corresponding to the specified in a child source.

Long
getMediaTimeForChildMediaTime(
    @UnknownNull childSourceId: T!,
    mediaTimeMs: Long,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns the media time in the MediaPeriod of the composite source corresponding to the specified media time in the MediaPeriod of the child source.

Int
getWindowIndexForChildWindowIndex(
    @UnknownNull childSourceId: T!,
    windowIndex: Int
)

Returns the window index in the composite source corresponding to the specified window index in a child source.

abstract Unit
onChildSourceInfoRefreshed(
    @UnknownNull childSourceId: T!,
    mediaSource: MediaSource!,
    newTimeline: Timeline!
)

Called when the source info of a child source has been refreshed.

Unit
prepareChildSource(@UnknownNull id: T!, mediaSource: MediaSource!)

Prepares a child source.

Unit

Releases a child source.

From androidx.media3.exoplayer.source.WrappingMediaSource
Unit

Disables the child source.

Unit

Enables the child source.

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.

MediaSource.MediaPeriodId?
getMediaPeriodIdForChildMediaPeriodId(
    childSourceId: Void!,
    mediaPeriodId: MediaSource.MediaPeriodId!
)

Returns the MediaPeriodId in the composite source corresponding to the specified in a child source.

Long
getMediaTimeForChildMediaTime(
    mediaTimeMs: Long,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns the media time in the MediaPeriod of the wrapping source corresponding to the specified media time in the MediaPeriod of the child source.

Long
getMediaTimeForChildMediaTime(
    childSourceId: Void!,
    mediaTimeMs: Long,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

Returns the media time in the MediaPeriod of the composite source corresponding to the specified media time in the MediaPeriod of the child source.

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.

Boolean

Returns true if the media source is guaranteed to never have zero or more than one window.

Unit
onChildSourceInfoRefreshed(
    childSourceId: Void!,
    mediaSource: MediaSource!,
    newTimeline: Timeline!
)

Called when the source info of a child source has been refreshed.

Unit

Prepares the wrapped child source.

Unit
prepareSourceInternal(mediaTransferListener: TransferListener?)

Starts source preparation and enables the source, see prepareSource.

Unit

Releases the child source.

Public constructors

MaskingMediaSource

MaskingMediaSource(mediaSource: MediaSource!, useLazyPreparation: Boolean)

Creates the masking media source.

Parameters
mediaSource: MediaSource!

A MediaSource.

useLazyPreparation: Boolean

Whether the mediaSource is prepared lazily. If false, all manifest loads and other initial preparation steps happen immediately. If true, these initial preparations are triggered only when the player starts buffering the media.

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
): MaskingMediaPeriod!

Creates the requested MediaPeriod.

This method typically forwards to the wrapped media source and optionally wraps the returned MediaPeriod.

See also
createPeriod

getTimeline

fun getTimeline(): Timeline!

Returns the Timeline.

maybeThrowSourceInfoRefreshError

fun maybeThrowSourceInfoRefreshError(): Unit

Throws any pending error encountered while loading or refreshing source information.

Should not be called directly from application code.

This method must be called on the playback thread and only after prepareSource.

prepareSourceInternal

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.

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

releaseSourceInternal

fun releaseSourceInternal(): Unit

Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.

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 in a child source. The default implementation does not change the media period id.

Parameters
mediaPeriodId: MediaSource.MediaPeriodId!

A MediaPeriodId of the child source.

Returns
MediaSource.MediaPeriodId?

The corresponding MediaPeriodId in the wrapping source. Null if no corresponding media period id can be determined.

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 . The Timeline for the wrapping source needs to be published with refreshSourceInfo.

Parameters
newTimeline: Timeline!

The timeline of the child source.