DASH
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
ExoPlayer mendukung DASH dengan beberapa format penampung. Aliran media harus di-demux, yang berarti video, audio, dan teks harus ditentukan dalam elemen AdaptationSet
yang berbeda dalam manifes DASH (CEA-608 adalah pengecualian seperti yang dijelaskan dalam tabel di bawah). Format sampel audio dan video yang disertakan juga harus didukung (lihat bagian format sampel untuk mengetahui detailnya).
Fitur |
Didukung |
Komentar |
Container |
|
|
FMP4 |
YA |
Hanya aliran yang di-demux |
WebM |
YA |
Hanya aliran yang di-demux |
Matroska |
YA |
Hanya aliran yang di-demux |
MPEG-TS |
TIDAK |
Tidak ada dukungan yang direncanakan |
Teks tertutup /
subtitel |
|
|
TTML
|
YA
|
Mentah, atau disematkan dalam FMP4
sesuai dengan ISO/IEC 14496-30 |
WebVTT
|
YA
|
Mentah, atau disematkan dalam FMP4
sesuai dengan ISO/IEC 14496-30 |
CEA-608
|
YA
|
Disematkan dalam FMP4 saat diberi sinyal
menggunakan deskriptor
Aksesibilitas SCTE |
CEA-708
|
YA
|
Disematkan dalam FMP4 saat diberi sinyal
menggunakan deskriptor
Aksesibilitas SCTE |
Metadata |
|
|
Metadata EMSG |
YA |
Disematkan di FMP4 |
Perlindungan konten |
|
|
Widevine
|
YA
|
Skema "cenc": API 19+;
Skema "cbcs": API 25+ |
PlayReady SL2000 |
YA |
Android TV, hanya skema "cenc" |
ClearKey |
YA |
API 21+, hanya skema "cenc" |
Penyisipan iklan |
|
|
Pemutaran multi-periode |
YA |
|
Penyisipan iklan yang dipandu server
(xlinks) |
TIDAK
|
|
Iklan sisi server dan sisi klien IMA |
YA
|
Panduan penyisipan iklan
|
Pemutaran live |
|
|
Pemutaran live reguler |
YA |
|
Pemutaran live CMAF dengan latensi ultra-rendah |
YA
|
|
Common Media Client Data
(CMCD) |
YA
|
Panduan integrasi CMCD
|
Untuk memutar streaming DASH, Anda harus bergantung pada modul DASH.
Kotlin
implementation("androidx.media3:media3-exoplayer-dash:1.8.0")
Groovy
implementation "androidx.media3:media3-exoplayer-dash:1.8.0"
Kemudian, Anda dapat membuat MediaItem
untuk URI MPD DASH dan meneruskannya ke pemutar.
Kotlin
// Create a player instance.
val player = ExoPlayer.Builder(context).build()
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(dashUri))
// Prepare the player.
player.prepare()
Java
// Create a player instance.
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri(dashUri));
// Prepare the player.
player.prepare();
Jika URI Anda tidak diakhiri dengan .mpd
, Anda dapat meneruskan MimeTypes.APPLICATION_MPD
ke setMimeType
dari MediaItem.Builder
untuk menunjukkan jenis
konten secara eksplisit.
ExoPlayer akan otomatis beradaptasi di antara representasi yang ditentukan dalam
manifest, dengan mempertimbangkan bandwidth yang tersedia dan kemampuan perangkat.
Untuk opsi penyesuaian lainnya, Anda dapat membuat DashMediaSource
dan meneruskannya
langsung ke pemutar, bukan MediaItem
.
Kotlin
val dataSourceFactory: DataSource.Factory = DefaultHttpDataSource.Factory()
// Create a dash media source pointing to a dash manifest uri.
val mediaSource: MediaSource =
DashMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(dashUri))
// Create a player instance which gets an adaptive track selector by default.
val player = ExoPlayer.Builder(context).build()
// Set the media source to be played.
player.setMediaSource(mediaSource)
// Prepare the player.
player.prepare()
Java
DataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();
// Create a dash media source pointing to a dash manifest uri.
MediaSource mediaSource =
new DashMediaSource.Factory(dataSourceFactory)
.createMediaSource(MediaItem.fromUri(dashUri));
// Create a player instance which gets an adaptive track selector by default.
ExoPlayer player = new ExoPlayer.Builder(context).build();
// Set the media source to be played.
player.setMediaSource(mediaSource);
// Prepare the player.
player.prepare();
Mengakses manifes
Anda dapat mengambil manifes saat ini dengan memanggil Player.getCurrentManifest
.
Untuk DASH, Anda harus melakukan transmisi objek yang ditampilkan ke DashManifest
. Callback
onTimelineChanged
dari Player.Listener
juga dipanggil setiap kali
manifes dimuat. Hal ini akan terjadi satu kali untuk konten on-demand, dan
mungkin berkali-kali untuk konten live. Cuplikan kode berikut menunjukkan cara aplikasi
dapat melakukan sesuatu setiap kali manifes dimuat.
Kotlin
player.addListener(
object : Player.Listener {
override fun onTimelineChanged(timeline: Timeline, @TimelineChangeReason reason: Int) {
val manifest = player.currentManifest
if (manifest is DashManifest) {
// Do something with the manifest.
}
}
}
)
Java
player.addListener(
new Player.Listener() {
@Override
public void onTimelineChanged(
Timeline timeline, @Player.TimelineChangeReason int reason) {
Object manifest = player.getCurrentManifest();
if (manifest != null) {
DashManifest dashManifest = (DashManifest) manifest;
// Do something with the manifest.
}
}
});
Menyesuaikan pemutaran
ExoPlayer menyediakan beberapa cara bagi Anda untuk menyesuaikan pengalaman pemutaran dengan kebutuhan aplikasi Anda. Lihat Halaman penyesuaian untuk melihat contohnya.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-27 UTC."],[],[],null,["# DASH\n\nExoPlayer supports DASH with multiple container formats. Media streams must be\ndemuxed, meaning that video, audio, and text must be defined in distinct\n`AdaptationSet` elements in the DASH manifest (CEA-608 is an exception as\ndescribed in the table below). The contained audio and video sample formats must\nalso be supported (see the\n[sample formats](/media/media3/exoplayer/supported-formats#sample-formats) section for details).\n\n| Feature | Supported | Comments |\n|-----------------------------------------|-----------|----------------------------------------------------------------------|\n| **Containers** | | |\n| FMP4 | YES | Demuxed streams only |\n| WebM | YES | Demuxed streams only |\n| Matroska | YES | Demuxed streams only |\n| MPEG-TS | NO | No support planned |\n| **Closed captions /** **subtitles** | | |\n| TTML | YES | Raw, or embedded in FMP4 according to ISO/IEC 14496-30 |\n| WebVTT | YES | Raw, or embedded in FMP4 according to ISO/IEC 14496-30 |\n| CEA-608 | YES | Embedded in FMP4 when signalled using SCTE Accessibility descriptors |\n| CEA-708 | YES | Embedded in FMP4 when signalled using SCTE Accessibility descriptors |\n| **Metadata** | | |\n| EMSG metadata | YES | Embedded in FMP4 |\n| **Content protection** | | |\n| Widevine | YES | \"cenc\" scheme: API 19+; \"cbcs\" scheme: API 25+ |\n| PlayReady SL2000 | YES | Android TV, \"cenc\" scheme only |\n| ClearKey | YES | API 21+, \"cenc\" scheme only |\n| **Ad insertion** | | |\n| Multi-period playback | YES | |\n| Server-guided ad insertion (xlinks) | NO | |\n| IMA server-side and client-side ads | YES | [Ad insertion guide](/media/media3/exoplayer/ad-insertion) |\n| **Live playback** | | |\n| Regular live playback | YES | |\n| Ultra low-latency CMAF live playback | YES | |\n| **Common Media Client Data** **(CMCD)** | YES | [CMCD integration guide](/media/media3/exoplayer/cmcd) |\n\nUsing MediaItem\n---------------\n\nTo play a DASH stream, you need to depend on the DASH module. \n\n### Kotlin\n\n```kotlin\nimplementation(\"androidx.media3:media3-exoplayer-dash:1.8.0\")\n```\n\n### Groovy\n\n```groovy\nimplementation \"androidx.media3:media3-exoplayer-dash:1.8.0\"\n```\n\nYou can then create a `MediaItem` for a DASH MPD URI and pass it to the player. \n\n### Kotlin\n\n```kotlin\n// Create a player instance.\nval player = ExoPlayer.Builder(context).build()\n// Set the media item to be played.\nplayer.setMediaItem(MediaItem.fromUri(dashUri))\n// Prepare the player.\nplayer.prepare()\n```\n\n### Java\n\n```java\n// Create a player instance.\nExoPlayer player = new ExoPlayer.Builder(context).build();\n// Set the media item to be played.\nplayer.setMediaItem(MediaItem.fromUri(dashUri));\n// Prepare the player.\nplayer.prepare();\n```\n\n\u003cbr /\u003e\n\nIf your URI doesn't end with `.mpd`, you can pass `MimeTypes.APPLICATION_MPD`\nto `setMimeType` of `MediaItem.Builder` to explicitly indicate the type of the\ncontent.\n\nExoPlayer will automatically adapt between representations defined in the\nmanifest, taking into account both available bandwidth and device capabilities.\n\nUsing DashMediaSource\n---------------------\n\nFor more customization options, you can create a `DashMediaSource` and pass it\ndirectly to the player instead of a `MediaItem`. \n\n### Kotlin\n\n```kotlin\nval dataSourceFactory: DataSource.Factory = DefaultHttpDataSource.Factory()\n// Create a dash media source pointing to a dash manifest uri.\nval mediaSource: MediaSource =\n DashMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(dashUri))\n// Create a player instance which gets an adaptive track selector by default.\nval player = ExoPlayer.Builder(context).build()\n// Set the media source to be played.\nplayer.setMediaSource(mediaSource)\n// Prepare the player.\nplayer.prepare()\n```\n\n### Java\n\n```java\nDataSource.Factory dataSourceFactory = new DefaultHttpDataSource.Factory();\n// Create a dash media source pointing to a dash manifest uri.\nMediaSource mediaSource =\n new DashMediaSource.Factory(dataSourceFactory)\n .createMediaSource(MediaItem.fromUri(dashUri));\n// Create a player instance which gets an adaptive track selector by default.\nExoPlayer player = new ExoPlayer.Builder(context).build();\n// Set the media source to be played.\nplayer.setMediaSource(mediaSource);\n// Prepare the player.\nplayer.prepare();\n```\n\n\u003cbr /\u003e\n\nAccessing the manifest\n----------------------\n\nYou can retrieve the current manifest by calling `Player.getCurrentManifest`.\nFor DASH you should cast the returned object to `DashManifest`. The\n`onTimelineChanged` callback of `Player.Listener` is also called whenever\nthe manifest is loaded. This will happen once for a on-demand content, and\npossibly many times for live content. The following code snippet shows how an app\ncan do something whenever the manifest is loaded. \n\n### Kotlin\n\n```kotlin\nplayer.addListener(\n object : Player.Listener {\n override fun onTimelineChanged(timeline: Timeline, @TimelineChangeReason reason: Int) {\n val manifest = player.currentManifest\n if (manifest is DashManifest) {\n // Do something with the manifest.\n }\n }\n }\n)\n```\n\n### Java\n\n```java\nplayer.addListener(\n new Player.Listener() {\n @Override\n public void onTimelineChanged(\n Timeline timeline, @Player.TimelineChangeReason int reason) {\n Object manifest = player.getCurrentManifest();\n if (manifest != null) {\n DashManifest dashManifest = (DashManifest) manifest;\n // Do something with the manifest.\n }\n }\n });\n```\n\n\u003cbr /\u003e\n\nCustomizing playback\n--------------------\n\nExoPlayer provides multiple ways for you to tailor playback experience to your\napp's needs. See the [Customization page](/guide/topics/media/exoplayer/customization) for examples."]]