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

# SegmentBase.SegmentTemplate

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

*** ** * ** ***


```
public final class SegmentBase.SegmentTemplate extends SegmentBase.MultiSegmentBase
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.md.txt) ||||
| ↳ | [androidx.media3.exoplayer.dash.manifest.SegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.md.txt) |||
|   | ↳ | [androidx.media3.exoplayer.dash.manifest.SegmentBase.MultiSegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase.md.txt) ||
|   |   | ↳ | [androidx.media3.exoplayer.dash.manifest.SegmentBase.SegmentTemplate](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.SegmentTemplate.md.txt) |

*** ** * ** ***

A `MultiSegmentBase` that uses a SegmentTemplate to define its segments.

## Summary

| ### Public constructors |
|---|
| `SegmentTemplate( @Nullable RangedUri initialization, long timescale, long presentationTimeOffset, long startNumber, long endNumber, long duration, @Nullable List<SegmentBase.SegmentTimelineElement> segmentTimeline, long availabilityTimeOffsetUs, @Nullable UrlTemplate initializationTemplate, @Nullable UrlTemplate mediaTemplate, long timeShiftBufferDepthUs, long periodStartUnixTimeUs )` |

| ### Public methods |
|---|---|
| `SegmentBase.SegmentTemplate` | `copyWithPresentationTimeOffset(long newPresentationTimeOffset)` Returns a copy of this `SegmentBase` with its presentation time offset replaced by ` newPresentationTimeOffset`. |
| `@Nullable RangedUri` | `getInitialization(Representation representation)` Returns the `RangedUri` defining the location of initialization data for a given representation, or null if no initialization data exists. |
| `long` | `getSegmentCount(long periodDurationUs)` See `getSegmentCount`. |
| `RangedUri` | `getSegmentUrl(Representation representation, long sequenceNumber)` Returns a `RangedUri` defining the location of a segment for the given index in the given representation. |

### Inherited methods

From [androidx.media3.exoplayer.dash.manifest.SegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.md.txt) `long` `getPresentationTimeOffsetUs()`

Returns the presentation time offset, in microseconds.
From [androidx.media3.exoplayer.dash.manifest.SegmentBase.MultiSegmentBase](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/SegmentBase.MultiSegmentBase.md.txt) `long` `getAvailableSegmentCount(long periodDurationUs, long nowUnixTimeUs)`

See `getAvailableSegmentCount`.
`long` `getFirstAvailableSegmentNum(long periodDurationUs, long nowUnixTimeUs)`

See `getFirstAvailableSegmentNum`.
`long` `getFirstSegmentNum()`

See `getFirstSegmentNum`.
`long` `getNextSegmentAvailableTimeUs(
long periodDurationUs,
long nowUnixTimeUs
)`

See `getNextSegmentAvailableTimeUs`.
`final long` `getSegmentDurationUs(long sequenceNumber, long periodDurationUs)`

See `getDurationUs`.
`long` `getSegmentNum(long timeUs, long periodDurationUs)`

See `getSegmentNum`.
`final long` `getSegmentTimeUs(long sequenceNumber)`

See `getTimeUs`.
`boolean` `isExplicit()`

See `isExplicit`

## Public constructors

### SegmentTemplate

```
public SegmentTemplate(
    @Nullable RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long endNumber,
    long duration,
    @Nullable List<SegmentBase.SegmentTimelineElement> segmentTimeline,
    long availabilityTimeOffsetUs,
    @Nullable UrlTemplate initializationTemplate,
    @Nullable UrlTemplate mediaTemplate,
    long timeShiftBufferDepthUs,
    long periodStartUnixTimeUs
)
```

| Parameters |
|---|---|
| `@Nullable RangedUri initialization` | A `RangedUri` corresponding to initialization data, if such data exists. The value of this parameter is ignored if `initializationTemplate` is non-null. |
| `long timescale` | The timescale in units per second. |
| `long presentationTimeOffset` | The presentation time offset. The value in seconds is the division of this value and `timescale`. |
| `long startNumber` | The sequence number of the first segment. |
| `long endNumber` | The sequence number of the last segment as specified by the SupplementalProperty with schemeIdUri="http://dashif.org/guidelines/last-segment-number", or `INDEX_UNSET`. |
| `long duration` | 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. |
| `@Nullable List<SegmentBase.SegmentTimelineElement> segmentTimeline` | A segment timeline corresponding to the segments. If null, then segments are assumed to be of fixed duration as specified by the `duration` parameter. |
| `long availabilityTimeOffsetUs` | The offset to the current realtime at which segments become available in microseconds, or `TIME_UNSET` if not applicable. |
| `@Nullable UrlTemplate initializationTemplate` | 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. |
| `@Nullable UrlTemplate mediaTemplate` | A template defining the location of each media segment. |
| `long timeShiftBufferDepthUs` | The time shift buffer depth in microseconds. |
| `long periodStartUnixTimeUs` | The start of the enclosing period in microseconds since the Unix epoch. |

## Public methods

### copyWithPresentationTimeOffset

```
public SegmentBase.SegmentTemplate copyWithPresentationTimeOffset(long newPresentationTimeOffset)
```

Returns a copy of this `SegmentBase` with its presentation time offset replaced by `
newPresentationTimeOffset`.

### getInitialization

```
public @Nullable RangedUri getInitialization(Representation representation)
```

Returns the `RangedUri` defining the location of initialization data for a given representation, or null if no initialization data exists.

| Parameters |
|---|---|
| `Representation representation` | The `Representation` for which initialization data is required. |

| Returns |
|---|---|
| `@Nullable RangedUri` | A `RangedUri` defining the location of the initialization data, or null. |

### getSegmentCount

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

See `getSegmentCount`.

### getSegmentUrl

```
public RangedUri getSegmentUrl(Representation representation, long sequenceNumber)
```

Returns a `RangedUri` defining the location of a segment for the given index in the given representation.

See `getSegmentUrl`.