Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/media/MediaParser.InputReader#pubmethods)

# MediaParser.InputReader

*** ** * ** ***

` public static interface MediaParser.InputReader `   
` `

|---|
| android.media.MediaParser.InputReader |

Known indirect subclasses [MediaParser.SeekableInputReader](https://developer.android.com/reference/android/media/MediaParser.SeekableInputReader) [MediaParser.SeekableInputReader](https://developer.android.com/reference/android/media/MediaParser.SeekableInputReader) `https://developer.android.com/reference/android/media/MediaParser.InputReader` that allows setting the read position.   

*** ** * ** ***

Provides input data to `https://developer.android.com/reference/android/media/MediaParser`.

## Summary

| ### Public methods ||
|---|---|
| ` abstract long` | ` https://developer.android.com/reference/android/media/MediaParser.InputReader#getLength()() ` Returns the length of the input in bytes, or -1 if the length is unknown. |
| ` abstract long` | ` https://developer.android.com/reference/android/media/MediaParser.InputReader#getPosition()() ` Returns the current read position (byte offset) in the stream. |
| ` abstract int` | ` https://developer.android.com/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`. |

## Public methods

### getLength

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract long getLength ()
```

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

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getPosition

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract long getPosition ()
```

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

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### read

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

| Parameters ||
|---|---|
| `buffer` | `byte`: The buffer into which the read data should be stored. This value cannot be `null`. <br /> |
| `offset` | `int`: The start offset into `buffer` at which data should be written. <br /> |
| `readLength` | `int`: The maximum number of bytes to read. <br /> |

| 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. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | If an error occurs reading from the source. |