我正在尝试按照Apple示例代码设置Fairplay + HLS。但是,当我调用streamingContentKeyRequestData
时,我看到了错误let certUrl = URL(fileURLWithPath: Bundle.main.path(forResource: "fairplay", ofType: "der")!)
let applicationCertificate = try? Data(contentsOf: certUrl)
guard let contentKeyIdentifierURL = resourceLoadingRequest.request.url,
let assetIDString = contentKeyIdentifierURL.host,
let assetIDData = assetIDString.data(using: .utf8) else {
print("Failed to get url or assetIDString for the request object of the resource.")
return
}
let spcData = try resourceLoadingRequest.streamingContentKeyRequestData(forApp: applicationCertificate,
contentIdentifier: assetIDData,
options: nil)
它将始终引发错误
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12158), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x2823e5710 {Error Domain=NSOSStatusErrorDomain Code=-12158 "(null)"}}
我检查了applicationCertificate不是nil,assetIDData不是nil。不知道我还需要什么才能使它工作。这是我的证书产生的问题还是我如何从文件创建数据。