Can I Download a video with DRM protection on SD card and play it only with my app that using Exoplayer or in someway that video saved securely. I don't want user can copy my video to another device and I want save it on SD card because of sizes and number of videos user may download
-
Hi Siavash, Have u got any solution ? – Prabhu M Dec 03 '15 at 10:50
-
@PrabhuM not for offline DRM but I write an answer. maybe it works for you too. – Siavash Abdoli Dec 03 '15 at 21:41
-
This issue on ExoPlayer's repository might help https://github.com/google/ExoPlayer/issues/949 – Pawan Jain Feb 11 '22 at 11:23
3 Answers
With the latest release of ExoPlayer 2.2.0 , it provides this facility inbuilt in ExoPlayer. ExoPlayer has a helper class to download and refresh offline license keys
OfflineLicenseHelper.java
/**
* Helper class to download, renew and release offline licenses. It utilizes {@link
* DefaultDrmSessionManager}.
*/
public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
You can access the latest code from the ExoPlayer repo
For more inspiration you can look at this closed issue.
I created a sample application for Offline playback of DRM content.You can access it from here

- 1,100
- 10
- 22
-
-
1
-
As google said: On Android 4.4 (API level 19) and higher, ExoPlayer supports Digital Rights Managment (DRM) protected playback. but you set minSdkVersion to 16, why? does it works for api 16? – Hamed Ghadirian May 25 '17 at 19:53
-
@HamedGh : Yeah that's an Honest mistake, I will update that. Thanks. – theJango May 28 '17 at 04:11
You can use Exoplayer for offline viewing. But you will have to extend your own class from DrmSessionManager
. The Key here is to use MediaDrm.KEY_TYPE_OFFLINE
as a keyType in mediaDrm.getKeyRequest
.
In the mediaDrm.provideKeyResponse
you need to get the KeySetId
and used later when another request for the same video is made mediaDrm.restoreKeys
Also don't forget to set the state of the player with STATE_OPENED_WITH_KEYS
after restoring the keys.
You can find more informations about this here: http://developer.android.com/reference/android/media/MediaDrm.html#KEY_TYPE_OFFLINE https://developer.android.com/reference/android/media/MediaDrm.html#restoreKeys(byte[],byte[])

- 14,061
- 1
- 23
- 25
For now I decide to use Facebook conceal library. fast and easy way for encryption. I download my content and pass it to conceal library and when I want to play the video use byte stream for and read video sectional.
but if you find better and easier way let me know.
you can find an example here

- 1
- 1

- 1,852
- 3
- 22
- 38
-
The example you provided is for image, how to implement it for video which user want to change progress to any time – Hamed Ghadirian May 20 '17 at 08:17
-
@HamedGh you can break one video to several 15 secs videos for example. and then encrypt and decrypt it. I know it's not a good solution. so you can use drm and pls see accepted answer. – Siavash Abdoli May 27 '17 at 09:19