Skip to content

Commit

Permalink
add check for drm type
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofMoch committed Sep 6, 2024
1 parent 51ff367 commit eab800d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ios/Video/Features/DRMManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 9 additions & 0 deletions ios/Video/Features/RCTVideoErrorHandling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum RCTVideoError: Error, Hashable {
case persistableKeyRequestFailed
case embeddedKeyExtractionFailed
case offlineDRMNotSuported
case unsupportedDRMType

var errorCode: Int {
switch self {
Expand Down Expand Up @@ -48,6 +49,8 @@ enum RCTVideoError: Error, Hashable {
return 1012
case .offlineDRMNotSuported:
return 1013
case .unsupportedDRMType:
return 1014
}
}
}
Expand Down Expand Up @@ -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: "")
}
}

Expand Down Expand Up @@ -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: "")
}
}

Expand Down Expand Up @@ -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: "")
}
}
}
Expand Down

0 comments on commit eab800d

Please sign in to comment.