Skip to the content.

Docs | Android

Offline DRM Assets

This guide shows how to use offline (downloaded) DRM-protected assets.

On this page:

LocalAssetsManager

The class that manages offline assets is called LocalAssetsManager.

LocalDataStore

LocalDataStore is an interface used by LocalAssetsManager to persist license data. The default implementation stores the licenses in a SharedPreferences file.

Applications should only customize LocalDataStore if they need to store the license files in another facility such as a db.

Create an instance

To use the default LocalDataStore, use the constructor that takes just the Context object.

The manager needs to be stored in a member (or a singleton).

Register a new asset

Registering a downloaded asset includes connecting to the DRM server to acquire a Widevine license and securely storing that license locally for later.

Call the following method

void registerAsset(@NonNull final PKMediaSource mediaSource, @NonNull final String localAssetPath,
                              @NonNull final String assetId, final AssetRegistrationListener listener) 

Unregister an asset

Before deleting an asset from storage, the application should tell LocalAssetsManager to remove the license linked with it. This is done by calling:

void unregisterAsset(@NonNull final String localAssetPath,
                    @NonNull final String assetId, final AssetRemovalListener listener)

Renew asset license

If the backend allows it, the asset license can be renewed (extended).

void refreshAsset(@NonNull final PKMediaSource mediaSource, @NonNull final String localAssetPath,
                @NonNull final String assetId, final AssetRegistrationListener listener)

Check asset status

To check the validity and expiration of a downloaded asset, the app can call the following function:

void checkAssetStatus(@NonNull final String localAssetPath, @NonNull final String assetId,
                      @Nullable final AssetStatusListener listener)

The listener has one method, onStatus(). It accepts 4 arguments:

void onStatus(String localAssetPath, long expiryTimeSeconds, long availableTimeSeconds, boolean isRegistered);

availableTimeSeconds is for extended business logic that is not commonly used. It refers to rental duration.

More info

For more info on downloading, see Download to Go.