I am implementing offline playback of some HLS/m3u8 streams. Everything is working as intended using AVAssetDownloadURLSession
, using it to make AVAssetDownloadTasks
given an AVURLAsset
from a stream url.
I would like to save some custom information in the asset's metadata
property before or after the download is complete, but it is read only. I have tried using AVAssetExportSession
, AVAssetWriter
, etc. but none have worked due to (I think) the special way the OS manages the HLS offline playback files. They are packaged as an .movpkg
Anyone have experience with the above and gotten it to work?
The session is currently set up like this:
private lazy var avAssetDownloadSession = AVAssetDownloadURLSession(configuration: downloadConfig, assetDownloadDelegate: self, delegateQueue: .main)
private let downloadConfig: URLSessionConfiguration
init() {
self.downloadConfig = URLSessionConfiguration.background(withIdentifier: "DownloadConfig")
self.downloadConfig.httpMaximumConnectionsPerHost = 1
}
private func startDownload(for asset: AVURLAsset) {
guard let downloadTask = avAssetDownloadSession.makeAssetDownloadTask(asset: asset, assetTitle: "Test", assetArtworkData: nil, options: nil)
else { return }
downloadTask.taskDescription = "Test task description"
downloadTask.resume()
}
The delegate methods are all firing appropriately, so there's no problem w/ the download part.