Play your own DRM content on ExoPlayer

Taku Semba
3 min readApr 14, 2018

--

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.

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

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
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
video.mp4 info

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!

--

--

Taku Semba
Taku Semba

Responses (1)