Skip to content

An example of using AVAssetDownloadTask in Swift to download HLS content to disk for offline playback in iOS devices.

Notifications You must be signed in to change notification settings

shawn-frank/HLSDownloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

HLSDownloader

An example of using AVAssetDownloadTask in Swift to download HLS content to disk for offline playback in iOS devices.

This sample was primarily created in response to this StackOverflow question with regards to a bug in AVAssetDownloadDelegate in iOS 12 and below.

The issue is that the AVAssetDownloadDelegate callbacks do not seem to fire after the app returns to the foreground when coming from the background.

The download seems to continue, however the progress does not get updated. The solution that seems to work for now is to:

  1. Subscribe to the UIApplication.willEnterForegroundNotification notification
  2. Check if the device is running iOS 12 and below as the app is returns to the foreground
  3. If it does, cancel and then resume the download task with the url of location on the iOS device where the file was partially downloaded

This solution seems to reset the delegate and all the AVAssetDownloadDelegate callbacks seem to fire again.

About

An example of using AVAssetDownloadTask in Swift to download HLS content to disk for offline playback in iOS devices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages