Android Widevine SDK (Standalone)

Integrate Studio DRM Standalone with your Android app.


πŸ‘

If you want to provide users with offline DRM playback, the Studio DRM Widevine is required.

For online DRM playback only, the Studio DRM Widevine is not required. Online DRM playback can be handled using ExoPlayer and MediaDrm API.


The Studio DRM Widevine SDK is an Android Archive (AAR) which can be used with ExoPlayer 2.12.1 to simplify the playback of the DRM content. It has been developed to specifically manage the DRM session, allowing complete asset and player management. It can be integrated into your Android application.



Requirements

  • Minimum SDK version is 19 (Android 4.4)
  • Android Studio 4.0.1


Add the Widevine SDK

  1. From within Android Studio, open your app.
  2. In the project build.gradle file, add the studiodrm-widevine and kid-plugin Maven repositories:

    Β Β Β β€’ https://maven.drm.technology/artifactory/studiodrm-widevine
    Β Β Β β€’ https://maven.drm.technology/artifactory/kid-plugin

    Be sure to map the username and password to your credentials to authenticate with the Maven repositories.
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.drm.technology/artifactory/studiodrm-widevine"
            credentials {
                username = "mavenUsername"
                password = "mavenPassword"
            }
        }
        maven {
            url "https://maven.drm.technology/artifactory/kid-plugin"
            credentials {
                username = "mavenUsername"
                password = "mavenPassword"
            }
        }
    }
}

  1. In the app build.gradle dependencies add the studiodrm-widevine and kid-plugin dependencies.
dependencies {
    ...
    
    implementation "com.vualto.studiodrm:widevine:1.0.0"
    implementation "com.vualto.studiodrm:kidplugin:1.0.0"

    // your app’s other dependencies
}


Example Usage

Instances of Studio DRM Widevine are associated with specific assets. Offline assets can be tracked using Exoplayer's DownloadService and DownloadTracker classes. Two types of session are available, determined by the current session's Studio DRM token policy and the asset configuration.


Online and Offline Streaming Sessions

Exoplayer 12 introduces more 'under the hood' management of DRM assets. This simplifies the flow for online and offline streaming sessions.

For an example of implementation, we recommend referring to our multiple asset Studio DRM Widevine demo application, which is directly adapted from Exoplayers demo application. To manage the required modification of license calls, we have added a simple StudiodrmHelper class to the demo application.

At minimum, asset configurations should contain the following stream information:
Β Β β€’ name
Β Β β€’ uri
Β Β β€’ drm_scheme("widevine")
Β Β β€’ drm_license_url

Tokens may be presented using either Exoplayer's license header drm_key_request_properties or a URL-encoded token added to the license server URI, such as "drm_license_uri": "https://widevine-license.staging.vudrm.tech/proxy?token=studiodrm-token-value".


  1. To implement Studio DRM Widevine, instantiate an AssetConfiguration using the fluent interface for both online and offline sessions. Minimally you need to provide the contents KID, DRM token, and license server URI.
assetConfiguration = new AssetConfiguration.Builder()
    .tokenWith(drmToken)
    .KIDWith(KID)
    .build();

  1. Construct a plugin by instantiating a WidevineCallback object with the asset configuration.
MediaDrmCallback callback = new WidevineCallback (assetConfiguration);

  1. When creating the DefaultDrmSessionManager object, pass the plugin to ExoPlayer as the required component.
return new DefaultDrmSessionManager.Builder()
    .setUuidAndExoMediaDrmProvider(C.WIDEVINE_UUID, FrameworkMediaDrm.DEFAULT_PROVIDER)
    .setMultiSession(false)
    .build(mediaDrmCallback);

For offline sessions, Exoplayer's DownloadTracker creates a WidevineOfflineLicenseFetchTask to acquire and download the license. After this, the download commences. When the download is complete, Exoplayer manages the asset for playback.

Reference: ExoPlayer library



Error handling

Independent of the SDK, DRM-related errors are bubbled up to ExoPlayer’s event listener system. The errors should contain the license server's HTTP response code and the request ID in the exception if applicable.



Known Issues

  • Exoplayer 12 for AndroidX introduced a requirement that the PSSH box be present in the main manifest. If the PSSH box is not present in the main manifest then Exoplayer's DefaultDrmSessionManager will throw this error: MissingSchemeDataException: Media does not support uuid: edef8ba9-79d6-4ace-a3c8-27dcd51d21ed.

  • 32-bit devices displayed issues where a license expiry time (secs) is too large to be handled, it therefore returns 0 seconds remaining and considers the license expired. To work around this, always set the license expiry time in your Studio DRM token policy.



Troubleshooting

  • Most issues are content related. You can use our demo application to test your own content by updating the media.exolist.json with your configurations.

  • Errors may also arise because the stream or asset configuration is not correct.

  • Tokens - You can easily eliminate token issues by beginning with an empty policy in the Studio DRM token. Please ensure your token is formatted correctly and validated. For the avoidance of doubt, where token policies use dates, the dates should always be in the future.