PlayKit supports download and playback of assets.
The PlayKit component responsible for local/offline/downloaded assets is
PKMediaEntry typically has more than one PKMediaSource, so the first step is selecting the most suitable source.
LocalAssetsManager.getPreferredDownloadableMediaSource(for:), passing a PKMediaEntry. It will try to find a downloadable
There are two mechanisms for downloading HLS assets: Kaltura’s DownloadToGo (DTG) library and Apple’s
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.
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.
NOTE: If the asset is FairPlay-protected, the master playlist MUST contain a EXT-X-SESSION-KEY tag with the asset’s
skdURL. Without it, LocalAssetsManager won’t be able to install a FairPlay license. Example (replace ASSET_ID below with the actual id):
In Kaltura’s backend, this is done by enabling “Allow Fairplay Offline” in the VOD_PACKAGER_HLS delivery profile. See screenshot.
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
AVAssetDownloadTaskmust be used, is when downloading FairPlay on iOS 10.0-10.2. We recommend avoiding FairPlay downloads on those iOS versions.
LocalAssetsManager.createLocalMediaEntry(for:localURL:), returns a PKMediaEntry ready to play.
ContentManager.itemPlaybackUrl(id:) to get the playback URL. This is what should be passed as the
Use the download location as you saved during the download process.