# Representation.MultiSegmentRepresentation

Artifact: [androidx.media3:media3-exoplayer-dash](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/dash/manifest/Representation.java+class:androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation)

*** ** * ** ***


```
public class Representation.MultiSegmentRepresentation extends Representation implements DashSegmentIndex
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.media3.exoplayer.dash.manifest.Representation](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation) ||
|   | ↳ | [androidx.media3.exoplayer.dash.manifest.Representation.MultiSegmentRepresentation](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation) |

*** ** * ** ***

A DASH representation consisting of multiple segments.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#MultiSegmentRepresentation(long,androidx.media3.common.Format,java.util.List<androidx.media3.exoplayer.dash.manifest.BaseUrl>,androidx.media3.exoplayer.dash.manifest.SegmentBase.MultiSegmentBase,java.util.List<androidx.media3.exoplayer.dash.manifest.Descriptor>,java.util.List<androidx.media3.exoplayer.dash.manifest.Descriptor>,java.util.List<androidx.media3.exoplayer.dash.manifest.Descriptor>)( long revisionId, https://developer.android.com/reference/androidx/media3/common/Format format, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/BaseUrl> baseUrls, https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase segmentBase, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> inbandEventStreams, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> essentialProperties, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> supplementalProperties )` Creates the multi-segment Representation. |

| ### Public methods |
|---|---|
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getAvailableSegmentCount(long,long)(long periodDurationUs, long nowUnixTimeUs)` Returns the number of available segments in the index. |
| `@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/dash/manifest/Representation.MultiSegmentRepresentation#getCacheKey()()` Returns a cache key for the representation if set, or null. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getDurationUs(long,long)(long segmentNum, long periodDurationUs)` Returns the duration of a segment. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getFirstAvailableSegmentNum(long,long)(long periodDurationUs, long nowUnixTimeUs)` Returns the segment number of the first available segment in the index. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getFirstSegmentNum()()` Returns the segment number of the first defined segment in the index. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getIndex()()` Returns an index if the representation provides one directly, or null otherwise. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getIndexUri()()` Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of the representation's segment index, or null if the representation provides an index directly. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getNextSegmentAvailableTimeUs(long,long)( long periodDurationUs, long nowUnixTimeUs )` Returns the time, in microseconds, at which a new segment becomes available, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if not applicable. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getSegmentCount(long)(long periodDurationUs)` Returns the number of segments defined in the index, or `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex#INDEX_UNBOUNDED()`. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getSegmentNum(long,long)(long timeUs, long periodDurationUs)` Returns `getFirstSegmentNum()` if the index has no segments or if the given media time is earlier than the start of the first segment. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getSegmentUrl(long)(long segmentNum)` Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of a segment. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#getTimeUs(long)(long segmentNum)` Returns the start time of a segment. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation.MultiSegmentRepresentation#isExplicit()()` Returns true if segments are defined explicitly by the index. |

### Inherited Constants

From [androidx.media3.exoplayer.dash.DashSegmentIndex](https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex) `static final int` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex#INDEX_UNBOUNDED() = -1` From [androidx.media3.exoplayer.dash.manifest.Representation](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation) `static final long` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#REVISION_ID_DEFAULT() = -1`

A default value for `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#revisionId()`.

### Inherited fields

From [androidx.media3.exoplayer.dash.manifest.Representation](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation) `final https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/BaseUrl>` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#baseUrls()`

The base URLs of the representation.
`final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor>` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#essentialProperties()`

Essential properties in the representation.
`final https://developer.android.com/reference/androidx/media3/common/Format` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#format()`

The format of the representation.
`final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor>` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#inbandEventStreams()`

The in-band event streams in the representation.
`final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#initializationUri()` `final long` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#presentationTimeOffsetUs()`

The offset of the presentation timestamps in the media stream relative to media time.
`final long` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#revisionId()`

Identifies the revision of the media contained within the representation.
`final https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor>` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#supplementalProperties()`

Supplemental properties in the adaptation set.
`final long` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#timescale()`

The timescale of the representation in units per second.

### Inherited methods

From [androidx.media3.exoplayer.dash.manifest.Representation](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation) `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#getInitializationUri()()`

Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of the representation's initialization data, or null if no initialization data exists.
`static https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#newInstance(long,androidx.media3.common.Format,java.util.List<androidx.media3.exoplayer.dash.manifest.BaseUrl>,androidx.media3.exoplayer.dash.manifest.SegmentBase)(
long revisionId,
https://developer.android.com/reference/androidx/media3/common/Format format,
https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/BaseUrl> baseUrls,
https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase segmentBase
)`

Constructs a new instance.
`static https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation` `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Representation#newInstance(long,androidx.media3.common.Format,java.util.List<androidx.media3.exoplayer.dash.manifest.BaseUrl>,androidx.media3.exoplayer.dash.manifest.SegmentBase,java.util.List<androidx.media3.exoplayer.dash.manifest.Descriptor>,java.util.List<androidx.media3.exoplayer.dash.manifest.Descriptor>,java.util.List<androidx.media3.exoplayer.dash.manifest.Descriptor>,java.lang.String)(
long revisionId,
https://developer.android.com/reference/androidx/media3/common/Format format,
https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/BaseUrl> baseUrls,
https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase segmentBase,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> inbandEventStreams,
https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> essentialProperties,
https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> supplementalProperties,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html cacheKey
)`

Constructs a new instance.

## Public constructors

### MultiSegmentRepresentation

