Merge pull request #2917 from wood1986/bug/kvo-crash
fix: fix the kvo compliance crash when rapidly switching source
This commit is contained in:
commit
685a626542
@ -233,14 +233,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
// MARK: - Player and source
|
||||
|
||||
@objc
|
||||
func setSrc(_ source:NSDictionary!) {
|
||||
DispatchQueue.global(qos: .default).async {
|
||||
_source = VideoSource(source)
|
||||
if (_source?.uri == nil || _source?.uri == "") {
|
||||
DispatchQueue.global(qos: .default).async {
|
||||
self._player?.replaceCurrentItem(with: nil)
|
||||
}
|
||||
return;
|
||||
}
|
||||
removePlayerLayer()
|
||||
@ -299,9 +297,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
self._player = self._player ?? AVPlayer()
|
||||
DispatchQueue.global(qos: .default).async {
|
||||
self._player?.replaceCurrentItem(with: playerItem)
|
||||
}
|
||||
self._player.replaceCurrentItem(with: playerItem)
|
||||
self._playerObserver.player = self._player
|
||||
self.applyModifiers()
|
||||
self._player?.actionAtItemEnd = .none
|
||||
@ -310,13 +306,6 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
self.setAutomaticallyWaitsToMinimizeStalling(self._automaticallyWaitsToMinimizeStalling)
|
||||
}
|
||||
|
||||
if self._adTagUrl != nil {
|
||||
// Set up your content playhead and contentComplete callback.
|
||||
self._contentPlayhead = IMAAVPlayerContentPlayhead(avPlayer: self._player!)
|
||||
|
||||
self._imaAdsManager.setUpAdsLoader()
|
||||
}
|
||||
|
||||
//Perform on next run loop, otherwise onVideoLoadStart is nil
|
||||
self.onVideoLoadStart?([
|
||||
"src": [
|
||||
@ -330,6 +319,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}.catch{_ in }
|
||||
_videoLoadStarted = true
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
func setDrm(_ drm:NSDictionary) {
|
||||
|
Loading…
Reference in New Issue
Block a user