Timeline.Window
public final class Timeline.Window
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.
Summary
Public fields |
|
|---|---|
long |
The default position relative to the start of the window at which to begin playback, in microseconds. |
long |
The duration of this window in microseconds, or |
long |
The offset between |
int |
The index of the first period that belongs to this window. |
boolean |
Whether this window may change when the timeline is updated. |
boolean |
Whether this window contains placeholder information because the real information has yet to be loaded. |
boolean |
Whether it's possible to seek within this window. |
int |
The index of the last period that belongs to this window. |
@Nullable MediaItem.LiveConfiguration |
The |
@Nullable Object |
The manifest of the window. |
MediaItem |
The |
long |
The position of the start of this window relative to the start of the first period belonging to it, in microseconds. |
long |
The start time of the presentation to which this window belongs in milliseconds since the Unix epoch, or |
@Nullable Object |
This field is deprecated. |
Object |
A unique identifier for the window. |
long |
The window's start time in milliseconds since the Unix epoch, or |
Public constructors |
|---|
Window()Creates window. |
Public methods |
|
|---|---|
boolean |
|
static Timeline.Window |
@UnstableApiRestores a |
long |
Returns the current time in milliseconds since the Unix epoch. |
long |
Returns the default position relative to the start of the window at which to begin playback, in milliseconds. |
long |
Returns the default position relative to the start of the window at which to begin playback, in microseconds. |
long |
Returns the duration of the window in milliseconds, or |
long |
Returns the duration of this window in microseconds, or |
long |
Returns the position of the start of this window relative to the start of the first period belonging to it, in milliseconds. |
long |
Returns the position of the start of this window relative to the start of the first period belonging to it, in microseconds. |
int |
hashCode() |
boolean |
isLive()Returns whether this is a live stream. |
Timeline.Window |
@CanIgnoreReturnValueSets the data held by this window. |
Bundle |
Returns a |
Constants
SINGLE_WINDOW_UID
public static final Object SINGLE_WINDOW_UID
A uid for a window that must be used for single-window Timelines.
Public fields
defaultPositionUs
@UnstableApi
public long defaultPositionUs
The default position relative to the start of the window at which to begin playback, in microseconds. May be 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.
durationUs
@UnstableApi
public long durationUs
The duration of this window in microseconds, or TIME_UNSET if unknown.
elapsedRealtimeEpochOffsetMs
public long elapsedRealtimeEpochOffsetMs
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.
Note that the current Unix time can be retrieved using getCurrentUnixTimeMs and is calculated as SystemClock.elapsedRealtime() + elapsedRealtimeEpochOffsetMs.
firstPeriodIndex
public int firstPeriodIndex
The index of the first period that belongs to this window.
isPlaceholder
public boolean isPlaceholder
Whether this window contains placeholder information because the real information has yet to be loaded.
lastPeriodIndex
public int lastPeriodIndex
The index of the last period that belongs to this window.
liveConfiguration
public @Nullable MediaItem.LiveConfiguration liveConfiguration
The MediaItem.LiveConfiguration that is used or null if isLive returns false.
manifest
public @Nullable Object manifest
The manifest of the window. May be null.
The concrete type depends on the media sources producing the timeline window. Examples provided by Media3 media source modules are
androidx.media3.exoplayer.dash.manifest.DashManifest,
androidx.media3.exoplayer.hls.HlsManifest and
androidx.media3.exoplayer.smoothstreaming.SSManifest.
mediaItem
public MediaItem mediaItem
The MediaItem associated to the window. Not necessarily unique.
positionInFirstPeriodUs
@UnstableApi
public long positionInFirstPeriodUs
The position of the start of this window relative to the start of the first period belonging to it, in microseconds.
presentationStartTimeMs
public long presentationStartTimeMs
The start time of the presentation to which this window belongs in milliseconds since the Unix epoch, or TIME_UNSET if unknown or not applicable. For informational purposes only.
uid
public Object uid
A unique identifier for the window. Single-window Timelines must use SINGLE_WINDOW_UID.
windowStartTimeMs
public long windowStartTimeMs
The window's start time in milliseconds since the Unix epoch, or TIME_UNSET if unknown or not applicable.
Public constructors
Public methods
fromBundle
@UnstableApi
public static Timeline.Window fromBundle(Bundle bundle)
Restores a Window from a Bundle.
getCurrentUnixTimeMs
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.
getDefaultPositionMs
public long getDefaultPositionMs()
Returns the default position relative to the start of the window at which to begin playback, in milliseconds. May be 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.
getDefaultPositionUs
public long getDefaultPositionUs()
Returns the default position relative to the start of the window at which to begin playback, in microseconds. May be 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.
getDurationMs
public long getDurationMs()
Returns the duration of the window in milliseconds, or TIME_UNSET if unknown.
getDurationUs
public long getDurationUs()
Returns the duration of this window in microseconds, or TIME_UNSET if unknown.
getPositionInFirstPeriodMs
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.
getPositionInFirstPeriodUs
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.
set
@CanIgnoreReturnValue
@UnstableApi
public Timeline.Window set(
Object uid,
@Nullable MediaItem mediaItem,
@Nullable Object manifest,
long presentationStartTimeMs,
long windowStartTimeMs,
long elapsedRealtimeEpochOffsetMs,
boolean isSeekable,
boolean isDynamic,
@Nullable MediaItem.LiveConfiguration liveConfiguration,
long defaultPositionUs,
long durationUs,
int firstPeriodIndex,
int lastPeriodIndex,
long positionInFirstPeriodUs
)
Sets the data held by this window.
toBundle
@UnstableApi
public Bundle toBundle()
Returns a Bundle representing the information stored in this object.
It omits the uid and manifest fields. The uid of an instance restored by fromBundle will be a fake Object and the manifest of the instance will be null.