# UrlTemplate

# UrlTemplate

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/dash/manifest/UrlTemplate "View this page in Java")

<br />

```
@UnstableApi
class UrlTemplate
```

<br />

*** ** * ** ***

A template from which URLs can be built.

URLs are built according to the substitution rules defined in ISO/IEC 23009-1:2014 5.3.9.4.4.

## Summary

|                                                        ### Public functions                                                        |
|------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!`                                               | [buildUri](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate#buildUri(java.lang.String,long,int,long))`(` ` representationId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!,` ` segmentNumber: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` bandwidth: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` time: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Constructs a Uri from the template, substituting in the provided arguments. |
| `java-static `[UrlTemplate](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate)`!` | [compile](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate#compile(java.lang.String))`(template: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Compile an instance from the provided template string.                                                                                                                                                                                                                                                                                                                                             |

## Public functions

### buildUri

```
fun buildUri(
    representationId: String!,
    segmentNumber: Long,
    bandwidth: Int,
    time: Long
): String!
```

Constructs a Uri from the template, substituting in the provided arguments.

Arguments whose corresponding identifiers are not present in the template will be ignored.  

|                                                Parameters                                                |
|----------------------------------------------------------------------------------------------------------|------------------------------------------------|
| `representationId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The representation identifier.                 |
| `segmentNumber: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)           | The segment number.                            |
| `bandwidth: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                 | The bandwidth.                                 |
| `time: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                    | The time as specified by the segment timeline. |

|                                       Returns                                        |
|--------------------------------------------------------------------------------------|----------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The built Uri. |

### compile

```
java-static fun compile(template: String!): UrlTemplate!
```

Compile an instance from the provided template string.  

|                                            Parameters                                            |
|--------------------------------------------------------------------------------------------------|---------------|
| `template: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The template. |

|                                                       Returns                                                        |
|----------------------------------------------------------------------------------------------------------------------|------------------------|
| [UrlTemplate](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/manifest/UrlTemplate)`!` | The compiled instance. |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------|
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | If the template string is malformed. |