From 2356bdce67cb79575f11c1194da407d05a797168 Mon Sep 17 00:00:00 2001 From: Michele Pozzi <123.mpozzi@gmail.com> Date: Mon, 23 Oct 2023 16:14:08 +0200 Subject: [PATCH] feat(minTimeshiftBufferDepth): add `LiveConfig` serializers on iOS --- ios/RCTConvert+BitmovinPlayer.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ios/RCTConvert+BitmovinPlayer.swift b/ios/RCTConvert+BitmovinPlayer.swift index 9de12cc0..25b07ba7 100644 --- a/ios/RCTConvert+BitmovinPlayer.swift +++ b/ios/RCTConvert+BitmovinPlayer.swift @@ -36,6 +36,9 @@ extension RCTConvert { if let bufferConfig = RCTConvert.bufferConfig(json["bufferConfig"]) { playerConfig.bufferConfig = bufferConfig } + if let liveConfig = RCTConvert.liveConfig(json["liveConfig"]) { + playerConfig.liveConfig = liveConfig + } #if os(iOS) if let remoteControlConfig = RCTConvert.remoteControlConfig(json["remoteControlConfig"]) { playerConfig.remoteControlConfig = remoteControlConfig @@ -191,6 +194,22 @@ extension RCTConvert { return bufferConfig } + /** + Utility method to instantiate a `LiveConfig` from a JS object. + - Parameter json: JS object. + - Returns: The produced `LiveConfig` object, or `nil` if `json` is not valid. + */ + static func liveConfig(_ json: Any?) -> LiveConfig? { + guard let json = json as? [String: Any?] else { + return nil + } + let liveConfig = LiveConfig() + if let minTimeshiftBufferDepth = json["minTimeshiftBufferDepth"] as? NSNumber { + liveConfig.minTimeshiftBufferDepth = minTimeshiftBufferDepth.doubleValue + } + return liveConfig + } + /** Utility method to instantiate an `AdvertisingConfig` from a JS object. - Parameter json: JS object.