Added in API level 30

InputReader


interface InputReader
android.media.MediaParser.InputReader

Provides input data to MediaParser.

Summary

Public methods
abstract Long

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

abstract Long

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

abstract Int
read(buffer: ByteArray, offset: Int, readLength: Int)

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

Public methods

getLength

Added in API level 30
abstract fun getLength(): Long

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

getPosition

Added in API level 30
abstract fun getPosition(): Long

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

read

Added in API level 30
abstract fun read(
    buffer: ByteArray,
    offset: Int,
    readLength: Int
): Int

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 ByteArray: 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.
Return
Int The non-zero number of bytes read, or -1 if no data is available because the end of the input has been reached.
Exceptions
java.io.IOException If an error occurs reading from the source.