Skip to main content

5. Offline Playback

This document explains how to play back content that has been fully downloaded to local disk. In offline mode, instead of the remote URL used for online streaming playback, a data source based on the media content key (MediaContentKey, mck) is used.

All example code in this document is based on the official sample app kollus_player_v2_android.


Offline playback

Instead of setDataSourceByUrl used for streaming playback, use the setDataSourceByKey method to specify a local media key and start offline playback.

// VideoView.openVideo()
String extraDrmParam = null;
if (mUri != null) {
// Streaming playback (online)
mMediaPlayer.setDataSourceByUrl(mUri.toString(), extraDrmParam);
} else if (mKollusContent != null) {
// Offline playback (downloaded content)
mMediaPlayer.setDataSourceByKey(
mKollusContent.getKollusContent().getMediaContentKey(),
extraDrmParam);
}
mMediaPlayer.prepareAsync();

Overall integration flow

  1. Obtain a MultiKollusContent object via multiStorage.getDownloadKollusContent(localPath) or getDownloadList().
  2. Attach the obtained object to the VideoView component using the setKollusContent(content) method.
  3. Internally, setDataSourceByKey(mck, extraDrmParam) and prepareAsync() are called sequentially.
  4. During playback preparation, the SDK automatically performs local DRM validation. If the license has expired or permissions are insufficient, the player stops and reports an error code via the onDRMInfo callback. (See Also: 8. Download Events/Callbacks)

Offline DRM validation conditions

To pass DRM validation in an offline environment without network connectivity, all three of the following DRM security restrictions embedded in the downloaded file must be satisfied.

  • Expiration date and time (DRMExpireDate): The device's current time must be before the expiration date and time specified in the license.
  • Play count (DRMExpireCount): The actual number of plays to date must be less than the configured maximum limit (DRMExpireCountMax).
  • Remaining time (DRMExpirePlayTime): The remaining allowed playback time must be greater than 0.

If any one of these three conditions is violated, local playback will fail, and the license must be renewed by reconnecting to the network for normal operation. (See Also: 6. DRM License Renewal)


Handle expired content

The following are the major error code specifications returned during the player playback stage when expiration is detected due to a license threshold being exceeded during the DRM validation phase.

Expiration typeError code (ErrorCode)
Expiration date exceededERROR_EXPIRATION_DATE
Play count exceededERROR_EXPIRATION_COUNT
Playback duration exceededERROR_EXPIRATION_PLAY_TIME
Force deletion (DRM callback)ERROR_FORCE_DELETE (followed by a DCB_INFO_DELETE signal triggered together in the onDRMInfo callback.)
Recommended UX for expired content

When any of the above error codes are detected, it is recommended to display a guidance popup on screen saying "Your license has expired. Please connect to a network to renew your license and try playing again.", and design the logic to attempt a dynamic license renewal API process in the background.


Handle file deletion and corrupted file exceptions

The following are safe defensive code implementation patterns for when a user arbitrarily modifies or forcibly deletes local media files.

SituationSDK determination and recommended handling
DB record exists but the actual file is missingEvaluate the KollusContent.isLoaded() == false condition and remove the corresponding index from the DB. (See the download restoration pipeline after app restart at the DownloadService.onCreate stage.)
File is corruptedAn ERROR_WRITE_FILE error is returned or a player error occurs during playback. Display a message to the user informing them of the file defect and recommending a re-download.