Created
September 2, 2022 18:42
-
-
Save matinzd/c50afa808b911348a85899a06423a709 to your computer and use it in GitHub Desktop.
Patch for react-native-video compile errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/react-native-video/ios/Video/Features/RCTPlayerObserver.swift b/node_modules/react-native-video/ios/Video/Features/RCTPlayerObserver.swift | |
index 68fc56d..d3951dd 100644 | |
--- a/node_modules/react-native-video/ios/Video/Features/RCTPlayerObserver.swift | |
+++ b/node_modules/react-native-video/ios/Video/Features/RCTPlayerObserver.swift | |
@@ -144,7 +144,7 @@ class RCTPlayerObserver: NSObject { | |
// @see endScrubbing in AVPlayerDemoPlaybackViewController.m | |
// of https://developer.apple.com/library/ios/samplecode/AVPlayerDemo/Introduction/Intro.html | |
_timeObserver = player?.addPeriodicTimeObserver( | |
- forInterval: CMTimeMakeWithSeconds(progressUpdateIntervalMS, preferredTimescale: Int32(NSEC_PER_SEC)), | |
+ forInterval: CMTimeMakeWithSeconds(progressUpdateIntervalMS, Int32(NSEC_PER_SEC)), | |
queue:nil, | |
using:_handlers.handleTimeUpdate | |
) | |
diff --git a/node_modules/react-native-video/ios/Video/Features/RCTPlayerOperations.swift b/node_modules/react-native-video/ios/Video/Features/RCTPlayerOperations.swift | |
index cd0ddfe..7744518 100644 | |
--- a/node_modules/react-native-video/ios/Video/Features/RCTPlayerOperations.swift | |
+++ b/node_modules/react-native-video/ios/Video/Features/RCTPlayerOperations.swift | |
@@ -17,7 +17,7 @@ enum RCTPlayerOperations { | |
// The first few tracks will be audio & video track | |
var firstTextIndex:Int = 0 | |
for i in 0..<(trackCount) { | |
- if player?.currentItem?.tracks[i].assetTrack?.hasMediaCharacteristic(.legible) ?? false { | |
+ if player?.currentItem?.tracks[i].assetTrack.hasMediaCharacteristic(.legible) ?? false { | |
firstTextIndex = i | |
break | |
} | |
@@ -172,9 +172,9 @@ enum RCTPlayerOperations { | |
static func seek(player: AVPlayer, playerItem:AVPlayerItem, paused:Bool, seekTime:Float, seekTolerance:Float) -> Promise<Bool> { | |
let timeScale:Int = 1000 | |
- let cmSeekTime:CMTime = CMTimeMakeWithSeconds(Float64(seekTime), preferredTimescale: Int32(timeScale)) | |
+ let cmSeekTime:CMTime = CMTimeMakeWithSeconds(Float64(seekTime), Int32(timeScale)) | |
let current:CMTime = playerItem.currentTime() | |
- let tolerance:CMTime = CMTimeMake(value: Int64(seekTolerance), timescale: Int32(timeScale)) | |
+ let tolerance:CMTime = CMTimeMake(Int64(seekTolerance), Int32(timeScale)) | |
return Promise<Bool>(on: .global()) { fulfill, reject in | |
guard CMTimeCompare(current, cmSeekTime) != 0 else { | |
@@ -190,37 +190,20 @@ enum RCTPlayerOperations { | |
} | |
static func configureAudio(ignoreSilentSwitch:String, mixWithOthers:String) { | |
- let session:AVAudioSession! = AVAudioSession.sharedInstance() | |
- var category:AVAudioSession.Category? = nil | |
- var options:AVAudioSession.CategoryOptions? = nil | |
- | |
- if (ignoreSilentSwitch == "ignore") { | |
- category = AVAudioSession.Category.playback | |
- } else if (ignoreSilentSwitch == "obey") { | |
- category = AVAudioSession.Category.ambient | |
- } | |
- | |
- if (mixWithOthers == "mix") { | |
- options = .mixWithOthers | |
- } else if (mixWithOthers == "duck") { | |
- options = .duckOthers | |
- } | |
+ do { | |
+ let session:AVAudioSession! = AVAudioSession.sharedInstance() | |
+ var options:AVAudioSession.CategoryOptions = .mixWithOthers | |
- if let category = category, let options = options { | |
- do { | |
- try session.setCategory(category, options: options) | |
- } catch { | |
+ if (mixWithOthers == "duck") { | |
+ options = .duckOthers | |
} | |
- } else if let category = category, options == nil { | |
- do { | |
- try session.setCategory(category) | |
- } catch { | |
- } | |
- } else if category == nil, let options = options { | |
- do { | |
- try session.setCategory(session.category, options: options) | |
- } catch { | |
+ | |
+ if (ignoreSilentSwitch == "ignore") { | |
+ try session.setCategory(AVAudioSessionCategoryPlayback, with: options) | |
+ } else if (ignoreSilentSwitch == "obey") { | |
+ try session.setCategory(AVAudioSessionCategoryAmbient, with: options) | |
} | |
+ } catch { | |
} | |
} | |
} | |
diff --git a/node_modules/react-native-video/ios/Video/Features/RCTVideoUtils.swift b/node_modules/react-native-video/ios/Video/Features/RCTVideoUtils.swift | |
index 50df8e3..80b0bc3 100644 | |
--- a/node_modules/react-native-video/ios/Video/Features/RCTVideoUtils.swift | |
+++ b/node_modules/react-native-video/ios/Video/Features/RCTVideoUtils.swift | |
@@ -22,7 +22,7 @@ enum RCTVideoUtils { | |
var effectiveTimeRange:CMTimeRange? | |
for (_, value) in video.loadedTimeRanges.enumerated() { | |
let timeRange:CMTimeRange = value.timeRangeValue | |
- if CMTimeRangeContainsTime(timeRange, time: video.currentTime()) { | |
+ if CMTimeRangeContainsTime(timeRange, video.currentTime()) { | |
effectiveTimeRange = timeRange | |
break | |
} | |
@@ -67,7 +67,7 @@ enum RCTVideoUtils { | |
return firstItem.timeRangeValue | |
} | |
- return (CMTimeRange.zero) | |
+ return kCMTimeRangeZero | |
} | |
static func playerItemDuration(_ player:AVPlayer?) -> CMTime { | |
@@ -76,7 +76,7 @@ enum RCTVideoUtils { | |
return(playerItem.duration) | |
} | |
- return(CMTime.invalid) | |
+ return kCMTimeInvalid | |
} | |
static func calculateSeekableDuration(_ player:AVPlayer?) -> NSNumber { | |
@@ -141,7 +141,7 @@ enum RCTVideoUtils { | |
// UNUSED | |
static func getCurrentTime(playerItem:AVPlayerItem?) -> Float { | |
- return Float(CMTimeGetSeconds(playerItem?.currentTime() ?? .zero)) | |
+ return Float(CMTimeGetSeconds(playerItem?.currentTime() ?? kCMTimeZero)) | |
} | |
static func base64DataFromBase64String(base64String:String?) -> Data? { | |
@@ -172,9 +172,9 @@ enum RCTVideoUtils { | |
let videoCompTrack:AVMutableCompositionTrack! = mixComposition.addMutableTrack(withMediaType: AVMediaType.video, preferredTrackID:kCMPersistentTrackID_Invalid) | |
do { | |
try videoCompTrack.insertTimeRange( | |
- CMTimeRangeMake(start: .zero, duration: videoAsset.timeRange.duration), | |
+ CMTimeRangeMake(kCMTimeZero, videoAsset.timeRange.duration), | |
of: videoAsset, | |
- at: .zero) | |
+ at: kCMTimeZero) | |
} catch { | |
} | |
@@ -182,9 +182,9 @@ enum RCTVideoUtils { | |
let audioCompTrack:AVMutableCompositionTrack! = mixComposition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID:kCMPersistentTrackID_Invalid) | |
do { | |
try audioCompTrack.insertTimeRange( | |
- CMTimeRangeMake(start: .zero, duration: videoAsset.timeRange.duration), | |
+ CMTimeRangeMake(kCMTimeZero, videoAsset.timeRange.duration), | |
of: audioAsset, | |
- at: .zero) | |
+ at: kCMTimeZero) | |
} catch { | |
} | |
@@ -213,9 +213,9 @@ enum RCTVideoUtils { | |
preferredTrackID:kCMPersistentTrackID_Invalid) | |
do { | |
try textCompTrack.insertTimeRange( | |
- CMTimeRangeMake(start: .zero, duration: videoAsset.timeRange.duration), | |
+ CMTimeRangeMake(kCMTimeZero, videoAsset.timeRange.duration), | |
of: textTrackAsset, | |
- at: .zero) | |
+ at: kCMTimeZero) | |
} catch { | |
} | |
} | |
diff --git a/node_modules/react-native-video/ios/Video/RCTVideo.swift b/node_modules/react-native-video/ios/Video/RCTVideo.swift | |
index a339aff..eaf5a34 100644 | |
--- a/node_modules/react-native-video/ios/Video/RCTVideo.swift | |
+++ b/node_modules/react-native-video/ios/Video/RCTVideo.swift | |
@@ -103,28 +103,28 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |
NotificationCenter.default.addObserver( | |
self, | |
selector: #selector(applicationWillResignActive(notification:)), | |
- name: UIApplication.willResignActiveNotification, | |
+ name: NSNotification.Name.UIApplicationWillResignActive, | |
object: nil | |
) | |
NotificationCenter.default.addObserver( | |
self, | |
selector: #selector(applicationDidEnterBackground(notification:)), | |
- name: UIApplication.didEnterBackgroundNotification, | |
+ name: NSNotification.Name.UIApplicationDidEnterBackground, | |
object: nil | |
) | |
NotificationCenter.default.addObserver( | |
self, | |
selector: #selector(applicationWillEnterForeground(notification:)), | |
- name: UIApplication.willEnterForegroundNotification, | |
+ name: NSNotification.Name.UIApplicationWillEnterForeground, | |
object: nil | |
) | |
NotificationCenter.default.addObserver( | |
self, | |
selector: #selector(audioRouteChanged(notification:)), | |
- name: AVAudioSession.routeChangeNotification, | |
+ name: NSNotification.Name.AVAudioSessionRouteChange, | |
object: nil | |
) | |
_playerObserver._handlers = self | |
@@ -196,7 +196,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |
let currentTime = _player?.currentTime() | |
let currentPlaybackTime = _player?.currentItem?.currentDate() | |
let duration = CMTimeGetSeconds(playerDuration) | |
- let currentTimeSecs = CMTimeGetSeconds(currentTime ?? .zero) | |
+ let currentTimeSecs = CMTimeGetSeconds(currentTime ?? kCMTimeZero) | |
NotificationCenter.default.post(name: NSNotification.Name("RCTVideo_progress"), object: nil, userInfo: [ | |
"progress": NSNumber(value: currentTimeSecs / duration) | |
@@ -332,9 +332,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |
@objc | |
func setResizeMode(_ mode: String?) { | |
if _controls { | |
- _playerViewController?.videoGravity = AVLayerVideoGravity(rawValue: mode ?? "") | |
+ _playerViewController?.videoGravity = mode ?? "" | |
} else { | |
- _playerLayer?.videoGravity = AVLayerVideoGravity(rawValue: mode ?? "") | |
+ _playerLayer?.videoGravity = AVLayerVideoGravity.init(rawValue: mode ?? "") | |
} | |
_resizeMode = mode | |
} | |
@@ -586,9 +586,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |
if (viewController == nil) { | |
let keyWindow:UIWindow! = UIApplication.shared.keyWindow | |
viewController = keyWindow.rootViewController | |
- if viewController.children.count > 0 | |
+ if viewController.childViewControllers.count > 0 | |
{ | |
- viewController = viewController.children.last | |
+ viewController = viewController.childViewControllers.last | |
} | |
} | |
if viewController != nil { | |
@@ -643,7 +643,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |
if _controls { | |
let viewController:UIViewController! = self.reactViewController() | |
- viewController.addChild(_playerViewController) | |
+ viewController.addChildViewController(_playerViewController) | |
self.addSubview(_playerViewController.view) | |
} | |
@@ -1050,7 +1050,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH | |
if _repeat { | |
let item:AVPlayerItem! = notification.object as? AVPlayerItem | |
- item.seek(to: CMTime.zero) | |
+ item.seek(to: kCMTimeZero) | |
self.applyModifiers() | |
} else { | |
self.setPaused(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment