When I am downloading .mp4 or .mov player then it will save into device gallery without any error but when I am trying to save .m3u8 video file it will always giving me this error in error local description:
"Optional(Error Domain=NSCocoaErrorDomain Code=-1 \"(null)\")"
Can anyone help me out from where I am getting wrong?
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask,
didFinishDownloadingTo location: URL) {
// 1
guard let sourceURL = downloadTask.originalRequest?.url else { return }
let download = DownloadManager.sharedDownloadManager.activeDownloads[sourceURL]
DownloadManager.sharedDownloadManager.activeDownloads[sourceURL] = nil
// 2
let destinationURL = localFilePath(for: sourceURL)
print(destinationURL)
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: destinationURL)
}) { saved, error in
if saved {
print("Video saved")
download?.track.downloaded = true
}else{
print("Video not saved")
download?.track.downloaded = false
}
}
}