首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下载时,Offline Fairplay AVAssetDownloadTask收到未知错误回调(仅在iOS 10.2上发生)

下载时,Offline Fairplay AVAssetDownloadTask收到未知错误回调(仅在iOS 10.2上发生)
EN

Stack Overflow用户
提问于 2017-01-11 12:23:06
回答 0查看 1.6K关注 0票数 2

我们正在为我们的客户端应用程序构建离线公平播放内容;我们通过引用HLSCatalog演示应用程序中的苹果示例下载管理器AssetPersistenceManager类来实现该功能。在AssetPersistenceManager类中有一个函数和两个回调,我想在这里突出显示,它是

代码语言:javascript
复制
    /
    func downloadStream(for asset: Asset) {
        /
         For the initial download, we ask the URLSession for an AVAssetDownloadTask
         with a minimum bitrate corresponding with one of the lower bitrate variants
         in the asset.
         */
        guard let task = assetDownloadURLSession.makeAssetDownloadTask(asset: asset.urlAsset, assetTitle: asset.name, assetArtworkData: nil, options: [AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: 265000]) else { return }

        /
        task.taskDescription = asset.name

        activeDownloadsMap[task] = asset

        task.resume()

        var userInfo = [String: Any]()
        userInfo[Asset.Keys.name] = asset.name
        userInfo[Asset.Keys.downloadState] = Asset.DownloadState.downloading.rawValue

        NotificationCenter.default.post(name: AssetDownloadStateChangedNotification, object: nil, userInfo:  userInfo)
    }

并在下载完流后回调

代码语言:javascript
复制
func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
    let userDefaults = UserDefaults.standard

    /
     This delegate callback should only be used to save the location URL
     somewhere in your application. Any additional work should be done in
     `URLSessionTaskDelegate.urlSession(_:task:didCompleteWithError:)`.
     */
    if let asset = activeDownloadsMap[assetDownloadTask] {

        userDefaults.set(location.relativePath, forKey: asset.name)
    }
}

最后一个是didCompleteWithError回调

代码语言:javascript
复制
func urlSession(_ session: URLSession, task: URLSessionTask,
didCompleteWithError error: Error?)

在iOS < 10.2上似乎一切正常,但在一些运行最新iOS 10.2的设备上测试后,应用程序总是得到didFinishDownloadTo委托的回调,而只有13-15%的完成百分比,在调用didCompleteWithError之后,我们收到了以下错误

代码语言:javascript
复制
> "=======> completed percent 11.2888760669556" .
> "=======> completed percent 11.44566601233" 
> "=======> completed percent 11.7592459030787"
> "=======> completed percent 12.0728257938275" 
> "=======> completed percent 12.5431956299506" 
> "=======> completed percent 13.0135654660738" 
> "=======> completed percent 13.3271453568226" 
> "=======> completed percent 13.6407252475713" 
> "=======> completed percent 13.9543051383201" 
> "=======> completed percent 14.1110950836945" 
> "=======> completed percent 14.2678850290689" 
> "Error Domain=AVFoundationErrorDomain Code=-11800 \"The operation could not
> be completed\" UserInfo={NSLocalizedDescription=The operation could
> not be completed, NSLocalizedFailureReason=An unknown error occurred
> (-12667)}"

检查代理调试应用程序,指出应用程序在整个接收响应之前关闭连接。

代码语言:javascript
复制
Status
Complete
Failure
Client closed connection before receiving entire response
Response Code
206 Partial Content

只有iOS 10.2有这个错误,在该版本以下的其他操作系统上测试的相同流仍然工作正常。尝试查找有关此部分的iOS 10.2的一些changelog,但一无所获?你们有什么建议吗?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41582668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档