Bhupesh Kumar
Bhupesh Kumar

Reputation: 419

How to pause ios app's video playing in Picture in Picture (PIP) when user locks the iPhone?

I am have implemented PIP in my app. When user goes to background while video was playing. App opens PIP and everything works fine. But when user locks the device , PIP is not stopping/Pausing the video.

Is there a way I can pause the Video when user locks the device?

Upvotes: 0

Views: 59

Answers (1)

kaiel
kaiel

Reputation: 1

I had the same issue as well - unfortunately iOS clumps all the UIBackgroundModes for Audio, AirPlay and Picture-in-Picture together so you can't enable one without the other.

What seems to work is setting the AVPlayer instance's audiovisualBackgroundPlaybackPolicy to .pauses, which achieves what you want (pausing the PiP playback when screen is locked).

Upvotes: 0

Related Questions