267 Followers
·
Follow

Play your own DRM content on ExoPlayer

Image for post
Image for post

Digital rights management, or you could just refer to it as DRM, is a way of controlling what users can do with some sort of digital content.

If it not protected by DRM, you might be able to do anything you want, like “Copy it”, “Send copies everyone you know”, “Remix it”, or “Play it on any machine”. DRM could prevent you from some of these things.

What differentiates it from just encrypting/decrypting contents is DRM requires you to get a key from a license server to decrypt the content so that the server can return the key only to someone who has the right to it.

Image for post
Image for post

Let’s make a DRM content from non-encrypted mp4 file. In this article Im just gonna use shaka-packager, but Im not gonna get deep into how to use shaka-pakager.

You also need a license sever, but google has a sample license server for testing.

https://google.github.io/shaka-packager/html/tutorials/widevine.html

Image for post
Image for post

MPEG-DASH + WideVine

This is how you can create a MPEG-DASH+WideVine content.

MPEG-DASH + WideVine

Now you will see sample.mpd, and encrypted audio.mp4, video.mp4.

sample.mpd
Image for post
Image for post
video.mp4 info

HLS + WideVine

It’s pretty much the same but, this is how you can create a HLS+WideVine content.

HLS + WideVine

Now you will see master.m3u8, audio.m3u8 video.m3u8, and encrypted audio.mp4, video.mp4.

video.m3u8
Image for post
Image for post
video.mp4 info
Image for post
Image for post

Let’s play the DRM contents you’ve just created.

Note that the example below uses ExoPlayer version 2.7.3 and this is formats ExoPlayer supports currently.

It seems that ExoPlayer supports both MPEG-DASH + WideVine(cenc) and HLS + WideVine (cenc) and this is my sample app that plays them.

Nailed it!

Image for post
Image for post

Written by

Android Engineer at AbemaTV Github: https://github.com/takusemba

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store