Skip to the content.

Docs | iOS

Offline Assets

PlayKit supports download and playback of assets.

On this page:

Download

The PlayKit component responsible for local/offline/downloaded assets is LocalAssetsManager.

Select a source to download

A PKMediaEntry typically has more than one PKMediaSource, so the first step is selecting the most suitable source. Call LocalAssetsManager.getPreferredDownloadableMediaSource(for:), passing a PKMediaEntry. It will try to find a downloadable source.

There are two mechanisms for downloading HLS assets: Kaltura’s DownloadToGo (DTG) library and Apple’s AVAssetDownloadTask. In most cases, DTG should be used. The only case in which AVAssetDownloadTask must be used, is when downloading FairPlay on iOS 10.0-10.2.

NOTE: We recommend that apps restrict FairPlay downloads to iOS 10.3 and up and use DTG.

DownloadToGo (DTG)

Kaltura’s DTG library can download HLS assets, with and without FairPlay protection. Please look at DTG’s guide for detailed usage instructions - the following focuses on PlayKit+DTG integration.

This flow works for clear and AES HLS assets on iOS 8 and up. It also works for FairPlay assets on iOS 10.3 and up.

AVAssetDownloadTask

AVAssetDownloadTask is a facility added to iOS in version 10.0. It can download HLS assets, with and without FairPlay protection. It can also download mp4 assets.

NOTE: As mentioned above, the only case in which AVAssetDownloadTask must be used, is when downloading FairPlay on iOS 10.0-10.2. We recommend avoiding FairPlay downloads on those iOS versions.

See PlayKit’s OfflineSample and Apple’s HLSCatalog for help with using AVAssetDownloadTask.

Playback

Call LocalAssetsManager.createLocalMediaEntry(for:localURL:), returns a PKMediaEntry ready to play.

DTG

Call ContentManager.itemPlaybackUrl(id:) to get the playback URL. This is what should be passed as the localURL above.

AVAssetDownloadTask

Use the download location as you saved during the download process.

More Info

For more on DRM (FairPlay) protection, see the Offline DRM guide.