Skip to content

Commit

Permalink
Merge pull request #5 from pfleigo/picture-in-picture
Browse files Browse the repository at this point in the history
fix: move observers to different hooks
  • Loading branch information
pfleigo authored Mar 27, 2023
2 parents 8d817f0 + efe4524 commit d87054f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ios/Video/RCTVideoPlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ class RCTVideoPlayerViewController: AVPlayerViewController {
return false
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)
}

deinit {
NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
}

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

if rctDelegate != nil {
rctDelegate.videoPlayerViewControllerWillDismiss(playerViewController: self)
rctDelegate.videoPlayerViewControllerDidDismiss(playerViewController: self)
}

NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
}

#if !TARGET_OS_TV
Expand Down

0 comments on commit d87054f

Please sign in to comment.