# MediaItem.SubtitleConfiguration.Builder

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

*** ** * ** ***


```
class MediaItem.SubtitleConfiguration.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#Builder(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` Constructs an instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#build()()` Creates a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration` from the values of this builder. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setId(java.lang.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the optional ID for this subtitle track. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setLabel(java.lang.String)(label: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the optional label for this subtitle track. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setLanguage(java.lang.String)(language: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the optional language of the subtitle file. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setMimeType(java.lang.String)(mimeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the MIME type. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setRoleFlags(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.RoleFlags roleFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the role flags. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setSelectionFlags(int)(@https://developer.android.com/reference/kotlin/androidx/media3/common/C.SelectionFlags selectionFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the flags used for track selection. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setTimeOffsetUs(long)(timeOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the offset that is added to the timestamps of the cues in this subtitle track, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration.Builder#setUri(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html!)` Sets the `https://developer.android.com/reference/android/net/Uri.html` to the subtitle file. |

## Public constructors

### Builder

```
Builder(uri: Uri!)
```

Constructs an instance.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | The `https://developer.android.com/reference/android/net/Uri.html` to the subtitle file. |

## Public functions

### build

```
fun build(): MediaItem.SubtitleConfiguration!
```

Creates a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration` from the values of this builder.

### setId

```
@CanIgnoreReturnValue
fun setId(id: String?): MediaItem.SubtitleConfiguration.Builder!
```

Sets the optional ID for this subtitle track.

### setLabel

```
@CanIgnoreReturnValue
fun setLabel(label: String?): MediaItem.SubtitleConfiguration.Builder!
```

Sets the optional label for this subtitle track.

### setLanguage

```
@CanIgnoreReturnValue
fun setLanguage(language: String?): MediaItem.SubtitleConfiguration.Builder!
```

Sets the optional language of the subtitle file.

### setMimeType

```
@CanIgnoreReturnValue
fun setMimeType(mimeType: String?): MediaItem.SubtitleConfiguration.Builder!
```

Sets the MIME type.

### setRoleFlags

```
@CanIgnoreReturnValue
fun setRoleFlags(@C.RoleFlags roleFlags: Int): MediaItem.SubtitleConfiguration.Builder!
```

Sets the role flags. These are used for track selection.

### setSelectionFlags

```
@CanIgnoreReturnValue
fun setSelectionFlags(@C.SelectionFlags selectionFlags: Int): MediaItem.SubtitleConfiguration.Builder!
```

Sets the flags used for track selection.

### setTimeOffsetUs

```
@CanIgnoreReturnValue
@UnstableApi
fun setTimeOffsetUs(timeOffsetUs: Long): MediaItem.SubtitleConfiguration.Builder!
```

Sets the offset that is added to the timestamps of the cues in this subtitle track, in microseconds.

A positive value shifts the cues to be displayed later relative to the media, a negative value shifts them to be displayed earlier.

ExoPlayer specific notes:

- The offset can be changed during playback by passing an updated `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` to `Player.replaceMediaItem(int, MediaItem)`. If only the time offsets of the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.SubtitleConfiguration` instances are changed, playback continues uninterrupted and the new offsets apply to cues that have not been read by the renderer yet. To also apply the new offset to the cues currently on screen, disable and re-enable the text track, for example with `
  TrackSelectionParameters.Builder.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, boolean)`.
- The offset only takes effect if the subtitles are parsed during extraction (the default behavior of `DefaultMediaSourceFactory`), and is ignored by the deprecated legacy subtitle decoding path.

The default value is `0`.

### setUri

```
@CanIgnoreReturnValue
fun setUri(uri: Uri!): MediaItem.SubtitleConfiguration.Builder!
```

Sets the `https://developer.android.com/reference/android/net/Uri.html` to the subtitle file.