# SegmentBase.SegmentTemplate

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/SegmentBase.java+class:androidx.media3.exoplayer.dash.manifest.SegmentBase.SegmentTemplate)

*** ** * ** ***


```
class SegmentBase.SegmentTemplate : SegmentBase.MultiSegmentBase
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [androidx.media3.exoplayer.dash.manifest.SegmentBase](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase) |||
|   | ↳ | [androidx.media3.exoplayer.dash.manifest.SegmentBase.MultiSegmentBase](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase) ||
|   |   | ↳ | [androidx.media3.exoplayer.dash.manifest.SegmentBase.SegmentTemplate](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate) |

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase` that uses a SegmentTemplate to define its segments.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate#SegmentTemplate(androidx.media3.exoplayer.dash.manifest.RangedUri,long,long,long,long,long,java.util.List<androidx.media3.exoplayer.dash.manifest.SegmentBase.SegmentTimelineElement>,long,androidx.media3.exoplayer.dash.manifest.UrlTemplate,androidx.media3.exoplayer.dash.manifest.UrlTemplate,long,long)( initialization: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri?, timescale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, presentationTimeOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, startNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, endNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, duration: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, segmentTimeline: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTimelineElement!>?, availabilityTimeOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, initializationTemplate: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate?, mediaTemplate: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate?, timeShiftBufferDepthUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, periodStartUnixTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate#copyWithPresentationTimeOffset(long)(newPresentationTimeOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns a copy of this `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase` with its presentation time offset replaced by ` newPresentationTimeOffset`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate#getInitialization(androidx.media3.exoplayer.dash.manifest.Representation)(representation: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/Representation!)` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of initialization data for a given representation, or null if no initialization data exists. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate#getSegmentCount(long)(periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getSegmentCount(long)`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate#getSegmentUrl(androidx.media3.exoplayer.dash.manifest.Representation,long)(representation: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/Representation!, sequenceNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of a segment for the given index in the given representation. |

### Inherited functions

From [androidx.media3.exoplayer.dash.manifest.SegmentBase](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase#getPresentationTimeOffsetUs()()`

Returns the presentation time offset, in microseconds.
From [androidx.media3.exoplayer.dash.manifest.SegmentBase.MultiSegmentBase](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getAvailableSegmentCount(long,long)(periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, nowUnixTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getAvailableSegmentCount(long,long)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getFirstAvailableSegmentNum(long,long)(periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, nowUnixTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getFirstAvailableSegmentNum(long,long)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getFirstSegmentNum()()`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getFirstSegmentNum()`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getNextSegmentAvailableTimeUs(long,long)(
periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html,
nowUnixTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html
)`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getNextSegmentAvailableTimeUs(long,long)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getSegmentDurationUs(long,long)(sequenceNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getDurationUs(long,long)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getSegmentNum(long,long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, periodDurationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getSegmentNum(long,long)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#getSegmentTimeUs(long)(sequenceNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getTimeUs(long)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase#isExplicit()()`

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#isExplicit()`

## Public constructors

### SegmentTemplate

```
SegmentTemplate(
    initialization: RangedUri?,
    timescale: Long,
    presentationTimeOffset: Long,
    startNumber: Long,
    endNumber: Long,
    duration: Long,
    segmentTimeline: (Mutable)List<SegmentBase.SegmentTimelineElement!>?,
    availabilityTimeOffsetUs: Long,
    initializationTemplate: UrlTemplate?,
    mediaTemplate: UrlTemplate?,
    timeShiftBufferDepthUs: Long,
    periodStartUnixTimeUs: Long
)
```

| Parameters |
|---|---|
| `initialization: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri?` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri` corresponding to initialization data, if such data exists. The value of this parameter is ignored if `initializationTemplate` is non-null. |
| `timescale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The timescale in units per second. |
| `presentationTimeOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The presentation time offset. The value in seconds is the division of this value and `timescale`. |
| `startNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The sequence number of the first segment. |
| `endNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The sequence number of the last segment as specified by the SupplementalProperty with schemeIdUri="http://dashif.org/guidelines/last-segment-number", or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()`. |
| `duration: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of each segment in the case of fixed duration segments. The value in seconds is the division of this value and `timescale`. If ` segmentTimeline` is non-null then this parameter is ignored. |
| `segmentTimeline: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTimelineElement!>?` | A segment timeline corresponding to the segments. If null, then segments are assumed to be of fixed duration as specified by the `duration` parameter. |
| `availabilityTimeOffsetUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The offset to the current realtime at which segments become available in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if not applicable. |
| `initializationTemplate: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate?` | A template defining the location of initialization data, if such data exists. If non-null then the `initialization` parameter is ignored. If null then `initialization` will be used. |
| `mediaTemplate: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate?` | A template defining the location of each media segment. |
| `timeShiftBufferDepthUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The time shift buffer depth in microseconds. |
| `periodStartUnixTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The start of the enclosing period in microseconds since the Unix epoch. |

## Public functions

### copyWithPresentationTimeOffset

```
fun copyWithPresentationTimeOffset(newPresentationTimeOffset: Long): SegmentBase.SegmentTemplate!
```

Returns a copy of this `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/SegmentBase` with its presentation time offset replaced by `
newPresentationTimeOffset`.

### getInitialization

```
fun getInitialization(representation: Representation!): RangedUri?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of initialization data for a given representation, or null if no initialization data exists.

| Parameters |
|---|---|
| `representation: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/Representation!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/Representation` for which initialization data is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri?` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of the initialization data, or null. |

### getSegmentCount

```
fun getSegmentCount(periodDurationUs: Long): Long
```

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getSegmentCount(long)`.

### getSegmentUrl

```
fun getSegmentUrl(representation: Representation!, sequenceNumber: Long): RangedUri!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/RangedUri` defining the location of a segment for the given index in the given representation.

See `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DashSegmentIndex#getSegmentUrl(long)`.