ExoPlayer is the easiest option to play your DRM-protected video content on Android devices. Configure ExoPlayer with a few lines of code and use it with Axinom DRM License Service.

ExoPlayer for Android

The easiest way to play DRM-protected videos on Android devices is to use ExoPlayer. The logical choice is to use Google Widevine with MPEG-DASH, because it is supported natively on Android devices.

You can configure ExoPlayer with a few lines of code to use Axinom DRM License Service. In a nutshell, you need to do two things to connect ExoPlayer with Axinom DRM:

ExoPlayer takes care of the rest, including generating a proper license request and adding the needed keyId(s) to it.

You can find more detailed instructions and available options below.

ExoPlayer Demo Application

ExoPlayer comes with a simple Demo Application. To make this application work with Axinom DRM, adjust the media.exolist.json configuration file by setting the correct values for drm_license_uri and specifying a custom license request header that carries the license token via the drm_key_request_properties object.

Sample configuration entry for ExoPlayer Demo Application
{
  "name": "AxinomDemoVideo-SingleKey",
  "uri": "https://media.axprod.net/VTB/DrmQuickStart/AxinomDemoVideo-SingleKey/Encrypted_Cenc/Manifest.mpd",
  "drm_scheme": "widevine",
  "drm_license_uri": "https://drm-widevine-licensing.axtest.net/AcquireLicense",
  "drm_key_request_properties": {
    "X-AxDRM-Message": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiNjllNTQwODgtZTllMC00NTMwLThjMWEtMWViNmRjZDBkMTRlIiwibWVzc2FnZSI6eyJ2ZXJzaW9uIjoyLCJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImxpY2Vuc2UiOnsiYWxsb3dfcGVyc2lzdGVuY2UiOnRydWV9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiIyMTFhYzFkYy1jOGEyLTQ1NzUtYmFmNy1mYTRiYTU2YzM4YWMiLCJ1c2FnZV9wb2xpY3kiOiJUaGVPbmVQb2xpY3kifV19LCJjb250ZW50X2tleV91c2FnZV9wb2xpY2llcyI6W3sibmFtZSI6IlRoZU9uZVBvbGljeSIsInBsYXlyZWFkeSI6eyJwbGF5X2VuYWJsZXJzIjpbIjc4NjYyN0Q4LUMyQTYtNDRCRS04Rjg4LTA4QUUyNTVCMDFBNyJdfX1dfX0.D9FM9sbTFxBmcCOC8yMHrEtTwm0zy6ejZUCrlJbHz_U"
  }
}

The table below includes some important information about the JSON file elements.

Element Notes

"uri"

Replace with a URL to your MPEG-DASH manifest.

"drm_license_uri"

The example indludes the URL for the Test environment of Axinom DRM. For production, use https://drm-widevine-licensing.axprod.net/AcquireLicense

"X-AxDRM-Message"

Replace with your Axinom DRM License Message ("license token").

To generate a test token, you can use the Entitlement Message Tool.

Custom ExoPlayer-Based Application

In custom ExoPlayer-based applications, the integration points are the same. The only difference with the ExoPlayer Demo application is that the same functional changes illustrated by the ExoPlayer Demo configuration adjustment that handles the MediaSource creation need to be implemented in the code.

Below, we provide a functional code sample for the MediaSource creation that enables playback with Axinom DRM:

// Defining content URI, license server URI and license token.
private String mContentUri = "https://media.axprod.net/VTB/DrmQuickStart/AxinomDemoVideo-SingleKey/Encrypted_Cenc/Manifest.mpd";
private String mLicenseServer = "https://drm-widevine-licensing.axtest.net/AcquireLicense";
private String mLicenseToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiNjllNTQwODgtZTllMC00NTMwLThjMWEtMWViNmRjZDBkMTRlIiwibWVzc2FnZSI6eyJ2ZXJzaW9uIjoyLCJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImxpY2Vuc2UiOnsiYWxsb3dfcGVyc2lzdGVuY2UiOnRydWV9LCJjb250ZW50X2tleXNfc291cmNlIjp7ImlubGluZSI6W3siaWQiOiIyMTFhYzFkYy1jOGEyLTQ1NzUtYmFmNy1mYTRiYTU2YzM4YWMiLCJ1c2FnZV9wb2xpY3kiOiJUaGVPbmVQb2xpY3kifV19LCJjb250ZW50X2tleV91c2FnZV9wb2xpY2llcyI6W3sibmFtZSI6IlRoZU9uZVBvbGljeSIsInBsYXlyZWFkeSI6eyJwbGF5X2VuYWJsZXJzIjpbIjc4NjYyN0Q4LUMyQTYtNDRCRS04Rjg4LTA4QUUyNTVCMDFBNyJdfX1dfX0.D9FM9sbTFxBmcCOC8yMHrEtTwm0zy6ejZUCrlJbHz_U";

// Creating a player instance and preparing it with the built media source
private void initializePlayer() {
    DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(this);
    SimpleExoPlayer player = new SimpleExoPlayer.Builder(this, renderersFactory).build();
    MediaSource mediaSource = buildMediaSource(this, mContentUri, mLicenseServer, mLicenseToken);
    player.setMediaSource(mediaSource);
    player.prepare();
}

// A method for building MediaSource.
private MediaSource buildMediaSource(Context context, String videoUrl, String licenseServer, String licenseToken) {
    String userAgent = Util.getUserAgent(context, "DRM example app");
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, userAgent);
    return new DashMediaSource.Factory(
            new DefaultDashChunkSource.Factory(dataSourceFactory), dataSourceFactory)
            .setDrmSessionManager(buildDrmSessionManager(userAgent, licenseServer, licenseToken))
            .createMediaSource(new MediaItem.Builder().setUri(videoUrl).build());
}

// A method for building DrmSessionManager.
private DefaultDrmSessionManager buildDrmSessionManager(String userAgent, String licenseUrl, String drmToken) {
    HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
            new DefaultHttpDataSourceFactory(userAgent, null));
    // Here the license token is attached to license request
    if (drmToken != null) {
        drmCallback.setKeyRequestProperty("X-AxDRM-Message", drmToken);
    }

    return new DefaultDrmSessionManager.Builder()
            .setUuidAndExoMediaDrmProvider(C.WIDEVINE_UUID, FrameworkMediaDrm.DEFAULT_PROVIDER)
            .build(drmCallback);
}

Axinom Sample Player

Additionally, Axinom offers a Sample Player application in source code to illustrate the DRM integration. The application provides a starting point for developers who want to implement a player application that includes support for Axinom DRM and offline playback. Details about the integration of Axinom DRM are well documented in the source code.

Axinom Sample Player also demonstrates the so-called Offline Playback, i.e. how you can download the DRM-protected videos to your device, request a persistent DRM License and play the videos later without an Internet connection.

The Sample Player’s source code is available on Github.

Revision History

The table below lists the document versions and any changes to them.

Version Date Description

1.0

January 22, 2021

  • Initial version.

2.0

March 5, 2021

  • ExoPlayer demo application added.

2.1

May 20, 2021

  • Comments in code replaced with a table.