I am implementing HLS streaming as per Apple Docs
But the problem that I am facing is for resuming the download when the user kills the app. If a download is in progress and say its 50% done and the user kills the app or app is killed by the system due to any reason and when the app is alive again then the URL session delegate of didCompleteWithError
is called
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
}
and here I dont have the partially downloaded file path or ability to resume the task.
The only location for the downloaded file is called when the download is complete via the following delegate call
func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
}
Now doc says to use
downloadSession.getAllTasks { tasksArray in }
but unfortunately, it does not resume the download
So my problem is
- How to resume the task from that downloaded state so that the entire download doesn't start all over again from 0% ?
- For the task that is not resumable or for a particular scenario where I don't want to resume it how can I delete the partially downloaded file ? How will I get the downloaded path (I don't want to search the entire documents directory)