# 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
public final class EmptySampleStream implements SampleStream
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/EmptySampleStream#isReady()()` Returns whether data is available to be read. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/EmptySampleStream#maybeThrowError()()` Throws an error that's preventing data from being read. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/EmptySampleStream#readData(androidx.media3.exoplayer.FormatHolder,androidx.media3.decoder.DecoderInputBuffer,int)( https://developer.android.com/reference/androidx/media3/exoplayer/FormatHolder formatHolder, https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer buffer, @https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream.ReadFlags int readFlags )` Attempts to read from the stream. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/EmptySampleStream#skipData(long)(long positionUs)` 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/androidx/media3/exoplayer/source/SampleStream) |---|---| | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream#FLAG_HAS_PREROLL() = 4` Specifies that the stream contains a preroll of decode-only samples. | | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream#FLAG_MAYBE_HAS_PREROLL() = 2` Specifies that the stream may contain preroll samples. | | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream#FLAG_OMIT_SAMPLE_DATA() = 4` Specifies that `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer#data()`, `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer#supplementalData()` and `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer#cryptoInfo()` should not be populated when reading a sample buffer. | | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream#FLAG_PEEK() = 1` Specifies that the read position should not be advanced if a sample buffer is read. | | `static final int` | `https://developer.android.com/reference/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. | | `static final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream#FLAG_STRICT_DURATION() = 1` Specifies that playout of the stream should be stopped once the duration is reached. | |

| ### Inherited methods |
|---|
| From [androidx.media3.exoplayer.source.SampleStream](https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream) |---|---| | `int` | `@https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream.Flags https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream#getFlags()()` Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream.Flags` set on this stream. | |

## Public constructors

### EmptySampleStream

```
public EmptySampleStream()
```

## Public methods

### isReady

```
public boolean isReady()
```

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/androidx/media3/exoplayer/source/SampleStream#readData(androidx.media3.exoplayer.FormatHolder,androidx.media3.decoder.DecoderInputBuffer,int)`. Hence an ended stream is always ready.

| Returns |
|---|---|
| `boolean` | Whether data is available to be read. |

### maybeThrowError

```
public void maybeThrowError()
```

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

```
public int readData(
    FormatHolder formatHolder,
    DecoderInputBuffer buffer,
    @SampleStream.ReadFlags int readFlags
)
```

Attempts to read from the stream.

If the stream has ended then `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set on `
buffer` and `https://developer.android.com/reference/androidx/media3/common/C#RESULT_BUFFER_READ()` is returned. Else if no data is available then `https://developer.android.com/reference/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/androidx/media3/common/C#RESULT_FORMAT_READ()` is returned. Else `buffer` is populated and `https://developer.android.com/reference/androidx/media3/common/C#RESULT_BUFFER_READ()` is returned.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/FormatHolder formatHolder` | A `https://developer.android.com/reference/androidx/media3/exoplayer/FormatHolder` to populate in the case of reading a format. |
| `https://developer.android.com/reference/androidx/media3/decoder/DecoderInputBuffer buffer` | A `https://developer.android.com/reference/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/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag will be set on the buffer. |
| `@https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream.ReadFlags int readFlags` | Flags controlling the behavior of this read operation. |

| Returns |
|---|---|
| `int` | The `https://developer.android.com/reference/androidx/media3/exoplayer/source/SampleStream.ReadDataResult` of the read operation. |

| Throws |
|---|---|
| `https://developer.android.com/reference/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/androidx/media3/decoder/DecoderInputBuffer#timeUs()` and flags are populated if this exception is thrown, but the read position is not advanced. |

### skipData

```
public int skipData(long positionUs)
```

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

| Parameters |
|---|---|
| `long positionUs` | The specified time. |

| Returns |
|---|---|
| `int` | The number of samples that were skipped. |