public interface

MediaChunkIterator

 androidx.media3.exoplayer.source.chunk.MediaChunkIterator

Subclasses:

BaseMediaChunkIterator, DefaultDashChunkSource.RepresentationSegmentIterator, FakeAdaptiveDataSet.Iterator, FakeMediaChunkIterator

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-exoplayer', version: '1.0.0-alpha03'

  • groupId: androidx.media3
  • artifactId: media3-exoplayer
  • version: 1.0.0-alpha03

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

Overview

Iterator for media chunk sequences.

The iterator initially points in front of the first available element. The first call to MediaChunkIterator.next() moves the iterator to the first element. Check the return value of MediaChunkIterator.next() or MediaChunkIterator.isEnded() to determine whether the iterator reached the end of the available data.

Summary

Fields
public static final MediaChunkIteratorEMPTY

An empty media chunk iterator without available data.

Methods
public longgetChunkEndTimeUs()

Returns the media end time of the chunk, in microseconds.

public longgetChunkStartTimeUs()

Returns the media start time of the chunk, in microseconds.

public DataSpecgetDataSpec()

Returns the DataSpec used to load the media chunk.

public booleanisEnded()

Returns whether the iteration has reached the end of the available data.

public booleannext()

Moves the iterator to the next media chunk.

public voidreset()

Resets the iterator to the initial position.

Fields

public static final MediaChunkIterator EMPTY

An empty media chunk iterator without available data.

Methods

public boolean isEnded()

Returns whether the iteration has reached the end of the available data.

public boolean next()

Moves the iterator to the next media chunk.

Check the return value or MediaChunkIterator.isEnded() to determine whether the iterator reached the end of the available data.

Returns:

Whether the iterator points to a media chunk with available data.

public DataSpec getDataSpec()

Returns the DataSpec used to load the media chunk.

public long getChunkStartTimeUs()

Returns the media start time of the chunk, in microseconds.

public long getChunkEndTimeUs()

Returns the media end time of the chunk, in microseconds.

public void reset()

Resets the iterator to the initial position.

Source

/*
 * Copyright (C) 2018 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.chunk;

import androidx.media3.common.util.UnstableApi;
import androidx.media3.datasource.DataSpec;
import java.util.NoSuchElementException;

/**
 * Iterator for media chunk sequences.
 *
 * <p>The iterator initially points in front of the first available element. The first call to
 * {@link #next()} moves the iterator to the first element. Check the return value of {@link
 * #next()} or {@link #isEnded()} to determine whether the iterator reached the end of the available
 * data.
 */
@UnstableApi
public interface MediaChunkIterator {

  /** An empty media chunk iterator without available data. */
  MediaChunkIterator EMPTY =
      new MediaChunkIterator() {
        @Override
        public boolean isEnded() {
          return true;
        }

        @Override
        public boolean next() {
          return false;
        }

        @Override
        public DataSpec getDataSpec() {
          throw new NoSuchElementException();
        }

        @Override
        public long getChunkStartTimeUs() {
          throw new NoSuchElementException();
        }

        @Override
        public long getChunkEndTimeUs() {
          throw new NoSuchElementException();
        }

        @Override
        public void reset() {
          // Do nothing.
        }
      };

  /** Returns whether the iteration has reached the end of the available data. */
  boolean isEnded();

  /**
   * Moves the iterator to the next media chunk.
   *
   * <p>Check the return value or {@link #isEnded()} to determine whether the iterator reached the
   * end of the available data.
   *
   * @return Whether the iterator points to a media chunk with available data.
   */
  boolean next();

  /**
   * Returns the {@link DataSpec} used to load the media chunk.
   *
   * @throws java.util.NoSuchElementException If the method is called before the first call to
   *     {@link #next()} or when {@link #isEnded()} is true.
   */
  DataSpec getDataSpec();

  /**
   * Returns the media start time of the chunk, in microseconds.
   *
   * @throws java.util.NoSuchElementException If the method is called before the first call to
   *     {@link #next()} or when {@link #isEnded()} is true.
   */
  long getChunkStartTimeUs();

  /**
   * Returns the media end time of the chunk, in microseconds.
   *
   * @throws java.util.NoSuchElementException If the method is called before the first call to
   *     {@link #next()} or when {@link #isEnded()} is true.
   */
  long getChunkEndTimeUs();

  /** Resets the iterator to the initial position. */
  void reset();
}