Skip to content

Commit

Permalink
[bugfix] player is frozen after re-focusing on the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii Drobiazko committed Oct 30, 2023
1 parent ad0422d commit 6a0b793
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
name: UIApplication.willResignActiveNotification,
object: nil
)

NotificationCenter.default.addObserver(
self,
selector: #selector(applicationDidBecomeActive(notification:)),
name: UIApplication.didBecomeActiveNotification,
object: nil
)

NotificationCenter.default.addObserver(
self,
Expand Down Expand Up @@ -192,6 +199,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
_player?.pause()
_player?.rate = 0.0
}

@objc func applicationDidBecomeActive(notification: NSNotification!) {
if _playInBackground || _playWhenInactive || _paused { return }

// Resume the player or any other tasks that should continue when the app becomes active.
_player?.play()
_player?.rate = 1.0
}

@objc func applicationDidEnterBackground(notification:NSNotification!) {
if !_playInBackground {
Expand Down

0 comments on commit 6a0b793

Please sign in to comment.