fix(visionOS): remove unsupported apis (#4154)

This commit is contained in:
Krzysztof Moch 2024-09-09 15:46:53 +02:00 committed by GitHub
parent b2fd8d62a1
commit 2c1fc964bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 22 deletions

View File

@ -19,12 +19,15 @@ enum RCTVideoSave {
reject("ERROR_COULD_NOT_CREATE_EXPORT_SESSION", "Could not create export session", nil) reject("ERROR_COULD_NOT_CREATE_EXPORT_SESSION", "Could not create export session", nil)
return return
} }
#if !os(visionOS)
var path: String! var path: String!
path = RCTVideoSave.generatePathInDirectory( path = RCTVideoSave.generatePathInDirectory(
directory: URL(fileURLWithPath: RCTVideoSave.cacheDirectoryPath() ?? "").appendingPathComponent("Videos").path, directory: URL(fileURLWithPath: RCTVideoSave.cacheDirectoryPath() ?? "").appendingPathComponent("Videos").path,
withExtension: ".mp4" withExtension: ".mp4"
) )
let url: NSURL! = NSURL.fileURL(withPath: path) as NSURL let url: NSURL! = NSURL.fileURL(withPath: path) as NSURL
exportSession.outputFileType = .mp4
exportSession.outputFileType = AVFileType.mp4 exportSession.outputFileType = AVFileType.mp4
exportSession.outputURL = url as URL? exportSession.outputURL = url as URL?
exportSession.videoComposition = playerItem?.videoComposition exportSession.videoComposition = playerItem?.videoComposition
@ -39,6 +42,9 @@ enum RCTVideoSave {
resolve(["uri": url.absoluteString]) resolve(["uri": url.absoluteString])
} }
}) })
#else
reject("ERROR_EXPORT_SESSION_CANCELLED", "this function is not supported on visionOS", nil)
#endif
} }
static func generatePathInDirectory(directory: String?, withExtension extension: String?) -> String? { static func generatePathInDirectory(directory: String?, withExtension extension: String?) -> String? {

View File

@ -500,7 +500,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
NowPlayingInfoCenterManager.shared.registerPlayer(player: _player!) NowPlayingInfoCenterManager.shared.registerPlayer(player: _player!)
} }
} else { } else {
#if !os(tvOS) #if !os(tvOS) && !os(visionOS)
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {
// This feature caused crashes, if the app was put in bg, before the source change // This feature caused crashes, if the app was put in bg, before the source change
// https://github.com/TheWidlarzGroup/react-native-video/issues/3900 // https://github.com/TheWidlarzGroup/react-native-video/issues/3900
@ -508,7 +508,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
} }
#endif #endif
_player?.replaceCurrentItem(with: playerItem) _player?.replaceCurrentItem(with: playerItem)
#if !os(tvOS) #if !os(tvOS) && !os(visionOS)
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {
self._playerViewController?.allowsVideoFrameAnalysis = true self._playerViewController?.allowsVideoFrameAnalysis = true
} }