public abstract class

ForwardingTimeline

extends Timeline

 java.lang.Object

androidx.media3.common.Timeline

↳androidx.media3.exoplayer.source.ForwardingTimeline

Subclasses:

TimelineWithUpdatedMediaItem, SinglePeriodAdTimeline, NoUidTimeline, FakeMediaSource.InitialTimeline

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-exoplayer', version: '1.5.0-alpha01'

  • groupId: androidx.media3
  • artifactId: media3-exoplayer
  • version: 1.5.0-alpha01

Artifact androidx.media3:media3-exoplayer:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

An overridable Timeline implementation forwarding all methods to another timeline.

Summary

Fields
protected final Timelinetimeline

from TimelineEMPTY
Constructors
publicForwardingTimeline(Timeline timeline)

Methods
public intgetFirstWindowIndex(boolean shuffleModeEnabled)

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

public abstract intgetIndexOfPeriod(java.lang.Object uid)

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

public intgetLastWindowIndex(boolean shuffleModeEnabled)

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

public intgetNextWindowIndex(int windowIndex, 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.

public abstract Timeline.PeriodgetPeriod(int periodIndex, Timeline.Period period, boolean setIds)

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

public abstract intgetPeriodCount()

Returns the number of periods in the timeline.

public intgetPreviousWindowIndex(int windowIndex, 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.

public abstract java.lang.ObjectgetUidOfPeriod(int periodIndex)

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

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

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

public abstract intgetWindowCount()

Returns the number of windows in the timeline.

from TimelinecopyWithSingleWindow, equals, fromBundle, getNextPeriodIndex, getPeriod, getPeriodByUid, getPeriodPosition, getPeriodPosition, getPeriodPositionUs, getPeriodPositionUs, getWindow, hashCode, isEmpty, isLastPeriod, toBundle
from java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Fields

protected final Timeline timeline

Constructors

public ForwardingTimeline(Timeline timeline)

Methods

public abstract int getWindowCount()

Returns the number of windows in the timeline.

public int getNextWindowIndex(int windowIndex, 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.

Parameters:

windowIndex: Index of a window in the timeline.
repeatMode: A repeat mode.
shuffleModeEnabled: Whether shuffling is enabled.

Returns:

The index of the next window, or C.INDEX_UNSET if this is the last window.

public int getPreviousWindowIndex(int windowIndex, 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.

Parameters:

windowIndex: Index of a window in the timeline.
repeatMode: A repeat mode.
shuffleModeEnabled: Whether shuffling is enabled.

Returns:

The index of the previous window, or C.INDEX_UNSET if this is the first window.

public int getLastWindowIndex(boolean shuffleModeEnabled)

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

Parameters:

shuffleModeEnabled: Whether shuffling is enabled.

Returns:

The index of the last window in the playback order, or C.INDEX_UNSET if the timeline is empty.

public int getFirstWindowIndex(boolean shuffleModeEnabled)

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

Parameters:

shuffleModeEnabled: Whether shuffling is enabled.

Returns:

The index of the first window in the playback order, or C.INDEX_UNSET if the timeline is empty.

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

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

Parameters:

windowIndex: The index of the window.
window: The Timeline.Window to 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.

public abstract int getPeriodCount()

Returns the number of periods in the timeline.

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

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

Parameters:

periodIndex: The index of the period.
period: The Timeline.Period to populate. Must not be null.
setIds: Whether Timeline.Period.id and Timeline.Period.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:

The populated Timeline.Period, for convenience.

public abstract int getIndexOfPeriod(java.lang.Object uid)

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

Parameters:

uid: A unique identifier for a period.

Returns:

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

public abstract java.lang.Object getUidOfPeriod(int periodIndex)

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

Parameters:

periodIndex: The index of the period.

Returns:

The unique id of the period.

Source

/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.media3.exoplayer.source;

import androidx.media3.common.Player;
import androidx.media3.common.Timeline;
import androidx.media3.common.util.UnstableApi;

/** An overridable {@link Timeline} implementation forwarding all methods to another timeline. */
@UnstableApi
public abstract class ForwardingTimeline extends Timeline {

  protected final Timeline timeline;

  public ForwardingTimeline(Timeline timeline) {
    this.timeline = timeline;
  }

  @Override
  public int getWindowCount() {
    return timeline.getWindowCount();
  }

  @Override
  public int getNextWindowIndex(
      int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
    return timeline.getNextWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
  }

  @Override
  public int getPreviousWindowIndex(
      int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
    return timeline.getPreviousWindowIndex(windowIndex, repeatMode, shuffleModeEnabled);
  }

  @Override
  public int getLastWindowIndex(boolean shuffleModeEnabled) {
    return timeline.getLastWindowIndex(shuffleModeEnabled);
  }

  @Override
  public int getFirstWindowIndex(boolean shuffleModeEnabled) {
    return timeline.getFirstWindowIndex(shuffleModeEnabled);
  }

  @Override
  public Window getWindow(int windowIndex, Window window, long defaultPositionProjectionUs) {
    return timeline.getWindow(windowIndex, window, defaultPositionProjectionUs);
  }

  @Override
  public int getPeriodCount() {
    return timeline.getPeriodCount();
  }

  @Override
  public Period getPeriod(int periodIndex, Period period, boolean setIds) {
    return timeline.getPeriod(periodIndex, period, setIds);
  }

  @Override
  public int getIndexOfPeriod(Object uid) {
    return timeline.getIndexOfPeriod(uid);
  }

  @Override
  public Object getUidOfPeriod(int periodIndex) {
    return timeline.getUidOfPeriod(periodIndex);
  }
}