SinglePeriodTimeline


@UnstableApi
class SinglePeriodTimeline : Timeline


A Timeline consisting of a single period and static window.

Summary

Public constructors

SinglePeriodTimeline(
    durationUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    isLive: Boolean,
    manifest: Any?,
    tag: Any?
)

This function is deprecated.

Use SinglePeriodTimeline instead.

SinglePeriodTimeline(
    durationUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    useLiveConfiguration: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!
)

Creates a timeline containing a single period and a window that spans it.

SinglePeriodTimeline(
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    isLive: Boolean,
    manifest: Any?,
    tag: Any?
)

This function is deprecated.

Use SinglePeriodTimeline instead.

SinglePeriodTimeline(
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    useLiveConfiguration: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!
)

Creates a timeline with one period, and a window of known duration starting at a specified position in the period.

SinglePeriodTimeline(
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    isLive: Boolean,
    manifest: Any?,
    tag: Any?
)

This function is deprecated.

Use SinglePeriodTimeline instead.

SinglePeriodTimeline(
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!,
    liveConfiguration: MediaItem.LiveConfiguration?
)

This function is deprecated.

Use SinglePeriodTimeline instead.

SinglePeriodTimeline(
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    suppressPositionProjection: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!,
    liveConfiguration: MediaItem.LiveConfiguration?
)

Creates a timeline with one period, and a window of known duration starting at a specified position in the period.

Public functions

Int

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

Timeline.Period!
getPeriod(periodIndex: Int, period: Timeline.Period!, setIds: Boolean)

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

Int

Returns the number of periods in the timeline.

Any!
getUidOfPeriod(periodIndex: Int)

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

Timeline.Window!
getWindow(
    windowIndex: Int,
    window: Timeline.Window!,
    defaultPositionProjectionUs: Long
)

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

Int

Returns the number of windows in the timeline.

Inherited Constants

From androidx.media3.common.Timeline
const Timeline!

An empty timeline.

Inherited functions

From androidx.media3.common.Timeline
Timeline!

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

Boolean
equals(obj: Any?)
java-static Timeline!

Restores a Timeline from a Bundle.

Int
getFirstWindowIndex(shuffleModeEnabled: Boolean)

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

Int
getLastWindowIndex(shuffleModeEnabled: Boolean)

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

Int
getNextPeriodIndex(
    periodIndex: Int,
    period: Timeline.Period!,
    window: Timeline.Window!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
)

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

Int
getNextWindowIndex(
    windowIndex: Int,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
)

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

Timeline.Period!
getPeriod(periodIndex: Int, period: Timeline.Period!)

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

Timeline.Period!
getPeriodByUid(periodUid: Any!, period: Timeline.Period!)

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

Pair<Any!, Long!>!
@UnstableApi
@InlineMe(replacement = "this.getPeriodPositionUs(window, period, windowIndex, windowPositionUs)")
getPeriodPosition(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long
)

This function is deprecated.

Use getPeriodPositionUs instead.

Pair<Any!, Long!>?
@UnstableApi
@InlineMe(replacement = "this.getPeriodPositionUs(" + "window, period, windowIndex, windowPositionUs, defaultPositionProjectionUs)")
getPeriodPosition(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long,
    defaultPositionProjectionUs: Long
)

This function is deprecated.

Use getPeriodPositionUs instead.

Pair<Any!, Long!>!
getPeriodPositionUs(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long
)

Calls getPeriodPositionUs with a zero default position projection.

Pair<Any!, Long!>?
getPeriodPositionUs(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long,
    defaultPositionProjectionUs: Long
)

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

Int
getPreviousWindowIndex(
    windowIndex: Int,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
)

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

Timeline.Window!
getWindow(windowIndex: Int, window: Timeline.Window!)

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

Int
Boolean

Returns whether the timeline is empty.

Boolean
isLastPeriod(
    periodIndex: Int,
    period: Timeline.Period!,
    window: Timeline.Window!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
)

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

Bundle!

Returns a Bundle representing the information stored in this object.

Public constructors

SinglePeriodTimeline

SinglePeriodTimeline(
    durationUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    isLive: Boolean,
    manifest: Any?,
    tag: Any?
)

SinglePeriodTimeline

SinglePeriodTimeline(
    durationUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    useLiveConfiguration: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!
)

Creates a timeline containing a single period and a window that spans it.

Parameters
durationUs: Long

The duration of the period, in microseconds.

isSeekable: Boolean

Whether seeking is supported within the period.

isDynamic: Boolean

Whether the window may change when the timeline is updated.

useLiveConfiguration: Boolean

Whether the window is live and liveConfiguration is used to configure live playback behaviour.

