LoopingMediaSource


@UnstableApi
class LoopingMediaSource : WrappingMediaSource


Loops a MediaSource a specified number of times.

Summary

Public constructors

Loops the provided source indefinitely.

LoopingMediaSource(childSource: MediaSource!, loopCount: Int)

Loops the provided source a specified number of times.

Public functions

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

Creates the requested MediaPeriod.

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.

Boolean

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

Unit
releasePeriod(mediaPeriod: MediaPeriod!)

Releases a MediaPeriod.

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
addDrmEventListener(
    handler: Handler!,
    eventListener: DrmSessionEventListener!
)

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

Unit
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
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    mediaTransferListener: TransferListener?
)

This function is deprecated.

Implement prepareSource instead.

Unit
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.

Unit

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

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.

Unit

Releases the source, see releaseSource.

From androidx.media3.exoplayer.source.WrappingMediaSource
Boolean

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

Unit

Disables the child source.

Unit

Enables the child source.

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.

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

Starts source preparation and enables the source, see prepareSource.

Unit
prepareSourceInternal(mediaTransferListener: TransferListener?)

Starts source preparation and enables the source, see prepareSource.

Unit

Releases the child source.

Unit

Updates the for this source.

Public constructors

LoopingMediaSource

LoopingMediaSource(childSource: MediaSource!)

Loops the provided source indefinitely. Note that it is usually better to use setRepeatMode.

Parameters
childSource: MediaSource!

The MediaSource to loop.

LoopingMediaSource

LoopingMediaSource(childSource: MediaSource!, loopCount: Int)

Loops the provided source a specified number of times.

Parameters
childSource: MediaSource!

The MediaSource to loop.

loopCount: Int

The desired number of loops. Must be strictly positive.

Public functions

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.

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

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.