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:
@@ -118,7 +118,9 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate {
|
||||
|
||||
_playerRateChangeObserver = player.observe(\.rate, options: [.old], changeHandler: _handlers.handlePlaybackRateChange)
|
||||
_playerVolumeChangeObserver = player.observe(\.volume, options: [.old], changeHandler: _handlers.handleVolumeChange)
|
||||
_playerExternalPlaybackActiveObserver = player.observe(\.isExternalPlaybackActive, changeHandler: _handlers.handleExternalPlaybackActiveChange)
|
||||
#if !os(visionOS)
|
||||
_playerExternalPlaybackActiveObserver = player.observe(\.isExternalPlaybackActive, changeHandler: _handlers.handleExternalPlaybackActiveChange)
|
||||
#endif
|
||||
}
|
||||
|
||||
func removePlayerObservers() {
|
||||
@@ -151,11 +153,13 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate {
|
||||
func addPlayerViewControllerObservers() {
|
||||
guard let playerViewController, let _handlers else { return }
|
||||
|
||||
_playerViewControllerReadyForDisplayObserver = playerViewController.observe(
|
||||
\.isReadyForDisplay,
|
||||
options: [.new],
|
||||
changeHandler: _handlers.handleReadyForDisplay
|
||||
)
|
||||
#if !os(visionOS)
|
||||
_playerViewControllerReadyForDisplayObserver = playerViewController.observe(
|
||||
\.isReadyForDisplay,
|
||||
options: [.new],
|
||||
changeHandler: _handlers.handleReadyForDisplay
|
||||
)
|
||||
#endif
|
||||
|
||||
_playerViewControllerOverlayFrameObserver = playerViewController.contentOverlayView?.observe(
|
||||
\.frame,
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,9 +28,11 @@ enum RCTVideoAssetsUtils {
|
||||
asset.loadTracks(withMediaType: withMediaType, completionHandler: handler)
|
||||
}
|
||||
} else {
|
||||
return Promise { fulfill, _ in
|
||||
fulfill(asset.tracks(withMediaType: withMediaType))
|
||||
}
|
||||
#if !os(visionOS)
|
||||
return Promise { fulfill, _ in
|
||||
fulfill(asset.tracks(withMediaType: withMediaType))
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user