Stay organized with collections
Save and categorize content based on your preferences.
interface 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 |
Reads up to readLength bytes of data and stores them into buffer , starting at index offset .
|
Public methods
getLength
abstract fun getLength(): Long
Returns the length of the input in bytes, or -1 if the length is unknown.
getPosition
abstract fun getPosition(): Long
Returns the current read position (byte offset) in the stream.
read
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. |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# MediaParser.InputReader\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nInputReader\n===========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/MediaParser.InputReader \"View this page in Java\") \n\n```\ninterface InputReader\n```\n\n|--------------------------------------------|\n| [android.media.MediaParser.InputReader](#) |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [MediaParser.SeekableInputReader](/reference/kotlin/android/media/MediaParser.SeekableInputReader) |----------------------------------------------------------------------------------------------------|---------------------------------------------------------| | [MediaParser.SeekableInputReader](/reference/kotlin/android/media/MediaParser.SeekableInputReader) | [InputReader](#) that allows setting the read position. | |\n\nProvides input data to [MediaParser](/reference/kotlin/android/media/MediaParser).\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getLength](#getLength())`()` Returns the length of the input in bytes, or -1 if the length is unknown. |\n| abstract [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getPosition](#getPosition())`()` Returns the current read position (byte offset) in the stream. |\n| abstract [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [read](#read(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int))`(`buffer:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)`, `offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `readLength:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` 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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun getLength(): Long\n```\n\nReturns the length of the input in bytes, or -1 if the length is unknown. \n\n### getPosition\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun getPosition(): Long\n```\n\nReturns the current read position (byte offset) in the stream. \n\n### read\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun read(\n buffer: ByteArray, \n offset: Int, \n readLength: Int\n): Int\n```\n\nReads up to `readLength` bytes of data and stores them into `buffer`, starting at index `offset`.\n\nThis 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.\n\n| Parameters ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `buffer` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html): The buffer into which the read data should be stored. This value cannot be `null`. |\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The start offset into `buffer` at which data should be written. |\n| `readLength` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The maximum number of bytes to read. |\n\n| Return ||\n|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The non-zero number of bytes read, or -1 if no data is available because the end of the input has been reached. |\n\n| Exceptions ||\n|-----------------------|---------------------------------------------|\n| `java.io.IOException` | If an error occurs reading from the source. |"]]