DRM in WebViews
Paid TrueVisions titles are encrypted. The player asks the platform's content decryption module for a licence through Encrypted Media Extensions, which a WebView blocks until the host app opts in. This page lists what to enable on each platform and includes a live check you can open on a device.
Summary
| Platform | Key system | What the host must do |
|---|---|---|
| Android WebView | Widevine | Grant RESOURCE_PROTECTED_MEDIA_ID in WebChromeClient.onPermissionRequest. Keep the WebView on https. |
| iOS WKWebView | FairPlay Streaming | Use WKWebView (not UIWebView) with inline playback. Nothing else to grant. |
| Web iframe | Widevine / PlayReady / FairPlay by browser | Add encrypted-media to the iframe's allow attribute. |
Android
Chrome-based WebViews expose Widevine, but every licence request first raises a permission request for the protected media identifier. The default WebChromeClientdenies it, and the player then fails with a DRM error and the viewer sees "This video can't be played right now".
webView.webChromeClient = object : WebChromeClient() {
override fun onPermissionRequest(request: PermissionRequest) {
val protectedMedia = request.resources
.filter { it == PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID }
.toTypedArray()
// Only the mini-app origin may use the CDM.
if (protectedMedia.isNotEmpty() && request.origin.host == "mini-app.truevisions.co.th") {
request.grant(protectedMedia)
} else {
request.deny()
}
}
}- The WebView must load the mini-app over
https; EME is unavailable in insecure contexts. - Widevine L1 (hardware) or L3 (software) is decided by the device. The player does not demand a security level, so L3-only devices still play at the resolution the licence permits.
- Do not set
WebSettings.setMixedContentModeto allow insecure content; licence servers are https and the CDM refuses mixed contexts. - Emulators without Google Play services have no Widevine CDM. Test on a real device.
iOS
WKWebView supports FairPlay Streaming through the same EME interface Safari uses. There is no permission prompt to handle. Make sure the configuration allows inline playback, otherwise the system player takes over and the mini-app controls disappear.
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
config.mediaTypesRequiringUserActionForPlayback = []- Requires iOS 14 or later for stable FairPlay in WKWebView.
- The WebView must be served over
https. - Screen recording and AirPlay of protected content are blocked by the system; this is expected.
Web iframe
<iframe src="https://mini-app.truevisions.co.th/en/trueapp/sport" allow="autoplay; encrypted-media; fullscreen"></iframe>Without encrypted-media the browser denies EME inside the frame and protected titles fail while free titles play.
How licences are requested
The playback API returns the stream manifest together with the licence server URLs per key system, and, when the licence server needs it, the headers the player must send (for example a short-lived licence token). The player forwards these as configured. The host never handles licence traffic, and no credentials are attached to licence requests other than the headers the API supplies.
{
"hls": "https://…/master.m3u8",
"dash": "https://…/manifest.mpd",
"drm": {
"widevineLicenseUrl": "https://…/widevine",
"playreadyLicenseUrl": "https://…/playready",
"fairplayLicenseUrl": "https://…/fairplay",
"fairplayCertificateUrl": "https://…/fairplay.cer",
"licenseHeaders": { "x-license-token": "…" },
"widevineRobustness": { "video": "SW_SECURE_CRYPTO" }
}
}widevineRobustness is optional and normally omitted. TrueVisions may set it to cap or require a Widevine security level for particular content; a level higher than the device supports makes playback fail, which is the intended outcome for such content.
Recognising DRM failures
| Bridge message | Likely cause |
|---|---|
playback-error | code in the 2000 range (DRM_*), for example DRM_NO_KEY_SYSTEM or DRM_FAILED_LICENSE_REQUEST. Permission not granted, insecure context, or the licence server rejected the request. |
playback-error | code 1400 SOURCE_ERROR: the manifest itself could not load. Network or allow-list, not DRM. |
Check this WebView
Load https://mini-app.truevisions.co.th/docs/drm?embed=1#check in your WebView. The probe below asks the browser for each key system exactly as the player would.
Checking…
Widevine (Android, Chrome)
com.widevine.alpha · checking…
PlayReady (Edge, Xbox)
com.microsoft.playready.recommendation · checking…
FairPlay (iOS, Safari)
com.apple.fps · checking…
A platform normally supports one key system. Widevine failing on Android means the host has not granted protected-media access; FairPlay failing on iOS means the page is not in a WKWebView or not served over https.
Still stuck? Capture the playback-error message and the user agent shown above and send them to TrueVisions with the content id. See also the WebView requirements.