I'm trying to download M3U8 media on watchOS by this code:
let configuration = URLSessionConfiguration.background(withIdentifier: "com.id")
let session = AVAssetDownloadURLSession(
configuration: configuration,
assetDownloadDelegate: M3U8DownloadDelegate.shared,
delegateQueue: .main
)
let asset = AVURLAsset(url: URL(string: mediaLink)!)
let downloadTask = session.makeAssetDownloadTask(downloadConfiguration: .init(asset: asset, title: ""))
downloadTask.resume()
m3u8DownloadObservation = downloadTask.progress.observe(\.fractionCompleted) { progress, _ in
print(progress)
}
But downloadTask.progress
is always zero, and the observation is never called.
How to get the progress correctly?