在使用AVContentSessionKey的Fairplay流媒体服务器SDK v4.0.1中的演示之后,我正在使用HLS FairPlay实现离线播放。我下载了三个内容,每个内容都被正确下载和保存,文档目录上的.movpkg和它的内容密钥,当我关闭WIFI这三个内容下载正确播放,没有任何问题,在使用以下代码播放Im之前:
let urlAsset = element.urlAsset!
ContentKeyManager.shared.contentKeySession.addContentKeyRecipient(urlAsset)
if !urlAsset.resourceLoader.preloadsEligibleContentKeys {
urlAsset.resourceLoader.preloadsEligibleContentKeys = true
}
self.present(playerViewController, animated: true, completion: {
AssetPlaybackManager.sharedManager.setAssetForPlayback(urlAsset)
})到目前一切尚好。但问题是,当我关闭应用程序(主页按钮关闭应用程序),然后播放下载的内容,只有最后下载的内容正确播放,其他的(第一和第二)在控制台上发送这些错误。
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed"
UserInfo={NSUnderlyingError=0x1c065d760 {Error Domain=NSOSStatusErrorDomain Code=-16227 "(null)"},
NSLocalizedFailureReason=An unknown error occurred (-16227),
NSURL=file:///private/var/mobile/Containers/Data/Application/A950D8DB-B711-47E3-AAF5-C95CC9682430/Library/com.apple.UserManagedAssets.kkG8Ih/644986_7798B8476A473F68.movpkg/, NSLocalizedDescription=The operation could not be completed}我用documents目录中的密钥仔细检查了.movpkg,并且显示正确
/Documents/.keys/one-key
/Documents/.keys/two-key
/Documents/.keys/three-key在错误发生之前,将调用ContentKeyDelegate,并正确加载密钥并将其传递给请求。
if persistableContentKeyExistsOnDisk(withContentKeyIdentifier: assetIDString) {
let urlToPersistableKey = urlForPersistableContentKey(withContentKeyIdentifier: assetIDString)
guard let contentKey = FileManager.default.contents(atPath: urlToPersistableKey.path) else {
/
pendingPersistableContentKeyIdentifiers.remove(assetIDString)
return
}
/
Create an AVContentKeyResponse from the persistent key data to use for requesting a key for
decrypting content.
*/
let keyResponse = AVContentKeyResponse(fairPlayStreamingKeyResponseData: contentKey)
/
keyRequest.processContentKeyResponse(keyResponse)
return
}如果我打印contentKeyRecipients,三个内容都会正确显示
- (lldb) po
ContentKeyManager.shared.contentKeySession.contentKeyRecipients ▿ 3
elements
- 0 : AVURLAsset: 0x1c0234d40, URL = file:///private/var/mobile/Containers/Data/Application/E791A4DE-4261-46B7-A84D-D10B27035FAE/Library/com.apple.UserManagedAssets.kkG8Ih/539628_20469336224AA388.movpkg
- 1 : AVURLAsset: 0x1c0234fa0, URL = file:///private/var/mobile/Containers/Data/Application/E791A4DE-4261-46B7-A84D-D10B27035FAE/Library/com.apple.UserManagedAssets.kkG8Ih/644986_7798B8476A473F68.movpkg
- 2 : AVURLAsset: 0x1c42391c0, URL = file:///private/var/mobile/Containers/Data/Application/E791A4DE-4261-46B7-A84D-D10B27035FAE/Library/com.apple.UserManagedAssets.kkG8Ih/573744_62377F9549C45B93.movpkg我的测试是在iOS 11.1.2和iOS 11.2 beta 2中进行的
我不确定发生了什么,但似乎是持久键有问题,我不知道每个内容是否需要同时与一个AVContentKeySession关联。
如果有人遇到类似的问题,任何帮助都将不胜感激。
提前感谢
发布于 2018-03-07 07:50:04
我也有类似的问题。
但是,由于我需要支持iOS 10,所以我没有使用新的AVContentKeyResponse类。相反,我自己加载持久内容密钥,并将其传递给加载请求。
不管怎样,我得到了和你一样的错误和行为。需要注意的一点是,如果我删除了从磁盘加载持久内容密钥的代码,并且总是从服务器获取密钥,那么一切都会正常工作。但这违背了“离线”回放的目的...
因此,系统似乎认为持久内容密钥无效...
发布于 2018-03-13 01:56:34
您在服务器端使用了哪个TLLV来指定下载内容的租用时长?您使用的是内容密钥持续时间TLLV还是离线密钥TLLV?如果你使用离线密钥TLLV,你需要仔细检查“内容ID”字段对于每个下载的电影是不同的。
发布于 2018-07-27 17:20:03
我们也遇到了这个错误消息。当内容超过服务器端设置的过期日期时,就会发生这种情况。
例如:
显示来自AVPlayerItem.error.description的以下错误消息:
Error Domain=AVFoundationErrorDomain Code=-11800
"The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16227),
NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1d4257310
{Error Domain=NSOSStatusErrorDomain Code=-16227 "(null)"}}您可以通过以下方式再次刷新加密数据
使用AVContentSessionKey的
https://stackoverflow.com/questions/47579882
复制相似问题