fix(visionOS): remove unsupported apis (#4154)
This commit is contained in:
		| @@ -19,26 +19,32 @@ 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 | ||||||
|         } |         } | ||||||
|         var path: String! |  | ||||||
|         path = RCTVideoSave.generatePathInDirectory( |         #if !os(visionOS) | ||||||
|             directory: URL(fileURLWithPath: RCTVideoSave.cacheDirectoryPath() ?? "").appendingPathComponent("Videos").path, |             var path: String! | ||||||
|             withExtension: ".mp4" |             path = RCTVideoSave.generatePathInDirectory( | ||||||
|         ) |                 directory: URL(fileURLWithPath: RCTVideoSave.cacheDirectoryPath() ?? "").appendingPathComponent("Videos").path, | ||||||
|         let url: NSURL! = NSURL.fileURL(withPath: path) as NSURL |                 withExtension: ".mp4" | ||||||
|         exportSession.outputFileType = AVFileType.mp4 |             ) | ||||||
|         exportSession.outputURL = url as URL? |             let url: NSURL! = NSURL.fileURL(withPath: path) as NSURL | ||||||
|         exportSession.videoComposition = playerItem?.videoComposition |             exportSession.outputFileType = .mp4 | ||||||
|         exportSession.shouldOptimizeForNetworkUse = true |             exportSession.outputFileType = AVFileType.mp4 | ||||||
|         exportSession.exportAsynchronously(completionHandler: { |             exportSession.outputURL = url as URL? | ||||||
|             switch exportSession.status { |             exportSession.videoComposition = playerItem?.videoComposition | ||||||
|             case .failed: |             exportSession.shouldOptimizeForNetworkUse = true | ||||||
|                 reject("ERROR_COULD_NOT_EXPORT_VIDEO", "Could not export video", exportSession.error) |             exportSession.exportAsynchronously(completionHandler: { | ||||||
|             case .cancelled: |                 switch exportSession.status { | ||||||
|                 reject("ERROR_EXPORT_SESSION_CANCELLED", "Export session was cancelled", exportSession.error) |                 case .failed: | ||||||
|             default: |                     reject("ERROR_COULD_NOT_EXPORT_VIDEO", "Could not export video", exportSession.error) | ||||||
|                 resolve(["uri": url.absoluteString]) |                 case .cancelled: | ||||||
|             } |                     reject("ERROR_EXPORT_SESSION_CANCELLED", "Export session was cancelled", exportSession.error) | ||||||
|         }) |                 default: | ||||||
|  |                     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? { | ||||||
|   | |||||||
| @@ -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 | ||||||
|                 } |                 } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user