feat: add visionOS support (#3425)

* feat: add visionOS to target platforms

* disable unsupported API

* add temporary `promises` patches

* fix(visionOS): update promises patches

* apply code review suggestions

* format code
This commit is contained in:
Krzysztof Moch
2024-01-15 08:04:29 +01:00
committed by GitHub
parent 8f1bdb7c36
commit cf3ebb7f15
7 changed files with 108 additions and 42 deletions

View File

@@ -78,24 +78,21 @@ enum RCTVideoDRM {
contentIdData: Data
) -> Promise<Data> {
return Promise<Data>(on: .global()) { fulfill, reject in
var spcError: NSError!
var spcData: Data?
do {
spcData = try loadingRequest.streamingContentKeyRequestData(forApp: certificateData, contentIdentifier: contentIdData as Data, options: nil)
} catch _ {
print("SPC error")
}
#if os(visionOS)
// TODO: DRM is not supported yet on visionOS. See #3467
reject(NSError(domain: "DRM is not supported yet on visionOS", code: 0, userInfo: nil))
#else
guard let spcData = try? loadingRequest.streamingContentKeyRequestData(
forApp: certificateData,
contentIdentifier: contentIdData as Data,
options: nil
) else {
reject(RCTVideoErrorHandler.noSPC)
return
}
if spcError != nil {
reject(spcError)
}
guard let spcData else {
reject(RCTVideoErrorHandler.noSPC)
return
}
fulfill(spcData)
fulfill(spcData)
#endif
}
}