Sources and DRM
Sources
The input sources can be configurated by MediaConfig. SDK provides full DASH playback and partial HLS playback.
DASH
- The following are the configuration to play DASH content without DRM protected:
val mediaConfig = MediaConfig.Source(
url = "LIVE_OR_ONDEMAND_DASH_URL",
protocol = MediaConfig.Protocol.DASH
)
player.load(mediaConfig)
- To play DRM-protected videos, please specify license server URLs and options with DRM.
val DRM_KEY = "x-custom-data"
val DRM_VALUE = "token_type=upfront&token_value=$PLAYBACK_TOKEN"
val mediaConfig = MediaConfig(
source = MediaConfig.Source(
url = "LIVE_OR_ONDEMAND_DASH_URL",
protocol = MediaConfig.Protocol.DASH,
drm = MeidaConfig.DrmInfo.Widevine(
licenseUrl = "$DRM_LICENSE_URL",
headers = mapOf(DRM_KEY to DRM_VALUE)
)
),
...
)
player.load(mediaConfig)
The
licenseUrl
can be found on here, andplaybackToken
is the same token to start a playback session
HLS
The Android SDK currently only supports on-demand content (e.g. VoD or AoD) and does not yet support live content and DRM-protected content.
val mediaConfig = MediaConfig(
sourec = MediaConfig.Source(
url = "ONDEMAND_HLS_URL",
protocol = MediaConfig.Protocol.HLS
)
)
player.load(mediaConfig)
Advence setting for DRM DASH
Some devices may not support hardware (L1) DRM decryption, resulting in content that cannot be played successfully.
Therefore, we also provide software (L3) DRM decryption to playback contents. L3 can not control with hardware device, need to pair with setSurfaceSecure(Boolean)
method to prevent recording and screenshot.
Example:
// when activity/fragment created
binding.uniView.setSurfaceSecure(true)
// prepare the media config
val mediaConfig = MediaConfig(
source = MediaConfig.Source(
...
drm = MeidaConfig.DrmInfo.Widevine(
...
drmSecurityLevel = DrmSecurityLevel.L3
)
),
...
)
// load the config
player.load(mediaConfig)