Search code examples
androiddrmexoplayerwidevineandroid-drm

Android Widevine DASH implementation + ExoPlayer


I want to play Widevine Modular - DASH video in my app and I want to use VideoView or ExoPlayer for it.

Is there any sample how I can setup it? Or can you provide me any sample code how to acquire the licence? I have URL of the video and also the Widevine server URL.

Before we were using Widevine classic and the request for licence looks like this:

private void prepareDrmInfoRequest()
{
        mDrmInfoRequest = new DrmInfoRequest(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO, "application/mp4");
        mDrmInfoRequest.put("WVVideoUrlKey", "http://some_url.com/dash/1.mpd");
        mDrmInfoRequest.put("WVDRMServerKey", "http://some_url.com/video/widevine_modular/?auth_token=haslůkfjlksjfljnvlakhnsufn");
        mDrmInfoRequest.put("WVCAUserDataKey", "LJKHlklkhkljhKJLHuzgztfZTFZTUFzutf");
        mDrmInfoRequest.put("WVPortalKey", "provider");
}

and then

  public int processDrm()
  {
        DrmInfo df = mDrmManagerClient.acquireDrmInfo(mDrmInfoRequest);
        if(df != null)
        {
            return mDrmManagerClient.processDrmInfo(df);
        }
  }

After that the video was playing on VideoView or ExoPlayer.


Solution

  • I realise this is an old question but if anyone is still looking for this the standard ExoPlayer demo includes widevine example manifests also.

    The demo player is available here:

    And the widevine manifest examples can be seen in the config at the following location:

    ExoPlayer/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTest.java

    To see it in use search for 'DefaultDrmSessionManager' in the repository.