# HlsMediaPlaylist.Segment

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

*** ** * ** ***


```
public final class HlsMediaPlaylist.Segment extends HlsMediaPlaylist.SegmentBase
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.SegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase) ||
|   | ↳ | [androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.Segment](https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment) |

*** ** * ** ***

Media segment reference.

## Summary

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Part>` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#parts()` The parts belonging to this segment. |
| `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#title()` The human readable title of the segment. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#Segment(java.lang.String,long,long,java.lang.String,java.lang.String)( https://developer.android.com/reference/java/lang/String.html uri, long byteRangeOffset, long byteRangeLength, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html fullSegmentEncryptionKeyUri, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html encryptionIV )` Creates an instance to be used as init segment. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#Segment(java.lang.String,androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.Segment,java.lang.String,long,int,long,androidx.media3.common.DrmInitData,java.lang.String,java.lang.String,long,long,boolean,java.util.List<androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.Part>)( https://developer.android.com/reference/java/lang/String.html url, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment initializationSegment, https://developer.android.com/reference/java/lang/String.html title, long durationUs, int relativeDiscontinuitySequence, long relativeStartTimeUs, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/DrmInitData drmInitData, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html fullSegmentEncryptionKeyUri, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html encryptionIV, long byteRangeOffset, long byteRangeLength, boolean hasGapTag, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Part> parts )` Creates an instance. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#copyWith(long,int)(long relativeStartTimeUs, int relativeDiscontinuitySequence)` |

| ### Inherited fields |
|---|
| From [androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.SegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase) |---|---| | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#byteRangeLength()` The segment's byte range length, as defined by #EXT-X-BYTERANGE, #EXT-X-PART or #EXT-X-PRELOAD-HINT, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if no byte range is specified or the byte range is open-ended. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#byteRangeOffset()` The segment's byte range offset, as defined by #EXT-X-BYTERANGE, #EXT-X-PART or #EXT-X-PRELOAD-HINT. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/DrmInitData` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#drmInitData()` DRM initialization data for sample decryption, or null if the segment does not use CDM-DRM protection. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#durationUs()` The duration of the segment in microseconds, as defined by #EXTINF or #EXT-X-PART. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#encryptionIV()` The encryption initialization vector as defined by #EXT-X-KEY, or null if the segment is not encrypted. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#fullSegmentEncryptionKeyUri()` The encryption identity key uri as defined by #EXT-X-KEY, or null if the segment does not use full segment encryption with identity key. | | `final boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#hasGapTag()` Whether the segment is marked as a gap. | | `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#initializationSegment()` The media initialization section for this segment, as defined by #EXT-X-MAP. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#relativeDiscontinuitySequence()` The number of #EXT-X-DISCONTINUITY tags in the playlist before the segment. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#relativeStartTimeUs()` The start time of the segment in microseconds, relative to the start of the playlist. | | `final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#url()` The url of the segment. | |

| ### Inherited methods |
|---|
| From [java.lang.Comparable](https://developer.android.com/reference/java/lang/Comparable.html) |---|---| | `abstract int` | `https://developer.android.com/reference/java/lang/Comparable.html#compareTo(T)(T p)` | |
| From [androidx.media3.exoplayer.hls.playlist.HlsMediaPlaylist.SegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase) |---|---| | `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#compareTo(java.lang.Long)(https://developer.android.com/reference/java/lang/Long.html relativeStartTimeUs)` | |

## Public fields

### parts

```
public final List<HlsMediaPlaylist.Part> parts
```

The parts belonging to this segment.

### title

```
public final String title
```

The human readable title of the segment.

## Public constructors

### Segment

```
public Segment(
    String uri,
    long byteRangeOffset,
    long byteRangeLength,
    @Nullable String fullSegmentEncryptionKeyUri,
    @Nullable String encryptionIV
)
```

Creates an instance to be used as init segment.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html uri` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#url()`. |
| `long byteRangeOffset` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#byteRangeOffset()`. |
| `long byteRangeLength` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#byteRangeLength()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html fullSegmentEncryptionKeyUri` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#fullSegmentEncryptionKeyUri()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html encryptionIV` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#encryptionIV()`. |

### Segment

```
public Segment(
    String url,
    @Nullable HlsMediaPlaylist.Segment initializationSegment,
    String title,
    long durationUs,
    int relativeDiscontinuitySequence,
    long relativeStartTimeUs,
    @Nullable DrmInitData drmInitData,
    @Nullable String fullSegmentEncryptionKeyUri,
    @Nullable String encryptionIV,
    long byteRangeOffset,
    long byteRangeLength,
    boolean hasGapTag,
    List<HlsMediaPlaylist.Part> parts
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html url` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#url()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment initializationSegment` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#initializationSegment()`. |
| `https://developer.android.com/reference/java/lang/String.html title` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#title()`. |
| `long durationUs` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#durationUs()`. |
| `int relativeDiscontinuitySequence` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#relativeDiscontinuitySequence()`. |
| `long relativeStartTimeUs` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#relativeStartTimeUs()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/DrmInitData drmInitData` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#drmInitData()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html fullSegmentEncryptionKeyUri` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#fullSegmentEncryptionKeyUri()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html encryptionIV` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#encryptionIV()`. |
| `long byteRangeOffset` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#byteRangeOffset()`. |
| `long byteRangeLength` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#byteRangeLength()`. |
| `boolean hasGapTag` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.SegmentBase#hasGapTag()`. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Part> parts` | See `https://developer.android.com/reference/androidx/media3/exoplayer/hls/playlist/HlsMediaPlaylist.Segment#parts()`. |

## Public methods

### copyWith

```
public HlsMediaPlaylist.Segment copyWith(long relativeStartTimeUs, int relativeDiscontinuitySequence)
```