```
public MultiSegmentRepresentation(
    long revisionId,
    Format format,
    List<BaseUrl> baseUrls,
    SegmentBase.MultiSegmentBase segmentBase,
    @Nullable List<Descriptor> inbandEventStreams,
    List<Descriptor> essentialProperties,
    List<Descriptor> supplementalProperties
)
```

Creates the multi-segment Representation.

| Parameters |
|---|---|
| `long revisionId` | Identifies the revision of the content. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The format of the representation. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/BaseUrl> baseUrls` | The base URLs of the representation. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase segmentBase` | The segment base underlying the representation. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> inbandEventStreams` | The in-band event streams in the representation. May be null. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> essentialProperties` | Essential properties in the representation. May be empty. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/Descriptor> supplementalProperties` | Supplemental properties in the representation. May be empty. |

## Public methods

### getAvailableSegmentCount

```
public long getAvailableSegmentCount(long periodDurationUs, long nowUnixTimeUs)
```

Returns the number of available segments in the index.

| Parameters |
|---|---|
| `long periodDurationUs` | The duration of the enclosing period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the period's duration is not yet known. |
| `long nowUnixTimeUs` | The current time in milliseconds since the Unix epoch. |

| Returns |
|---|---|
| `long` | The number of available segments in the index. |

### getCacheKey

```
public @Nullable String getCacheKey()
```

Returns a cache key for the representation if set, or null.

### getDurationUs

```
public long getDurationUs(long segmentNum, long periodDurationUs)
```

Returns the duration of a segment.

| Parameters |
|---|---|
| `long segmentNum` | The segment number. |
| `long periodDurationUs` | The duration of the enclosing period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the period's duration is not yet known. |

| Returns |
|---|---|
| `long` | The duration of the segment, in microseconds. |

### getFirstAvailableSegmentNum

```
public long getFirstAvailableSegmentNum(long periodDurationUs, long nowUnixTimeUs)
```

Returns the segment number of the first available segment in the index.

| Parameters |
|---|---|
| `long periodDurationUs` | The duration of the enclosing period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the period's duration is not yet known. |
| `long nowUnixTimeUs` | The current time in milliseconds since the Unix epoch. |

| Returns |
|---|---|
| `long` | The number of the first available segment. |

### getFirstSegmentNum

```
public long getFirstSegmentNum()
```

Returns the segment number of the first defined segment in the index.

### getIndex

```
public DashSegmentIndex getIndex()
```

Returns an index if the representation provides one directly, or null otherwise.

### getIndexUri

```
public @Nullable RangedUri getIndexUri()
```

Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of the representation's segment index, or null if the representation provides an index directly.

### getNextSegmentAvailableTimeUs

```
public long getNextSegmentAvailableTimeUs(
    long periodDurationUs,
    long nowUnixTimeUs
)
```

Returns the time, in microseconds, at which a new segment becomes available, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if not applicable.

| Parameters |
|---|---|
| `long periodDurationUs` | The duration of the enclosing period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the period's duration is not yet known. |
| `long nowUnixTimeUs` | The current time in milliseconds since the Unix epoch. |

| Returns |
|---|---|
| `long` | The time, in microseconds, at which a new segment becomes available, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if not applicable. |

### getSegmentCount

```
public long getSegmentCount(long periodDurationUs)
```

Returns the number of segments defined in the index, or `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex#INDEX_UNBOUNDED()`.

An unbounded index occurs if a dynamic manifest uses SegmentTemplate elements without a SegmentTimeline element, and if the period duration is not yet known. In this case the caller can query the available segment using `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex#getFirstAvailableSegmentNum(long,long)` and `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex#getAvailableSegmentCount(long,long)`.

| Parameters |
|---|---|
| `long periodDurationUs` | The duration of the enclosing period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the period's duration is not yet known. |

| Returns |
|---|---|
| `long` | The number of segments in the index, or `https://developer.android.com/reference/androidx/media3/exoplayer/dash/DashSegmentIndex#INDEX_UNBOUNDED()`. |

### getSegmentNum

```
public long getSegmentNum(long timeUs, long periodDurationUs)
```

Returns `getFirstSegmentNum()` if the index has no segments or if the given media time is earlier than the start of the first segment. Returns `getFirstSegmentNum() +
getSegmentCount() - 1` if the given media time is later than the end of the last segment. Otherwise, returns the segment number of the segment containing the given media time.

| Parameters |
|---|---|
| `long timeUs` | The time in microseconds. |
| `long periodDurationUs` | The duration of the enclosing period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the period's duration is not yet known. |

| Returns |
|---|---|
| `long` | The segment number of the corresponding segment. |

### getSegmentUrl

```
public RangedUri getSegmentUrl(long segmentNum)
```

Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of a segment.

| Parameters |
|---|---|
| `long segmentNum` | The segment number. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` | The `https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of the data. |

### getTimeUs

```
public long getTimeUs(long segmentNum)
```

Returns the start time of a segment.

| Parameters |
|---|---|
| `long segmentNum` | The segment number. |

| Returns |
|---|---|
| `long` | The corresponding start time in microseconds. |

### isExplicit

```
public boolean isExplicit()
```

Returns true if segments are defined explicitly by the index.

If true is returned, each segment is defined explicitly by the index data, and all of the listed segments are guaranteed to be available at the time when the index was obtained.

If false is returned then segment information was derived from properties such as a fixed segment duration. If the presentation is dynamic, it's possible that only a subset of the segments are available.

| Returns |
|---|---|
| `boolean` | Whether segments are defined explicitly by the index. |