# SubtitleOutputBuffer

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

*** ** * ** ***


```
@UnstableApi
public abstract class SubtitleOutputBuffer extends DecoderOutputBuffer implements Subtitle
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [androidx.media3.decoder.Buffer](https://developer.android.com/reference/androidx/media3/decoder/Buffer) |||
|   | ↳ | [androidx.media3.decoder.DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer) ||
|   |   | ↳ | [androidx.media3.extractor.text.SubtitleOutputBuffer](https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer) |

*** ** * ** ***

Base class for `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleDecoder` output buffers.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#SubtitleOutputBuffer()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#clear()()` Clears the buffer. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/text/Cue>` | `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#getCues(long)(long timeUs)` Retrieve the cues that should be displayed at a given time. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#getEventTime(int)(int index)` Returns the event time at a specified index. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#getEventTimeCount()()` Returns the number of event times, where events are defined as points in time at which the cues returned by `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle#getCues(long)` changes. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#getNextEventTimeIndex(long)(long timeUs)` Returns the index of the first event that occurs after a given time (exclusive). |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleOutputBuffer#setContent(long,androidx.media3.extractor.text.Subtitle,long)(long timeUs, https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle subtitle, long subsampleOffsetUs)` Sets the content of the output buffer, consisting of a `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle` and associated metadata. |

### Inherited fields

From [androidx.media3.decoder.DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer) `boolean` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#shouldBeSkipped()`

Whether this buffer should be skipped, usually because the decoding process generated no data or invalid data.
`int` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#skippedOutputBufferCount()`

The number of buffers immediately prior to this one that were skipped in the `https://developer.android.com/reference/androidx/media3/decoder/Decoder`.
`long` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#timeUs()`

The presentation timestamp for the buffer, in microseconds.

### Inherited methods

From [androidx.media3.decoder.Buffer](https://developer.android.com/reference/androidx/media3/decoder/Buffer) `final void` `https://developer.android.com/reference/androidx/media3/decoder/Buffer#addFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)`

Adds the `flag` to this buffer's flags.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/Buffer#clearFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)`

Removes the `flag` from this buffer's flags, if it is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#getFlag(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flag)`

Returns whether the specified flag has been set on this buffer.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#hasSupplementalData()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isEndOfStream()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_END_OF_STREAM()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isFirstSample()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_FIRST_SAMPLE()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isKeyFrame()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_KEY_FRAME()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#isLastSample()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_LAST_SAMPLE()` flag is set.
`final boolean` `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html
https://developer.android.com/reference/androidx/media3/decoder/Buffer#notDependedOn()()`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/C#BUFFER_FLAG_NOT_DEPENDED_ON()` flag is set.
`final void` `https://developer.android.com/reference/androidx/media3/decoder/Buffer#setFlags(int)(@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flags)`

Replaces this buffer's flags with `flags`.
From [androidx.media3.decoder.DecoderOutputBuffer](https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer) `abstract void` `https://developer.android.com/reference/androidx/media3/decoder/DecoderOutputBuffer#release()()`

Releases the output buffer for reuse.

## Public constructors

### SubtitleOutputBuffer

```
public SubtitleOutputBuffer()
```

## Public methods

### clear

```
public void clear()
```

Clears the buffer.

### getCues

```
public List<Cue> getCues(long timeUs)
```

Retrieve the cues that should be displayed at a given time.

| Parameters |
|---|---|
| `long timeUs` | The time in microseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/text/Cue>` | A list of cues that should be displayed, possibly empty. |

### getEventTime

```
public long getEventTime(int index)
```

Returns the event time at a specified index.

| Parameters |
|---|---|
| `int index` | The index of the event time to obtain. |

| Returns |
|---|---|
| `long` | The event time in microseconds. |

### getEventTimeCount

```
public int getEventTimeCount()
```

Returns the number of event times, where events are defined as points in time at which the cues returned by `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle#getCues(long)` changes.

| Returns |
|---|---|
| `int` | The number of event times. |

### getNextEventTimeIndex

```
public int getNextEventTimeIndex(long timeUs)
```

Returns the index of the first event that occurs after a given time (exclusive).

| Parameters |
|---|---|
| `long timeUs` | The time in microseconds. |

| Returns |
|---|---|
| `int` | The index of the next event, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if there are no events after the specified time. |

### setContent

```
public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs)
```

Sets the content of the output buffer, consisting of a `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle` and associated metadata.

| Parameters |
|---|---|
| `long timeUs` | The time of the start of the subtitle in microseconds. |
| `https://developer.android.com/reference/androidx/media3/extractor/text/Subtitle subtitle` | The subtitle. |
| `long subsampleOffsetUs` | An offset that must be added to the subtitle's event times, or `https://developer.android.com/reference/androidx/media3/common/Format#OFFSET_SAMPLE_RELATIVE()` if `timeUs` should be added. |