Android and Android TV
Integrate DRM-X 6.0 Widevine playback on Android, Android TV, Google TV, and Fire TV with Kotlin, Media3, server-side authorization, and session release.
Server request#
After your API authenticates the app user and approves entitlement, request a playback session with clientPlatform: android, drmSystems: ["widevine"], manifestTypes: ["dash"], and truthful device capability. The APK never contains the Site Key or Access Key.
Configure Media3#
val drm = MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
.setLicenseUri(session.drm.licenseServerUrl)
.setLicenseRequestHeaders(mapOf(
session.drm.authorization.headerName to
"${session.drm.authorization.scheme} ${session.drm.authorization.value}"
))
.setMultiSession(false)
.build()
val item = MediaItem.Builder()
.setUri(session.manifest.url)
.setDrmConfiguration(drm)
.build()Use the manifest MIME type returned by the contract and apply the licensed maximum height to track selection. Do not reuse one session ID across devices.
Lifecycle and offline behavior#
- Call the returned release route when the player is stopped, replaced, or destroyed.
- Use a bounded retry policy; create a fresh playback session after authorization expires.
- Do not treat a network retry as a new viewer session unless a new playback attempt really started.
- For offline or persistent licenses, define a dedicated server policy and application lifecycle; do not convert a streaming token into a download entitlement.
Device qualification#
Test physical phones, tablets, Android TV/Google TV, and Fire TV classes you support. Verify Widevine security level, maximum decoder resolution, HDCP behavior, codec support, audio/subtitle selection, background/foreground transitions, and HDMI changes.
Android, Android TV, Google TV, and Fire TV#
The DRM-X Kotlin/Media3 SDK targets API 23+ and uses Android MediaDrm for Widevine. The app calls your authenticated backend; policy and DRM-X credentials stay off the device.
val player = DrmXPlayer(this, playerView)
val capabilities = WidevineCapabilities.playbackCapabilities(
clientPlatform = "android",
displayMetrics = resources.displayMetrics,
applicationVersion = BuildConfig.VERSION_NAME,
)
player.prepare(
endpoint = "https://customer.example/api/drmx/playback-session",
contentId = "course-12-lesson-4",
contentType = "vod", // or "live"
capabilities = capabilities,
customerAuthenticationHeaders = mapOf(
"Authorization" to "Bearer ${customerLogin.accessToken}",
),
)
Call close() from the Activity or Fragment lifecycle. Use the default SurfaceView and protectWindow() for protected screens. Test both certified Widevine L1 hardware and an L3 device or emulator.
DRM-X 6.0