Skip to content

Commit 596d7ff

Browse files
authored
fix for PiP still active when app foregrounded on iOS (#888)
1 parent 047706f commit 596d7ff

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

packages/stream_video/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Unreleased
22

3+
🐞 Fixed
4+
* (iOS) Fixed an issue where PiP will not stop when bringing app back to foreground
5+
36
✅ Added
47
* Added `membersLimit` parameter to `getOrCreate()` and `join()` methods in `Call` class to limit number of members listed in the response.
58

packages/stream_video_flutter/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Unreleased
22

3+
🐞 Fixed
4+
* (iOS) Fixed an issue where PiP will not stop when bringing app back to foreground
5+
36
✅ Added
47
* Added `membersLimit` parameter to `getOrCreate()` and `join()` methods in `Call` class to limit number of members listed in the response.
58

packages/stream_video_flutter/ios/Classes/PictureInPicture/StreamPictureInPictureController.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import stream_webrtc_flutter
99

1010
/// A controller class for picture-in-picture whenever that is possible.
1111
final class StreamPictureInPictureController: NSObject, AVPictureInPictureControllerDelegate {
12-
1312
// MARK: - Properties
1413

1514
/// The RTCVideoTrack for which the picture-in-picture session is created.
@@ -80,7 +79,12 @@ final class StreamPictureInPictureController: NSObject, AVPictureInPictureContro
8079
self.contentViewController = contentViewController
8180
self.canStartPictureInPictureAutomaticallyFromInline =
8281
canStartPictureInPictureAutomaticallyFromInline
82+
8383
super.init()
84+
85+
NotificationCenter.default.addObserver(
86+
self, selector: #selector(handleAppDidBecomeActive),
87+
name: UIApplication.didBecomeActiveNotification, object: nil)
8488
}
8589

8690
// MARK: - AVPictureInPictureControllerDelegate
@@ -179,4 +183,15 @@ final class StreamPictureInPictureController: NSObject, AVPictureInPictureContro
179183
private func didUpdatePictureInPictureActiveState(_ isActive: Bool) {
180184
trackStateAdapter.isEnabled = isActive
181185
}
186+
187+
@objc private func handleAppDidBecomeActive() {
188+
guard
189+
let pictureInPictureController,
190+
pictureInPictureController.isPictureInPictureActive == true
191+
else {
192+
return
193+
}
194+
pictureInPictureController.stopPictureInPicture()
195+
}
196+
182197
}

0 commit comments

Comments
 (0)