From eab800dff39643cc55baa0c0b83d6daa512982b1 Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Fri, 6 Sep 2024 11:51:11 +0200 Subject: [PATCH] add check for drm type --- ios/Video/Features/DRMManager.swift | 10 +++++++++- ios/Video/Features/RCTVideoErrorHandling.swift | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ios/Video/Features/DRMManager.swift b/ios/Video/Features/DRMManager.swift index 6a3e98ba2c..cad95d17e9 100644 --- a/ios/Video/Features/DRMManager.swift +++ b/ios/Video/Features/DRMManager.swift @@ -37,7 +37,15 @@ class DRMManager: NSObject { self.onVideoError = onVideoError self.onGetLicense = onGetLicense self.drmParams = drmParams - + + if drmParams?.type != "fairplay" { + self.onVideoError?([ + "error": RCTVideoErrorHandler.createError(from: RCTVideoError.unsupportedDRMType), + "target": self.reactTag as Any, + ]) + return + } + contentKeySession.addContentKeyRecipient(asset) } diff --git a/ios/Video/Features/RCTVideoErrorHandling.swift b/ios/Video/Features/RCTVideoErrorHandling.swift index ec18351fe2..db6078307f 100644 --- a/ios/Video/Features/RCTVideoErrorHandling.swift +++ b/ios/Video/Features/RCTVideoErrorHandling.swift @@ -17,6 +17,7 @@ enum RCTVideoError: Error, Hashable { case persistableKeyRequestFailed case embeddedKeyExtractionFailed case offlineDRMNotSuported + case unsupportedDRMType var errorCode: Int { switch self { @@ -48,6 +49,8 @@ enum RCTVideoError: Error, Hashable { return 1012 case .offlineDRMNotSuported: return 1013 + case .unsupportedDRMType: + return 1014 } } } @@ -85,6 +88,8 @@ extension RCTVideoError: LocalizedError { return NSLocalizedString("Failed to extract embedded key", comment: "") case .offlineDRMNotSuported: return NSLocalizedString("Offline DRM is not supported, see https://github.com/TheWidlarzGroup/react-native-video/issues/3539", comment: "") + case .unsupportedDRMType: + return NSLocalizedString("Unsupporeted DRM type", comment: "") } } @@ -118,6 +123,8 @@ extension RCTVideoError: LocalizedError { return NSLocalizedString("Unable to extract the embedded key from the custom scheme URL.", comment: "") case .offlineDRMNotSuported: return NSLocalizedString("You tried to use Offline DRM but it is not supported yet", comment: "") + case .unsupportedDRMType: + return NSLocalizedString("You tried to use unsupporeted DRM type", comment: "") } } @@ -151,6 +158,8 @@ extension RCTVideoError: LocalizedError { return NSLocalizedString("Check if the embedded key is present in the URL and the custom scheme is correctly implemented.", comment: "") case .offlineDRMNotSuported: return NSLocalizedString("Check if localSourceEncryptionKeyScheme is setted", comment: "") + case .unsupportedDRMType: + return NSLocalizedString("Verifiy that you are using fairplay (on Apple devices)", comment: "") } } }