MediaParserExtractorAdapter


@RequiresApi(value = 30)
@UnstableApi
public final class MediaParserExtractorAdapter implements ProgressiveMediaExtractor


ProgressiveMediaExtractor implemented on top of the platform's MediaParser.

Summary

Nested types

A ProgressiveMediaExtractor.Factory for instances of .

Constants

static final ProgressiveMediaExtractor.Factory

This field is deprecated.

Use MediaParserExtractorAdapter.Factory instead.

Public constructors

This method is deprecated.

Use MediaParserExtractorAdapter.Factory instead.

Public methods

void

Disables seeking in MP3 streams.

long

Returns the current read position in the input stream, or INDEX_UNSET if no input is available.

void
init(
    DataReader dataReader,
    Uri uri,
    Map<StringList<String>> responseHeaders,
    long position,
    long length,
    ExtractorOutput output
)

Initializes the underlying infrastructure for reading from the input.

int
read(PositionHolder positionHolder)

Extracts data starting at the current input stream position.

void

Releases any held resources.

void
seek(long position, long seekTimeUs)

Notifies the extracting infrastructure that a seek has occurred.

Constants

FACTORY

public static final ProgressiveMediaExtractor.Factory FACTORY

Public constructors

MediaParserExtractorAdapter

public MediaParserExtractorAdapter(PlayerId playerId)

Public methods

disableSeekingOnMp3Streams

public void disableSeekingOnMp3Streams()

Disables seeking in MP3 streams.

MP3 live streams commonly have seekable metadata, despite being unseekable.

getCurrentInputPosition

public long getCurrentInputPosition()

Returns the current read position in the input stream, or INDEX_UNSET if no input is available.

init

public void init(
    DataReader dataReader,
    Uri uri,
    Map<StringList<String>> responseHeaders,
    long position,
    long length,
    ExtractorOutput output
)

Initializes the underlying infrastructure for reading from the input.

Parameters
DataReader dataReader

The DataReader from which data should be read.

Uri uri

The Uri from which the media is obtained.

Map<StringList<String>> responseHeaders

The response headers of the media, or an empty map if there are none.

long position

The initial position of the dataReader in the stream.

long length

The length of the stream, or LENGTH_UNSET if length is unknown.

ExtractorOutput output

The ExtractorOutput that will be used to initialize the selected extractor.

Throws
androidx.media3.exoplayer.source.UnrecognizedInputFormatException

Thrown if the input format could not be detected.

java.io.IOException

Thrown if the input could not be read.

read

public int read(PositionHolder positionHolder)

Extracts data starting at the current input stream position.

Parameters
PositionHolder positionHolder

If RESULT_SEEK is returned, this holder is updated to hold the position of the required data.

Returns
int

One of the Extractor.RESULT_* values.

Throws
java.io.IOException

If an error occurred reading from the input.

release

public void release()

Releases any held resources.

seek

public void seek(long position, long seekTimeUs)

Notifies the extracting infrastructure that a seek has occurred.

Parameters
long position

The byte offset in the stream from which data will be provided.

long seekTimeUs

The seek time in microseconds.