Developer resources
Play DynTube HLS with AndroidX Media3 ExoPlayer
AndroidX Media3 ExoPlayer can play supported DynTube HLS output in a native Android application. Build the player around a playback URL returned for the authorized viewer, then verify that the selected DynTube protection mode works on the devices your application supports.
Add Media3 dependencies
Use the same current Media3 version for the ExoPlayer core, HLS, and UI artifacts. Choose the stable version recommended by the AndroidX Media3 release notes when implementing the app.
dependencies {
implementation("androidx.media3:media3-exoplayer:<CURRENT_VERSION>")
implementation("androidx.media3:media3-exoplayer-hls:<CURRENT_VERSION>")
implementation("androidx.media3:media3-ui:<CURRENT_VERSION>")
}Create the player view
<androidx.media3.ui.PlayerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/player_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />Prepare a DynTube HLS item
private var player: ExoPlayer? = null
private fun startPlayback(hlsUrl: String) {
val exoPlayer = ExoPlayer.Builder(this).build()
findViewById<PlayerView>(R.id.player_view).player = exoPlayer
exoPlayer.setMediaItem(MediaItem.fromUri(hlsUrl))
exoPlayer.prepare()
exoPlayer.playWhenReady = true
player = exoPlayer
}
override fun onStop() {
findViewById<PlayerView>(R.id.player_view).player = null
player?.release()
player = null
super.onStop()
}Pass the playback URL into this screen through your application's trusted data flow. For protected video, your backend should authenticate and authorize the viewer, obtain or create the permitted short-lived playback data, and return only what the app needs. Keep DynTube API and signing keys out of the APK.
Production playback checks
- Test published video and the exact HLS URL shape your account receives.
- Verify authorized, expired, and revoked playback rather than testing only a public sample.
- Exercise captions, alternate audio, seeking, rotation, backgrounding, interruption, and resume.
- Test Wi-Fi-to-mobile transitions, constrained bandwidth, and supported Android versions on real devices.
- Redact playback tokens from application, crash-reporting, and analytics logs.
Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.