AVAssetDownloadURLSession从未初始化
创始人
2024-11-12 20:00:22
0

在创建AVAssetDownloadURLSession之前,需要在AppDelegate中设置NSURLSessionConfiguration并创建URLSession。以下是示例代码:

在AppDelegate中:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let backgroundConfiguration = URLSessionConfiguration.background(withIdentifier: "yourIdentifer") backgroundConfiguration.sessionSendsLaunchEvents = true

let downloadSession = URLSession(configuration: backgroundConfiguration, delegate: self, delegateQueue: OperationQueue.main)
downloadSession.getTasksWithCompletionHandler { (dataTasks, uploadTasks, downloadTasks) in
    for downloadTask in downloadTasks {
        downloadTask.cancel()
    }
}
downloadSession.finishTasksAndInvalidate()
return true

}

在ViewController中:

let urlAsset = AVURLAsset(url: videoURL) let downloadTask = downloadSession.makeAssetDownloadTask(asset: urlAsset, assetTitle: "title", assetArtworkData: nil, options: nil) downloadTask?.resume()

注意:此代码在Swift 5.0上测试通过。如果使用的是其他版本的Swift,请确认代码是否适用。

相关内容

热门资讯

发现一款!wepoker辅助透... 发现一款!wepoker辅助透视软件,wepoker公共底牌,真是是真的有挂(的确有挂)1)wepo...
一分钟了解!wpk透视插件,w... 一分钟了解!wpk透视插件,wepoker买钻石有用吗,确实有挂(有挂方针)所有人都在同一条线上,像...
分享开挂内幕!wpk私人局辅助... 分享开挂内幕!wpk私人局辅助是真的吗,WePOker有没有透视方法,总是真的是有挂(存在有挂)所有...
一分钟了解!wepoker免费... 一分钟了解!wepoker免费脚本弱密码,wepoker怎么下载游戏,原来是真的有挂(有挂辅助)1、...
重大科普!hhpoker软件靠... 重大科普!hhpoker软件靠谱吗,hhpoker透视方法,本来是有挂(有挂讲解)1、玩家可以在透视...
关于!hhpoker德州透视,... 关于!hhpoker德州透视,pokermaster辅助器,一贯有挂(详细教程)1、免费脚本咨询教程...
玩家实测!wepoker有没有... 玩家实测!wepoker有没有机器人,hhpoker是真的假的,真是是有挂(有挂分析)1)有没有挂:...
玩家必看攻略!wepoker轻... 玩家必看攻略!wepoker轻量版透视系统,wepoker透视app下载,竟然是有挂(有挂分析)1、...
教学盘点!约局吧作弊脚本,we... 教学盘点!约局吧作弊脚本,wepoker可以免费玩吗,总是是真的有挂(有挂教程)1、很好的工具软件,...
热点推荐!wpk德州局怎么透视... 热点推荐!wpk德州局怎么透视,有哪些免费的wpk作弊码,都是存在有挂(今日头条)1、点击下载安装,...