From 546400bfe7963229ea697c768bf0fb976ec1791a Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Tue, 19 Sep 2023 15:41:45 +0200 Subject: [PATCH] fix: fix non-DRM playback on iOS --- ios/SourceModule.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ios/SourceModule.swift b/ios/SourceModule.swift index 54737553..1bd3b735 100644 --- a/ios/SourceModule.swift +++ b/ios/SourceModule.swift @@ -42,8 +42,13 @@ class SourceModule: NSObject, RCTBridgeModule { @objc(initWithAnalyticsConfig:drmNativeId:config:analyticsSourceMetadata:) func initWithAnalyticsConfig(_ nativeId: NativeId, drmNativeId: NativeId?, config: Any?, analyticsSourceMetadata: Any?) { bridge.uiManager.addUIBlock { [weak self] _, _ in - let fairplayConfig = drmNativeId != nil ? self?.getDrmModule()?.retrieve(drmNativeId!) : nil - + let fairplayConfig: FairplayConfig? + if let drmNativeId = drmNativeId { + fairplayConfig = self?.getDrmModule()?.retrieve(drmNativeId) + } else { + fairplayConfig = nil + } + guard self?.sources[nativeId] == nil, let sourceConfig = RCTConvert.sourceConfig(config, drmConfig: fairplayConfig), @@ -64,9 +69,15 @@ class SourceModule: NSObject, RCTBridgeModule { @objc(initWithConfig:drmNativeId:config:) func initWithConfig(_ nativeId: NativeId, drmNativeId: NativeId?, config: Any?) { bridge.uiManager.addUIBlock { [weak self] _, _ in + let fairplayConfig: FairplayConfig? + if let drmNativeId = drmNativeId { + fairplayConfig = self?.getDrmModule()?.retrieve(drmNativeId) + } else { + fairplayConfig = nil + } + guard self?.sources[nativeId] == nil, - let fairplayConfig = drmNativeId != nil ? self?.getDrmModule()?.retrieve(drmNativeId!) : nil, let sourceConfig = RCTConvert.sourceConfig(config, drmConfig: fairplayConfig) else { return