Added in API level 30

MediaParser.InputReader

public static interface MediaParser.InputReader

android.media.MediaParser.InputReader


Provides input data to MediaParser.

Summary

Public methods

abstract long getLength()

Returns the length of the input in bytes, or -1 if the length is unknown.

abstract long getPosition()

Returns the current read position (byte offset) in the stream.

abstract int read(byte[] buffer, int offset, int readLength)

Reads up to readLength bytes of data and stores them into buffer, starting at index offset.

Public methods

getLength

Added in API level 30
public abstract long getLength ()

Returns the length of the input in bytes, or -1 if the length is unknown.

Returns
long

getPosition

Added in API level 30
public abstract long getPosition ()

Returns the current read position (byte offset) in the stream.

Returns
long

read

Added in API level 30
public abstract int read (byte[] buffer, 
                int offset, 
                int readLength)

Reads up to readLength bytes of data and stores them into buffer, starting at index offset.

This method blocks until at least one byte is read, the end of input is detected, or an exception is thrown. The read position advances to the first unread byte.

Parameters
buffer byte: The buffer into which the read data should be stored. This value cannot be null.

offset int: The start offset into buffer at which data should be written.

readLength int: The maximum number of bytes to read.

Returns
int The non-zero number of bytes read, or -1 if no data is available because the end of the input has been reached.

Throws
IOException If an error occurs reading from the source.