# EmptySampleStream

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/EmptySampleStream.java+class:androidx.media3.exoplayer.source.EmptySampleStream)

*** ** * ** ***


```
@UnstableApi
class EmptySampleStream : SampleStream
```

<br />

*** ** * ** ***

An empty `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/EmptySampleStream#EmptySampleStream()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/EmptySampleStream#isReady()()` Returns whether data is available to be read. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/EmptySampleStream#maybeThrowError()()` Throws an error that's preventing data from being read. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/EmptySampleStream#readData(androidx.media3.exoplayer.FormatHolder,androidx.media3.decoder.DecoderInputBuffer,int)( formatHolder: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/FormatHolder!, buffer: https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer!, @https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream.ReadFlags readFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Attempts to read from the stream. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/EmptySampleStream#skipData(long)(positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Attempts to skip to the keyframe before the specified position, or to the end of the stream if `positionUs` is beyond it. |

| ### Inherited Constants |
|---|
| From [androidx.media3.exoplayer.source.SampleStream](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream) |---|---| | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#FLAG_HAS_PREROLL() = 4` Specifies that the stream contains a preroll of decode-only samples. | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#FLAG_MAYBE_HAS_PREROLL() = 2` Specifies that the stream may contain preroll samples. | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#FLAG_OMIT_SAMPLE_DATA() = 4` Specifies that `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#data()`, `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` and `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#cryptoInfo()` should not be populated when reading a sample buffer. | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#FLAG_PEEK() = 1` Specifies that the read position should not be advanced if a sample buffer is read. | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#FLAG_REQUIRE_FORMAT() = 2` Specifies that if a sample buffer would normally be read next, the format of the stream should be read instead. | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#FLAG_STRICT_DURATION() = 1` Specifies that playout of the stream should be stopped once the duration is reached. | |

| ### Inherited functions |
|---|
| From [androidx.media3.exoplayer.source.SampleStream](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream) |---|---| | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream.Flags https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#getFlags()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream.Flags` set on this stream. | |

## Public constructors

### EmptySampleStream

```
EmptySampleStream()
```

## Public functions

### isReady

```
fun isReady(): Boolean
```

Returns whether data is available to be read.

Note: If the stream has ended then a buffer with the end of stream flag can always be read from `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream#readData(androidx.media3.exoplayer.FormatHolder,androidx.media3.decoder.DecoderInputBuffer,int)`. Hence an ended stream is always ready.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether data is available to be read. |

### maybeThrowError

```
fun maybeThrowError(): Unit
```

Throws an error that's preventing data from being read. Does nothing if no such error exists.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | The underlying error. |

### readData

```
fun readData(
    formatHolder: FormatHolder!,
    buffer: DecoderInputBuffer!,
    @SampleStream.ReadFlags readFlags: Int
): Int
```

Attempts to read from the stream.

If the stream has ended then `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set on `
buffer` and `https://developer.android.com/reference/kotlin/androidx/media3/common/C#RESULT_BUFFER_READ()` is returned. Else if no data is available then `https://developer.android.com/reference/kotlin/androidx/media3/common/C#RESULT_NOTHING_READ()` is returned. Else if the format of the media is changing or if `
formatRequired` is set then `formatHolder` is populated and `https://developer.android.com/reference/kotlin/androidx/media3/common/C#RESULT_FORMAT_READ()` is returned. Else `buffer` is populated and `https://developer.android.com/reference/kotlin/androidx/media3/common/C#RESULT_BUFFER_READ()` is returned.

| Parameters |
|---|---|
| `formatHolder: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/FormatHolder!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/FormatHolder` to populate in the case of reading a format. |
| `buffer: https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer!` | A `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer` to populate in the case of reading a sample or the end of the stream. If the end of the stream has been reached, the `https://developer.android.com/reference/kotlin/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag will be set on the buffer. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream.ReadFlags readFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Flags controlling the behavior of this read operation. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SampleStream.ReadDataResult` of the read operation. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer.InsufficientCapacityException` | If the `buffer` has insufficient capacity to hold the data of a sample being read. The buffer `https://developer.android.com/reference/kotlin/androidx/media3/decoder/DecoderInputBuffer#timeUs()` and flags are populated if this exception is thrown, but the read position is not advanced. |

### skipData

```
fun skipData(positionUs: Long): Int
```

Attempts to skip to the keyframe before the specified position, or to the end of the stream if `positionUs` is beyond it.

| Parameters |
|---|---|
| `positionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The specified time. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of samples that were skipped. |