swift - Swift AVAssetDownloadURLSession 不会启动
问题描述
let background = URLSessionConfiguration.background(withIdentifier: "AAPL-Identifier")
var assetDownloadURLSession = AVAssetDownloadURLSession(configuration: background, assetDownloadDelegate: self, delegateQueue: OperationQueue.main)
let urlAsset = AVURLAsset(url: URL(string: "https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s-fmp4/f08e80da-bf1d-4e3d-8899-f0f6155f6efa_video_180_250000.m3u8")!)
guard let task = assetDownloadURLSession.aggregateAssetDownloadTask(with: urlAsset, mediaSelections: [urlAsset.preferredMediaSelection], assetTitle: "Testing", assetArtworkData: nil, options:[AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: 265_000]) else { return }
task.resume()
func urlSession(_ session: URLSession, aggregateAssetDownloadTask: AVAggregateAssetDownloadTask, didLoad timeRange: CMTimeRange, totalTimeRangesLoaded loadedTimeRanges: [NSValue], timeRangeExpectedToLoad: CMTimeRange, for mediaSelection: AVMediaSelection) {
print("start download")
}
我正在使用官方示例代码,它工作正常。
但是当我尝试创建我的新样本时, AVAssetDownloadDelegate 永远不会触发......
请帮忙,谢谢!
解决方案
推荐阅读
- javascript - 可以在反应组件中调用函数吗?
- python - 尽管在 run_in_executor 中运行了阻塞方法,但我收到“正在执行的任务”通知
- chart.js - 在 ChartJS 的插件中抓取标题
- java - 带导航的 Android Studio ViewPager
- java - 如何在Android中打开特定的tiktok视频链接?
- html - 当内部文本被包装时,如何防止绝对位置跨度向上移动
- libjpeg-turbo - Jpeg Turbo 适用于彩色但不适用于灰度
- java - 司机爪哇动物保护区
- docker - 如何将 docker 信任根密钥 ID 与实际的根密钥文件相关联
- swiftui - ScrollView + LazyStacks 口吃