Stay organized with collections
Save and categorize content based on your preferences.
public
static
interface
MediaParser.InputReader
android.media.MediaParser.InputReader
|
Known indirect subclasses
|
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
public abstract long getLength ()
Returns the length of the input in bytes, or -1 if the length is unknown.
getPosition
public abstract long getPosition ()
Returns the current read position (byte offset) in the stream.
read
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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# MediaParser.InputReader\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nMediaParser.InputReader\n=======================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/media/MediaParser.InputReader \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nMediaParser.InputReader\n`\n\n\n`\n\n\n`\n\n|---------------------------------------|\n| android.media.MediaParser.InputReader |\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [MediaParser.SeekableInputReader](/reference/android/media/MediaParser.SeekableInputReader) |---------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------| | [MediaParser.SeekableInputReader](/reference/android/media/MediaParser.SeekableInputReader) | [InputReader](/reference/android/media/MediaParser.InputReader) that allows setting the read position. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nProvides input data to [MediaParser](/reference/android/media/MediaParser).\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract long` | ` `[getLength](/reference/android/media/MediaParser.InputReader#getLength())`() ` Returns the length of the input in bytes, or -1 if the length is unknown. |\n| ` abstract long` | ` `[getPosition](/reference/android/media/MediaParser.InputReader#getPosition())`() ` Returns the current read position (byte offset) in the stream. |\n| ` abstract int` | ` `[read](/reference/android/media/MediaParser.InputReader#read(byte[],%20int,%20int))`(byte[] buffer, int offset, int readLength) ` Reads up to `readLength` bytes of data and stores them into `buffer`, starting at index `offset`. |\n\nPublic methods\n--------------\n\n### getLength\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract long getLength ()\n```\n\nReturns the length of the input in bytes, or -1 if the length is unknown.\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------|--------|\n| `long` | \u003cbr /\u003e |\n\n### getPosition\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract long getPosition ()\n```\n\nReturns the current read position (byte offset) in the stream.\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------|--------|\n| `long` | \u003cbr /\u003e |\n\n### read\n\nAdded in [API level 30](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract int read (byte[] buffer, \n int offset, \n int readLength)\n```\n\nReads up to `readLength` bytes of data and stores them into `buffer`,\nstarting at index `offset`.\n\nThis method blocks until at least one byte is read, the end of input is detected, or\nan exception is thrown. The read position advances to the first unread byte.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|---------------------------------------------------------------------------------------------------|\n| `buffer` | `byte`: The buffer into which the read data should be stored. This value cannot be `null`. \u003cbr /\u003e |\n| `offset` | `int`: The start offset into `buffer` at which data should be written. \u003cbr /\u003e |\n| `readLength` | `int`: The maximum number of bytes to read. \u003cbr /\u003e |\n\n| Returns ||\n|-------|------------------------------------------------------------------------------------------------------------------------|\n| `int` | The non-zero number of bytes read, or -1 if no data is available because the end of the input has been reached. \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------|---------------------------------------------|\n| [IOException](/reference/java/io/IOException) | If an error occurs reading from the source. |"]]