manifest: Any?

The manifest. May be null.

mediaItem: MediaItem!

A media item used for mediaItem.

SinglePeriodTimeline

SinglePeriodTimeline(
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    isLive: Boolean,
    manifest: Any?,
    tag: Any?
)

SinglePeriodTimeline

SinglePeriodTimeline(
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    useLiveConfiguration: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!
)

Creates a timeline with one period, and a window of known duration starting at a specified position in the period.

Parameters
periodDurationUs: Long

The duration of the period in microseconds.

windowDurationUs: Long

The duration of the window in microseconds.

windowPositionInPeriodUs: Long

The position of the start of the window in the period, in microseconds.

windowDefaultStartPositionUs: Long

The default position relative to the start of the window at which to begin playback, in microseconds.

isSeekable: Boolean

Whether seeking is supported within the window.

isDynamic: Boolean

Whether the window may change when the timeline is updated.

useLiveConfiguration: Boolean

Whether the window is live and liveConfiguration is used to configure live playback behaviour.

manifest: Any?

The manifest. May be null.

mediaItem: MediaItem!

A media item used for mediaItem.

SinglePeriodTimeline

SinglePeriodTimeline(
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    isLive: Boolean,
    manifest: Any?,
    tag: Any?
)

SinglePeriodTimeline

SinglePeriodTimeline(
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!,
    liveConfiguration: MediaItem.LiveConfiguration?
)

SinglePeriodTimeline

SinglePeriodTimeline(
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    periodDurationUs: Long,
    windowDurationUs: Long,
    windowPositionInPeriodUs: Long,
    windowDefaultStartPositionUs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    suppressPositionProjection: Boolean,
    manifest: Any?,
    mediaItem: MediaItem!,
    liveConfiguration: MediaItem.LiveConfiguration?
)

Creates a timeline with one period, and a window of known duration starting at a specified position in the period.

Parameters
presentationStartTimeMs: Long

The start time of the presentation in milliseconds since the epoch, or TIME_UNSET if unknown or not applicable.

windowStartTimeMs: Long

The window's start time in milliseconds since the epoch, or TIME_UNSET if unknown or not applicable.

elapsedRealtimeEpochOffsetMs: Long

The offset between elapsedRealtime and the time since the Unix epoch according to the clock of the media origin server, or TIME_UNSET if unknown or not applicable.

periodDurationUs: Long

The duration of the period in microseconds.

windowDurationUs: Long

The duration of the window in microseconds.

windowPositionInPeriodUs: Long

The position of the start of the window in the period, in microseconds.

windowDefaultStartPositionUs: Long

The default position relative to the start of the window at which to begin playback, in microseconds.

isSeekable: Boolean

Whether seeking is supported within the window.

isDynamic: Boolean

Whether the window may change when the timeline is updated.

suppressPositionProjection: Boolean

Whether position projection in a playlist should be suppressed. This only applies for dynamic timelines and is ignored otherwise.

manifest: Any?

The manifest. May be null.

mediaItem: MediaItem!

A media item used for mediaItem.

liveConfiguration: MediaItem.LiveConfiguration?

The configuration for live playback behaviour, or null if the window is not live.

Public functions

getIndexOfPeriod

fun getIndexOfPeriod(uid: Any!): Int

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

Parameters
uid: Any!

A unique identifier for a period.

Returns
Int

The index of the period, or INDEX_UNSET if the period was not found.

getPeriod

fun getPeriod(periodIndex: Int, period: Timeline.Period!, setIds: Boolean): Timeline.Period!

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

Parameters
periodIndex: Int

The index of the period.

period: Timeline.Period!

The Period to populate. Must not be null.

setIds: Boolean

Whether id and uid should be populated. If false, the fields will be set to null. The caller should pass false for efficiency reasons unless the fields are required.

Returns
Timeline.Period!

The populated Period, for convenience.

getPeriodCount

fun getPeriodCount(): Int

Returns the number of periods in the timeline.

getUidOfPeriod

fun getUidOfPeriod(periodIndex: Int): Any!

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

Parameters
periodIndex: Int

The index of the period.

Returns
Any!

The unique id of the period.

getWindow

fun getWindow(
    windowIndex: Int,
    window: Timeline.Window!,
    defaultPositionProjectionUs: Long
): Timeline.Window!

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

Parameters
windowIndex: Int

The index of the window.

window: Timeline.Window!

The Window to populate. Must not be null.

defaultPositionProjectionUs: Long

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

Returns
Timeline.Window!

The populated Window, for convenience.

getWindowCount

fun getWindowCount(): Int

Returns the number of windows in the timeline.