LoopingMediaSource


@UnstableApi
public final class LoopingMediaSource extends WrappingMediaSource


Loops a MediaSource a specified number of times.

Summary

Public constructors

This method is deprecated. Deprecated in Java

LoopingMediaSource(MediaSource childSource, int loopCount)

This method is deprecated. Deprecated in Java

Public methods

MediaPeriod
createPeriod(
    MediaSource.MediaPeriodId id,
    Allocator allocator,
    long startPositionUs
)

This method is deprecated. Deprecated in Java

@Nullable Timeline

This method is deprecated. Deprecated in Java

boolean

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

Protected methods

@Nullable MediaSource.MediaPeriodId

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

Inherited fields

From androidx.media3.exoplayer.source.BaseMediaSource
@Nullable BandwidthMeter

This field is deprecated. Deprecated in Java

@Nullable PlayerId

This field is deprecated. Deprecated in Java

From androidx.media3.exoplayer.source.WrappingMediaSource
final MediaSource

This field is deprecated. Deprecated in Java

Inherited methods

From androidx.media3.exoplayer.source.BaseMediaSource
final void
@UnstableApi
addDrmEventListener(
    Handler handler,
    DrmSessionEventListener eventListener
)

This method is deprecated. Deprecated in Java

final void
@UnstableApi
addEventListener(
    Handler handler,
    MediaSourceEventListener eventListener
)

This method is deprecated. Deprecated in Java

final DrmSessionEventListener.EventDispatcher

This method is deprecated. Deprecated in Java

final DrmSessionEventListener.EventDispatcher
createDrmEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

final MediaSourceEventListener.EventDispatcher

This method is deprecated. Deprecated in Java

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

This method is deprecated.

Use createEventDispatcher instead.

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

final MediaSourceEventListener.EventDispatcher
createEventDispatcher(
    int windowIndex,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId,
    long mediaTimeOffsetMs
)

This method is deprecated.

Use createEventDispatcher instead.

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final BandwidthMeter

This method is deprecated. Deprecated in Java

final PlayerId

This method is deprecated. Deprecated in Java

final boolean

This method is deprecated. Deprecated in Java

final void
@UnstableApi
prepareSource(
    MediaSource.MediaSourceCaller caller,
    PlayerId playerId,
    BandwidthMeter bandwidthMeter
)

This method is deprecated. Deprecated in Java

final boolean

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

From androidx.media3.exoplayer.source.CompositeMediaSource
final void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

@Nullable MediaSource.MediaPeriodId
getMediaPeriodIdForChildMediaPeriodId(
    @UnknownNull T childSourceId,
    MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

long
getMediaTimeForChildMediaTime(
    @UnknownNull T childSourceId,
    long mediaTimeMs,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

int
getWindowIndexForChildWindowIndex(
    @UnknownNull T childSourceId,
    int windowIndex
)

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

abstract void
onChildSourceInfoRefreshed(
    @UnknownNull T childSourceId,
    MediaSource mediaSource,
    Timeline newTimeline
)

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

From androidx.media3.exoplayer.source.MediaSource
void
@UnstableApi
prepareSource(
    MediaSource.MediaSourceCaller caller,
    @Nullable TransferListener mediaTransferListener,
    PlayerId playerId
)

This method is deprecated.

Use prepareSource instead.

From androidx.media3.exoplayer.source.WrappingMediaSource
boolean

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

MediaItem

This method is deprecated. Deprecated in Java

final @Nullable MediaSource.MediaPeriodId
getMediaPeriodIdForChildMediaPeriodId(
    Void childSourceId,
    MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

long
getMediaTimeForChildMediaTime(
    long mediaTimeMs,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

final long
getMediaTimeForChildMediaTime(
    Void childSourceId,
    long mediaTimeMs,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

final int
getWindowIndexForChildWindowIndex(Void childSourceId, int windowIndex)

This method is deprecated. Deprecated in Java

final void
onChildSourceInfoRefreshed(
    Void childSourceId,
    MediaSource mediaSource,
    Timeline newTimeline
)

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

final void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

Public constructors

LoopingMediaSource

public LoopingMediaSource(MediaSource childSource)

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

Parameters
MediaSource childSource

The MediaSource to loop.

LoopingMediaSource

public LoopingMediaSource(MediaSource childSource, int loopCount)

Loops the provided source a specified number of times.

Parameters
MediaSource childSource

The MediaSource to loop.

int loopCount

The desired number of loops. Must be strictly positive.

Public methods

createPeriod

public MediaPeriod 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

getInitialTimeline

public @Nullable Timeline getInitialTimeline()

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

public boolean isSingleWindow()

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

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

Protected methods

getMediaPeriodIdForChildMediaPeriodId

protected @Nullable 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 MediaPeriodId of the child source.

Returns
@Nullable MediaSource.MediaPeriodId

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

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.