TimelineWithUpdatedMediaItem


@UnstableApi
public final class TimelineWithUpdatedMediaItem extends ForwardingTimeline


A Timeline that overrides the MediaItem.

Summary

Public constructors

Creates the timeline.

Public methods

Timeline.Window
getWindow(
    int windowIndex,
    Timeline.Window window,
    long defaultPositionProjectionUs
)

Populates a Window with data for the window at the specified index.

Inherited Constants

From androidx.media3.common.Timeline
static final Timeline

An empty timeline.

Inherited methods

From androidx.media3.exoplayer.source.ForwardingTimeline
int
getFirstWindowIndex(boolean shuffleModeEnabled)

Returns the index of the first window in the playback order depending on whether shuffling is enabled.

int

Returns the index of the period identified by its unique uid, or INDEX_UNSET if the period is not in the timeline.

int
getLastWindowIndex(boolean shuffleModeEnabled)

Returns the index of the last window in the playback order depending on whether shuffling is enabled.

int
getNextWindowIndex(
    int windowIndex,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled
)

Returns the index of the window after the window at index windowIndex depending on the repeatMode and whether shuffling is enabled.

Timeline.Period
getPeriod(int periodIndex, Timeline.Period period, boolean setIds)

Populates a Period with data for the period at the specified index.

int

Returns the number of periods in the timeline.

int
getPreviousWindowIndex(
    int windowIndex,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled
)

Returns the index of the window before the window at index windowIndex depending on the repeatMode and whether shuffling is enabled.

Object
getUidOfPeriod(int periodIndex)

Returns the unique id of the period identified by its index in the timeline.

int

Returns the number of windows in the timeline.

From androidx.media3.common.Timeline
final Timeline

Returns a copy of this timeline containing just the single specified Window.

boolean
static Timeline

Restores a Timeline from a Bundle.

final int
getNextPeriodIndex(
    int periodIndex,
    Timeline.Period period,
    Timeline.Window window,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled
)

Returns the index of the period after the period at index periodIndex depending on the repeatMode and whether shuffling is enabled.

final Timeline.Period
getPeriod(int periodIndex, Timeline.Period period)

Populates a Period with data for the period at the specified index.

Timeline.Period
getPeriodByUid(Object periodUid, Timeline.Period period)

Populates a Period with data for the period with the specified unique identifier.

final Pair<ObjectLong>
@UnstableApi
@InlineMe(replacement = "this.getPeriodPositionUs(window, period, windowIndex, windowPositionUs)")
getPeriodPosition(
    Timeline.Window window,
    Timeline.Period period,
    int windowIndex,
    long windowPositionUs
)

This method is deprecated.

Use getPeriodPositionUs instead.

final @Nullable Pair<ObjectLong>
@UnstableApi
@InlineMe(replacement = "this.getPeriodPositionUs(" + "window, period, windowIndex, windowPositionUs, defaultPositionProjectionUs)")
getPeriodPosition(
    Timeline.Window window,
    Timeline.Period period,
    int windowIndex,
    long windowPositionUs,
    long defaultPositionProjectionUs
)

This method is deprecated.

Use getPeriodPositionUs instead.

final Pair<ObjectLong>
getPeriodPositionUs(
    Timeline.Window window,
    Timeline.Period period,
    int windowIndex,
    long windowPositionUs
)

Calls getPeriodPositionUs with a zero default position projection.

final @Nullable Pair<ObjectLong>
getPeriodPositionUs(
    Timeline.Window window,
    Timeline.Period period,
    int windowIndex,
    long windowPositionUs,
    long defaultPositionProjectionUs
)

Converts (windowIndex, windowPositionUs) to the corresponding (periodUid, periodPositionUs).

final Timeline.Window
getWindow(int windowIndex, Timeline.Window window)

Populates a Window with data for the window at the specified index.

abstract Timeline.Window
getWindow(
    int windowIndex,
    Timeline.Window window,
    long defaultPositionProjectionUs
)

Populates a Window with data for the window at the specified index.

int
final boolean

Returns whether the timeline is empty.

final boolean
isLastPeriod(
    int periodIndex,
    Timeline.Period period,
    Timeline.Window window,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled
)

Returns whether the given period is the last period of the timeline depending on the repeatMode and whether shuffling is enabled.

final Bundle

Returns a Bundle representing the information stored in this object.

Public constructors

TimelineWithUpdatedMediaItem

public TimelineWithUpdatedMediaItem(Timeline timeline, MediaItem mediaItem)

Creates the timeline.

Parameters
Timeline timeline

The wrapped Timeline.

MediaItem mediaItem

The MediaItem that replaced the original one in timeline.

Public methods

getWindow

public Timeline.Window getWindow(
    int windowIndex,
    Timeline.Window window,
    long defaultPositionProjectionUs
)

Populates a Window with data for the window at the specified index.

Parameters
int windowIndex

The index of the window.

Timeline.Window window

The Window to populate. Must not be null.

long defaultPositionProjectionUs

A duration into the future that the populated window's default start position should be projected.

Returns
Timeline.Window

The populated Window, for convenience.