harmonwood / capacitor-video-player

Capacitor Video Player Plugin
MIT License
112 stars 46 forks source link

Swiping down the control center bugs the player (iOS) #122

Closed PhantomPainX closed 1 year ago

PhantomPainX commented 1 year ago

I don't if it happens to anyone but I'm having this issue when I use the plugin in iOS devices.

Basically the steps to reproduce it is:

  1. Open the video
  2. Swipe down the control center or notification screen
  3. The player shows a black screen with icon on it and only the sound works
  4. You can get the video to be working again locking and unlocking the device.

This video shows it better: https://www.veed.io/view/d42c3186-0c5a-40b6-a634-488d13dfb077?sharingWidget=true&panel=share

PhantomPainX commented 1 year ago

If anyone still experiencing the error

I forgot to post and didn't add a PR after I resolved this weeks ago because this was on purpose in the following observer in CapacitorVideoPlayerPlugin.Observers

willResignObserver =
            NotificationCenter.default.addObserver(
                forName: UIApplication.willResignActiveNotification,
                object: nil, queue: nil) { (_) in
                if !isInPIPMode &&
                    self.videoPlayerFullScreenView != nil {
                    // release video tracks
                    if let playerItem = self.videoPlayerFullScreenView?
                        .playerItem {
                        self.videoTrackEnable(playerItem: playerItem,
                                              enable: false)
                    }
                }
            }

It just disables the video when a system process overlays the video player like Siri, control center, notification panel, etc. The video is not shown again unless we fire a foregroundObserver event.

I just moved the code inside backgroundObserver and it works the same way without affecting the app.

jepiqueau commented 1 year ago

@PhantomPainX this is not really clear for me.Why not do a PR so everyone can benefit from it.

PhantomPainX commented 1 year ago

@PhantomPainX this is not really clear for me.Why not do a PR so everyone can benefit from it.

I didn't make a PR because that code was there on purpose, maybe for some reason. But if you want I will do the PR, no problem 👌

jepiqueau commented 1 year ago

@PhantomPainX i will have a deeper look. Thanks