Class FakeMultiPeriodLiveTimeline
- java.lang.Object
-
- com.google.android.exoplayer2.Timeline
-
- com.google.android.exoplayer2.testutil.FakeMultiPeriodLiveTimeline
-
- All Implemented Interfaces:
Bundleable
public class FakeMultiPeriodLiveTimeline extends Timeline
A fakeTimelinethat produces a live window with periods according to the available time range.The parameters passed to the constructor define the availability start time, the window size and
now. UseadvanceNowUs(long)to advance the live window of the timeline accordingly.The first available period with
ID0 (zero) starts atavailabilityStartTimeUs. Thelive windowstarts atnow - liveWindowDurationUswith the first period of the window having its ID relative to the first available period.Periods are either of type content or ad as defined by the ad sequence pattern. A period is an ad if
adSequencePattern[id % adSequencePattern.length]evaluates to true. Ad periods have a duration ofAD_PERIOD_DURATION_MSand content periods have a duration ofPERIOD_DURATION_MS.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.android.exoplayer2.Timeline
Timeline.Period, Timeline.RemotableTimeline, Timeline.Window
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Bundleable
Bundleable.Creator<T extends Bundleable>
-
-
Field Summary
Fields Modifier and Type Field Description static longAD_PERIOD_DURATION_MSstatic longPERIOD_DURATION_MS
-
Constructor Summary
Constructors Constructor Description FakeMultiPeriodLiveTimeline(long availabilityStartTimeMs, long liveWindowDurationUs, long nowUs, boolean[] adSequencePattern, long[] periodDurationMsPattern, boolean isContentTimeline, boolean populateAds, boolean playedAds)Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadvanceNowUs(long durationUs)Advances the live window by the given duration, in microseconds.intgetIndexOfPeriod(Object uid)Returns the index of the period identified by its uniqueTimeline.Period.uid, orC.INDEX_UNSETif the period is not in the timeline.Timeline.PeriodgetPeriod(int periodIndex, Timeline.Period period, boolean setIds)Populates aTimeline.Periodwith data for the period at the specified index.intgetPeriodCount()Returns the number of periods in the timeline.longgetPeriodStartTimeUs(int periodIndex)Returns the period start time since Unix epoch, in microseconds.ObjectgetUidOfPeriod(int periodIndex)Returns the unique id of the period identified by its index in the timeline.Timeline.WindowgetWindow(int windowIndex, Timeline.Window window, long defaultPositionProjectionUs)Populates aTimeline.Windowwith data for the window at the specified index.intgetWindowCount()Returns the number of windows in the timeline.longgetWindowStartTimeUs()The window's start time in microseconds since the Unix epoch, orC.TIME_UNSETif unknown or not applicable.-
Methods inherited from class com.google.android.exoplayer2.Timeline
equals, getFirstWindowIndex, getLastWindowIndex, getNextPeriodIndex, getNextWindowIndex, getPeriod, getPeriodByUid, getPeriodPosition, getPeriodPosition, getPeriodPositionUs, getPeriodPositionUs, getPreviousWindowIndex, getWindow, hashCode, isEmpty, isLastPeriod, toBundle, toBundleWithOneWindowOnly
-
-
-
-
Field Detail
-
AD_PERIOD_DURATION_MS
public static final long AD_PERIOD_DURATION_MS
- See Also:
- Constant Field Values
-
PERIOD_DURATION_MS
public static final long PERIOD_DURATION_MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FakeMultiPeriodLiveTimeline
public FakeMultiPeriodLiveTimeline(long availabilityStartTimeMs, long liveWindowDurationUs, long nowUs, boolean[] adSequencePattern, long[] periodDurationMsPattern, boolean isContentTimeline, boolean populateAds, boolean playedAds)Creates an instance.- Parameters:
availabilityStartTimeMs- The start time of the available time range, UNIX epoch in milliseconds.liveWindowDurationUs- The duration of the live window.nowUs- The current time that determines the end of the live window.adSequencePattern- The repeating pattern of periods starting atavailabilityStartTimeMs. True is an ad period, and false a content period.periodDurationMsPattern- The repeating pattern of periods durations starting atavailabilityStartTimeMs, in milliseconds. Must have the same length asadSequencePattern.isContentTimeline- Whether the timeline is a content timeline withoutAdPlaybackStates.populateAds- Whether to populate ads in the same way if an ad event has been received.playedAds- Whether ads should be marked as played if populated.
-
-
Method Detail
-
advanceNowUs
public void advanceNowUs(long durationUs)
Advances the live window by the given duration, in microseconds.
-
getWindowStartTimeUs
public long getWindowStartTimeUs()
The window's start time in microseconds since the Unix epoch, orC.TIME_UNSETif unknown or not applicable.
-
getPeriodStartTimeUs
public long getPeriodStartTimeUs(int periodIndex)
Returns the period start time since Unix epoch, in microseconds.Note: The returned value has millisecond precision only, so the trailing 3 digits are always zeros.
-
getWindowCount
public int getWindowCount()
Description copied from class:TimelineReturns the number of windows in the timeline.- Specified by:
getWindowCountin classTimeline
-
getWindow
public Timeline.Window getWindow(int windowIndex, Timeline.Window window, long defaultPositionProjectionUs)
Description copied from class:TimelinePopulates aTimeline.Windowwith data for the window at the specified index.- Specified by:
getWindowin classTimeline- Parameters:
windowIndex- The index of the window.window- TheTimeline.Windowto populate. Must not be null.defaultPositionProjectionUs- A duration into the future that the populated window's default start position should be projected.- Returns:
- The populated
Timeline.Window, for convenience.
-
getPeriodCount
public int getPeriodCount()
Description copied from class:TimelineReturns the number of periods in the timeline.- Specified by:
getPeriodCountin classTimeline
-
getPeriod
public Timeline.Period getPeriod(int periodIndex, Timeline.Period period, boolean setIds)
Description copied from class:TimelinePopulates aTimeline.Periodwith data for the period at the specified index.- Specified by:
getPeriodin classTimeline- Parameters:
periodIndex- The index of the period.period- TheTimeline.Periodto populate. Must not be null.setIds- WhetherTimeline.Period.idandTimeline.Period.uidshould 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:
- The populated
Timeline.Period, for convenience.
-
getIndexOfPeriod
public int getIndexOfPeriod(Object uid)
Description copied from class:TimelineReturns the index of the period identified by its uniqueTimeline.Period.uid, orC.INDEX_UNSETif the period is not in the timeline.- Specified by:
getIndexOfPeriodin classTimeline- Parameters:
uid- A unique identifier for a period.- Returns:
- The index of the period, or
C.INDEX_UNSETif the period was not found.
-
getUidOfPeriod
public Object getUidOfPeriod(int periodIndex)
Description copied from class:TimelineReturns the unique id of the period identified by its index in the timeline.- Specified by:
getUidOfPeriodin classTimeline- Parameters:
periodIndex- The index of the period.- Returns:
- The unique id of the period.
-
-