ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Let’s Dive into Exo-Player (Part III): The DRM Way

--

Photo by charlesdeluvio on Unsplash

Recently I came across a use case where we needed to incorporate DRM with our ExoPlayer so while implementing I thought of penning it down in continuation to my ExoPlayer Series
Part 1: https://medium.com/@prateekbatra54/lets-dive-into-exo-player-2-12-working-5b6aa7042421

Part 2: https://medium.com/@prateekbatra54/lets-dive-into-exo-player-part-ii-adding-quality-control-a0c0b50cc628

What is DRM

Digital Rights Management is a mechanism we can protect the copyrights of any digital media. This is majorly used for protecting data from copyright of proprietary data files and securing them

In DRM data files (media, data, e-books, content, software, or any other copyrighted material) are encrypted using a piece of code.
Those files can be decrypted using a license key.

Along with this, we can also set different configs to it like how many times a user can play (Single or Multiple playbacks), Licence Duration, Playback Duration i.e we can lock any content specific to geolocation, number of plays, playback duration

Various DRM Providers

These are some of the major DRM Providers each of which provide different ways to manage DRM Content and Decode them using a license

Widevine DRM Technology: Introduced by Google. This is one of the majorly used DRM Providers used in Android Devices
PlayReady DRM technology: Introduced by Microsoft. This is one of the majorly used DRM Providers used in Chrome Browser Devices
FairPlay DRM Technology: Introduced by Apple. This is one of the majorly used DRM Providers used in Safari & Apple Devices.

Implementation

Basic Setup
For the basic setup you can follow the Part 1 :

Demo Repo

Now here basic setup code for Player we are :

Here we are using the Widevine DRM .
You can Replace LICENSE_URL ,VIDEO_URL with your own value .
(The demo repo already has testing urls)

Along with this, there are sometimes cases where we need to add a certain header to our DRM Licence Request. Then you can use setLicenseRequestHeaders with DRM config and set all your required headers in form of a Map. Along with this, there are many different configurations you can use as per the configuration request.

Now, this sums up pretty much everything you need to play any DRM video with online support. Also Since we can also Download Any such content offline we have support for DRM for offline videos too if the generated license support that too.

What's Next?

Some Additional thoughts?

ExoPlayer has support for many extensive features like Caching, and Offline Download. Do let me know in the comments if you need another article specifically for Video Caching, Offline Downloads.

Thank you for reading, stay tuned for amazing articles!

Catch me up on: https://twitter.com/its_pra_tick

Do not forget claps, happy coding :)

--

--

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Prateek Batra

Just Getting Started here #Android #Kotlin

Responses (1)