我正在实施Apple Fireplay DRM以将加密内容传送到设备。 我能够成功加载证书,但是当我尝试从AVAssetResourceLoadingRequest
获取SPC数据时,出现此错误。
Error obtaining key request data: AVFoundationErrorDomain reason: Optional("An unknown error occurred (-42650)")
以下是检索 SPC 内容的代码
let spcData: Data!
do {
/*
To obtain the Server Playback Context (SPC), we call
AVAssetResourceLoadingRequest.streamingContentKeyRequestData(forApp:contentIdentifier:options:)
using the information we obtained earlier.
*/
spcData = try resourceLoadingRequest.streamingContentKeyRequestData(forApp: applicationCertificate, contentIdentifier: assetIDData, options: resourceLoadingRequestOptions)
} catch let error as NSError {
print("Error obtaining key request data: (error.domain) reason: (error.localizedFailureReason)")
resourceLoadingRequest.finishLoading(with: error)
return
}
我已经在苹果开发者论坛上搜索了错误代码:42650,但没有运气!
我也收到了这个错误。就我而言,我使用错误的数据格式(函数中的 appIdentifier 参数(生成应用程序证书resourceLoadingRequest.streamingContentKeyRequestData(forApp:contentIdentifier:options:)
提供给我的证书是 base64 编码的。所以我需要用Data(base64Encoded: yourCertificateString)
创建数据。
我也有这个问题。我没有使用永久键,我复制粘贴了示例代码,但我忘记更改
AVAssetResourceLoadingRequestStreamingContentKeyRequestRequiresPersistentKey: true
到false
.
在此之后,它开始工作。