AVAggregateAssetDownloadTask不支持currentRequest属性,但可以通过实现AVAssetDownloadDelegate的方法来获取下载请求。例如:
let downloadTask = AVAggregateAssetDownloadTask(asset: asset, mediaSelections: mediaSelections, options: options)
downloadTask.delegate = self
downloadTask.resume()
...
// Implement AVAssetDownloadDelegate methods
extension ViewController: AVAssetDownloadDelegate {
func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
if let originalRequest = assetDownloadTask.value(forKey: "originalURLRequest") as? URLRequest {
print("Download request: \(originalRequest)")
}
// Handle downloaded asset here
}
}
在AVAssetDownloadDelegate中的didFinishDownloadingTo
方法中,通过获取originalURLRequest
属性来获取下载请求。