> Documentation index: https://developer.android.com/reference/llms.txt

# HlsMediaPlaylist.Interstitial.Builder

Artifact: [androidx.media3:media3-exoplayer-hls](https://developer.android.com/jetpack/androidx/releases/media3.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.java+class:androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.Interstitial.Builder)

*** ** * ** ***


```
public final class HlsMediaPlaylist.Interstitial.Builder
```

<br />

*** ** * ** ***

Builder for `Interstitial`.

See RFC 8216bis, section 4.4.5.1 for how to consolidate multiple interstitials with the same `ID`.

## Summary

| ### Public constructors |
|---|
| `Builder(String id)` Creates the builder. |

| ### Public methods |
|---|---|
| `@Nullable HlsMediaPlaylist.Interstitial` | `build()` Builds and returns a new `Interstitial` instance or null if validation of the properties fails. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setAssetListUri(@Nullable Uri assetListUri)` Sets the asset list URI. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setAssetUri(@Nullable Uri assetUri)` Sets the asset URI. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setClientDefinedAttributes( List<HlsMediaPlaylist.ClientDefinedAttribute> clientDefinedAttributes )` Sets the `client defined attributes`. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setContentMayVary(@Nullable Boolean contentMayVary)` Sets whether the content may vary between clients. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setCue(List<@HlsMediaPlaylist.Interstitial.CueTriggerType String> cue)` Sets the `cue trigger types`. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setDurationUs(long durationUs)` Sets the duration, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setEndDateUnixUs(long endDateUnixUs)` Sets the end date as a unix epoch timestamp, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setEndOnNext(boolean endOnNext)` Sets whether the interstitial ends on the start time of the next interstitial. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setPlannedDurationUs(long plannedDurationUs)` Sets the planned duration, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setPlayoutLimitUs(long playoutLimitUs)` Sets the play out limit, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setRestrictions( List<@HlsMediaPlaylist.Interstitial.NavigationRestriction String> restrictions )` Sets the `navigation restrictions`. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setResumeOffsetUs(long resumeOffsetUs)` Sets the resume offset, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setSkipControlDurationUs(long skipControlDurationUs)` Sets the skip control duration, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setSkipControlLabelId(@Nullable String skipControlLabelId)` Sets the skip control label ID. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setSkipControlOffsetUs(long skipControlOffsetUs)` Sets the skip control offset, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setSnapTypes( List<@HlsMediaPlaylist.Interstitial.SnapType String> snapTypes )` Sets the `snap types`. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setStartDateUnixUs(long startDateUnixUs)` Sets the start date as a unix epoch timestamp, in microseconds. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setTimelineOccupies( @HlsMediaPlaylist.Interstitial.TimelineOccupiesType @Nullable @HlsMediaPlaylist.Interstitial.TimelineOccupiesType String timelineOccupies )` Sets the `timeline occupies type`. |
| `HlsMediaPlaylist.Interstitial.Builder` | `@CanIgnoreReturnValue setTimelineStyle( @HlsMediaPlaylist.Interstitial.TimelineStyleType @Nullable @HlsMediaPlaylist.Interstitial.TimelineStyleType String timelineStyle )` Sets the `timeline style type`. |

## Public constructors

### Builder

```
public Builder(String id)
```

Creates the builder.

| Parameters |
|---|---|
| `String id` | The id. |

## Public methods

### build

```
public @Nullable HlsMediaPlaylist.Interstitial build()
```

Builds and returns a new `Interstitial` instance or null if validation of the properties fails. The properties are considered invalid, if the start date is missing or both asset URI and asset list URI are set at the same time.

### setAssetListUri

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setAssetListUri(@Nullable Uri assetListUri)
```

Sets the asset list URI.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a non-null value that is different to the value previously set. |

### setAssetUri

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setAssetUri(@Nullable Uri assetUri)
```

Sets the asset URI.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a non-null value that is different to the value previously set. |

### setClientDefinedAttributes

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setClientDefinedAttributes(
    List<HlsMediaPlaylist.ClientDefinedAttribute> clientDefinedAttributes
)
```

Sets the `client defined attributes`.

Equal duplicates are ignored, new attributes are added to those already set.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a list containing a client defined attribute that is not equal with an attribute previously set with the same ` name`. |

### setContentMayVary

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setContentMayVary(@Nullable Boolean contentMayVary)
```

Sets whether the content may vary between clients.

The default value is `true` .

| Parameters |
|---|---|
| `@Nullable Boolean contentMayVary` | Whether the content may vary. |

| Returns |
|---|---|
| `HlsMediaPlaylist.Interstitial.Builder` | This builder. |

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if attempting to change a value that is already set to a different value. |

### setCue

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setCue(List<@HlsMediaPlaylist.Interstitial.CueTriggerType String> cue)
```

Sets the `cue trigger types`.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setDurationUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setDurationUs(long durationUs)
```

Sets the duration, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setEndDateUnixUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setEndDateUnixUs(long endDateUnixUs)
```

Sets the end date as a unix epoch timestamp, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setEndOnNext

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setEndOnNext(boolean endOnNext)
```

Sets whether the interstitial ends on the start time of the next interstitial.

Once set to true, it can't be reset to false and doing so would be ignored.

### setPlannedDurationUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setPlannedDurationUs(long plannedDurationUs)
```

Sets the planned duration, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setPlayoutLimitUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setPlayoutLimitUs(long playoutLimitUs)
```

Sets the play out limit, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setRestrictions

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setRestrictions(
    List<@HlsMediaPlaylist.Interstitial.NavigationRestriction String> restrictions
)
```

Sets the `navigation restrictions`.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a non-empty list of restrictions that is not equal to the non-empty list that was previously set. |

### setResumeOffsetUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setResumeOffsetUs(long resumeOffsetUs)
```

Sets the resume offset, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setSkipControlDurationUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setSkipControlDurationUs(long skipControlDurationUs)
```

Sets the skip control duration, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setSkipControlLabelId

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setSkipControlLabelId(@Nullable String skipControlLabelId)
```

Sets the skip control label ID.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a non-null value that is different to the value previously set. |

### setSkipControlOffsetUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setSkipControlOffsetUs(long skipControlOffsetUs)
```

Sets the skip control offset, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setSnapTypes

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setSnapTypes(
    List<@HlsMediaPlaylist.Interstitial.SnapType String> snapTypes
)
```

Sets the `snap types`.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a non-empty list of snap types that is not equal to the non-empty list that was previously set. |

### setStartDateUnixUs

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setStartDateUnixUs(long startDateUnixUs)
```

Sets the start date as a unix epoch timestamp, in microseconds.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if called with a value different to `TIME_UNSET` and different to the value previously set. |

### setTimelineOccupies

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setTimelineOccupies(
    @HlsMediaPlaylist.Interstitial.TimelineOccupiesType @Nullable @HlsMediaPlaylist.Interstitial.TimelineOccupiesType String timelineOccupies
)
```

Sets the `timeline occupies type`.

The default value is `TIMELINE_OCCUPIES_POINT`.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if attempting to change a value that is already set to a different value. |

### setTimelineStyle

```
@CanIgnoreReturnValue
public HlsMediaPlaylist.Interstitial.Builder setTimelineStyle(
    @HlsMediaPlaylist.Interstitial.TimelineStyleType @Nullable @HlsMediaPlaylist.Interstitial.TimelineStyleType String timelineStyle
)
```

Sets the `timeline style type`. The default value is `TIMELINE_STYLE_HIGHLIGHT`.

| Throws |
|---|---|
| `java.lang.IllegalArgumentException` | if attempting to change from a non-default value to a different non-default value. |