0

我正在尝试按照 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。不知道我还需要做什么才能使其工作。这是我的证书的问题还是我如何从文件创建数据。

4

0 回答 0