public final class

Timeline.Window

extends java.lang.Object

 java.lang.Object

↳androidx.media3.common.Timeline.Window

Overview

Holds information about a window in a Timeline. A window usually corresponds to one playlist item and defines a region of media currently available for playback along with additional information such as whether seeking is supported within the window. The figure below shows some of the information defined by a window, as well as how this information relates to corresponding Periods in the timeline.

Information defined by a timeline window

Summary

Fields
public longdefaultPositionUs

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

public longdurationUs

The duration of this window in microseconds, or C.TIME_UNSET if unknown.

public longelapsedRealtimeEpochOffsetMs

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

public intfirstPeriodIndex

The index of the first period that belongs to this window.

public booleanisDynamic

Whether this window may change when the timeline is updated.

public booleanisPlaceholder

Whether this window contains placeholder information because the real information has yet to be loaded.

public booleanisSeekable

Whether it's possible to seek within this window.

public intlastPeriodIndex

The index of the last period that belongs to this window.

public MediaItem.LiveConfigurationliveConfiguration

The MediaItem.LiveConfiguration that is used or null if Timeline.Window.isLive() returns false.

public java.lang.Objectmanifest

The manifest of the window.

public MediaItemmediaItem

The MediaItem associated to the window.

public longpositionInFirstPeriodUs

The position of the start of this window relative to the start of the first period belonging to it, in microseconds.

public longpresentationStartTimeMs

The start time of the presentation to which this window belongs in milliseconds since the Unix epoch, or C.TIME_UNSET if unknown or not applicable.

public static final java.lang.ObjectSINGLE_WINDOW_UID

A Timeline.Window.uid for a window that must be used for single-window Timelines.

public java.lang.Objecttag

public java.lang.Objectuid

A unique identifier for the window.

public longwindowStartTimeMs

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

Constructors
publicWindow()

Creates window.

Methods
public booleanequals(java.lang.Object obj)

public static Timeline.WindowfromBundle(Bundle bundle)

Restores a Window from a .

public longgetCurrentUnixTimeMs()

Returns the current time in milliseconds since the Unix epoch.

public longgetDefaultPositionMs()

Returns the default position relative to the start of the window at which to begin playback, in milliseconds.

public longgetDefaultPositionUs()

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

public longgetDurationMs()

Returns the duration of the window in milliseconds, or C.TIME_UNSET if unknown.

public longgetDurationUs()

Returns the duration of this window in microseconds, or C.TIME_UNSET if unknown.

public longgetPositionInFirstPeriodMs()

Returns the position of the start of this window relative to the start of the first period belonging to it, in milliseconds.

public longgetPositionInFirstPeriodUs()

Returns the position of the start of this window relative to the start of the first period belonging to it, in microseconds.

public inthashCode()

public booleanisLive()

Returns whether this is a live stream.

public Timeline.Windowset(java.lang.Object uid, MediaItem mediaItem, java.lang.Object manifest, long presentationStartTimeMs, long windowStartTimeMs, long elapsedRealtimeEpochOffsetMs, boolean isSeekable, boolean isDynamic, MediaItem.LiveConfiguration liveConfiguration, long defaultPositionUs, long durationUs, int firstPeriodIndex, int lastPeriodIndex, long positionInFirstPeriodUs)

Sets the data held by this window.

public BundletoBundle()

Returns a representing the information stored in this object.

from java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Fields

public static final java.lang.Object SINGLE_WINDOW_UID

A Timeline.Window.uid for a window that must be used for single-window Timelines.

public java.lang.Object uid

A unique identifier for the window. Single-window Timelines must use Timeline.Window.SINGLE_WINDOW_UID.

public java.lang.Object tag

Deprecated: Use Timeline.Window.mediaItem instead.

public MediaItem mediaItem

The MediaItem associated to the window. Not necessarily unique.

public java.lang.Object manifest

The manifest of the window. May be null.

public long presentationStartTimeMs

The start time of the presentation to which this window belongs in milliseconds since the Unix epoch, or C.TIME_UNSET if unknown or not applicable. For informational purposes only.

public long windowStartTimeMs

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

public long elapsedRealtimeEpochOffsetMs

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

Note that the current Unix time can be retrieved using Timeline.Window.getCurrentUnixTimeMs() and is calculated as SystemClock.elapsedRealtime() + elapsedRealtimeEpochOffsetMs.

public boolean isSeekable

Whether it's possible to seek within this window.

public boolean isDynamic

Whether this window may change when the timeline is updated.

public MediaItem.LiveConfiguration liveConfiguration

The MediaItem.LiveConfiguration that is used or null if Timeline.Window.isLive() returns false.

public boolean isPlaceholder

Whether this window contains placeholder information because the real information has yet to be loaded.

public long defaultPositionUs

The default position relative to the start of the window at which to begin playback, in microseconds. May be C.TIME_UNSET if and only if the window was populated with a non-zero default position projection, and if the specified projection cannot be performed whilst remaining within the bounds of the window.

public long durationUs

The duration of this window in microseconds, or C.TIME_UNSET if unknown.

public int firstPeriodIndex

The index of the first period that belongs to this window.

public int lastPeriodIndex

The index of the last period that belongs to this window.

public long positionInFirstPeriodUs

The position of the start of this window relative to the start of the first period belonging to it, in microseconds.

Constructors

public Window()

Creates window.

Methods

public Timeline.Window set(java.lang.Object uid, MediaItem mediaItem, java.lang.Object manifest, long presentationStartTimeMs, long windowStartTimeMs, long elapsedRealtimeEpochOffsetMs, boolean isSeekable, boolean isDynamic, MediaItem.LiveConfiguration liveConfiguration, long defaultPositionUs, long durationUs, int firstPeriodIndex, int lastPeriodIndex, long positionInFirstPeriodUs)

Sets the data held by this window.

public long getDefaultPositionMs()

Returns the default position relative to the start of the window at which to begin playback, in milliseconds. May be C.TIME_UNSET if and only if the window was populated with a non-zero default position projection, and if the specified projection cannot be performed whilst remaining within the bounds of the window.

public long getDefaultPositionUs()

Returns the default position relative to the start of the window at which to begin playback, in microseconds. May be C.TIME_UNSET if and only if the window was populated with a non-zero default position projection, and if the specified projection cannot be performed whilst remaining within the bounds of the window.

public long getDurationMs()

Returns the duration of the window in milliseconds, or C.TIME_UNSET if unknown.

public long getDurationUs()

Returns the duration of this window in microseconds, or C.TIME_UNSET if unknown.

public long getPositionInFirstPeriodMs()

Returns the position of the start of this window relative to the start of the first period belonging to it, in milliseconds.

public long getPositionInFirstPeriodUs()

Returns the position of the start of this window relative to the start of the first period belonging to it, in microseconds.

public long getCurrentUnixTimeMs()

Returns the current time in milliseconds since the Unix epoch.

This method applies known corrections made available by the media such that this time corresponds to the clock of the media origin server.

public boolean isLive()

Returns whether this is a live stream.

public boolean equals(java.lang.Object obj)

public int hashCode()

public Bundle toBundle()

Returns a representing the information stored in this object.

It omits the Timeline.Window.uid and Timeline.Window.manifest fields. The Timeline.Window.uid of an instance restored by Timeline.Window.fromBundle(Bundle) will be a fake java.lang.Object and the Timeline.Window.manifest of the instance will be null.

public static Timeline.Window fromBundle(Bundle bundle)

Restores a Window from a .