我正在尝试集成Bitmovin ios。但是当我通过“ let config = PlayerConfiguration.fromJson(”“);”实例化播放器时那里的方法显示错误“类型'PlayerConfiguration'没有成员'fromJson'”。请任何人帮助我。

最佳答案

是!我找到了解决方案。

我添加了以下回调。


fpsConfig.prepareCertificate
fpsConfig.prepareLicense
fpsConfig.prepareContentId
fpsConfig.prepareMessage
*
可以使用以下命令设置自定义请求头:
fpsConfig.certificateRequestHeaders
fpsConfig.licenseRequestHeaders

do {
    try config.setSourceItem(url: fairplayStreamUrl)

    // create drm configuration
    let fpsConfig = FairplayConfiguration(license: licenseUrl, certificateURL: certificateUrl)

    // Example of how certificate data can be prepared if custom modifications are needed
    fpsConfig.prepareCertificate = { (data: Data) -> Data in
        // Do something with the loaded certificate
        return data
    }

    fpsConfig.prepareMessage = { (spcData: Data, assetID: String) -> Data in
        return spcData
    }

    fpsConfig.licenseRequestHeaders = ["content-type": "application/octet-stream"]

    fpsConfig.prepareLicense = { (ckc: Data) -> Data in
        return ckc
    }

    fpsConfig.prepareContentId = { (contentId: String) -> String in
        let part1 = contentId.components(separatedBy: ";")[1]
        let part2 = part1.components(separatedBy: "?")[0]
        return part2
    }

    config.sourceItem?.add(drmConfiguration: fpsConfig)

    // Create player based on player configuration
    let player = BitmovinPlayer(configuration: config)

    // Create player view and pass the player instance to it
    let playerView = BMPBitmovinPlayerView(player: player, frame: .zero)

    // Listen to player events
    player.add(listener: self)

    playerView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
    playerView.frame = view.bounds

    view.addSubview(playerView)
    view.bringSubview(toFront: playerView)

    self.player = player
} catch {
    print("Configuration error: \(error)")
}

07-26 09:38