Revert "fix: pip works only for first invocation"
This reverts commit 3df8f73c25e3ec81c4c90bedd01de7cea7bdda3f.
This commit is contained in:
1 parent
03cabd0506
commit
4640ec86ed
1 file changed
+19
-23
@@ -100,26 +100,12 @@
|
|||||||
|
|
||||||
- (void)pictureInPictureControllerDidStopPictureInPicture:(AVPictureInPictureController *)pictureInPictureController {
|
- (void)pictureInPictureControllerDidStopPictureInPicture:(AVPictureInPictureController *)pictureInPictureController {
|
||||||
_streamView.hidden = NO;
|
_streamView.hidden = NO;
|
||||||
|
|
||||||
if (!_isRestoringFromPiP) {
|
if (!_isRestoringFromPiP) {
|
||||||
[self returnToMainFrame];
|
[self returnToMainFrame];
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_isRestoringFromPiP = NO;
|
_isRestoringFromPiP = NO;
|
||||||
|
|
||||||
[self cleanupPiPController];
|
|
||||||
|
|
||||||
// Immediately set up a new PiP controller.
|
|
||||||
// We cannot wait for a delegate callback that will not fire again.
|
|
||||||
// At this point, we know the stream is active and the renderer is available.
|
|
||||||
if (self->_streamMan && self->_streamMan.videoRenderer) {
|
|
||||||
Log(LOG_I, @"Re-initializing PiP controller immediately after restore.");
|
|
||||||
[self setupPiPControllerWithRenderer:self->_streamMan.videoRenderer];
|
|
||||||
} else {
|
|
||||||
Log(LOG_E, @"Failed to re-initialize PiP controller: renderer was not available.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pictureInPictureController:(AVPictureInPictureController *)pictureInPictureController restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:(void (^)(BOOL restored))completionHandler {
|
- (void)pictureInPictureController:(AVPictureInPictureController *)pictureInPictureController restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:(void (^)(BOOL restored))completionHandler {
|
||||||
_isRestoringFromPiP = YES;
|
_isRestoringFromPiP = YES;
|
||||||
_streamView.hidden = NO;
|
_streamView.hidden = NO;
|
||||||
@@ -850,6 +836,15 @@
|
|||||||
|
|
||||||
// This will fire if the user opens control center or gets a low battery message
|
// This will fire if the user opens control center or gets a low battery message
|
||||||
- (void)applicationWillResignActive:(NSNotification *)notification {
|
- (void)applicationWillResignActive:(NSNotification *)notification {
|
||||||
|
if (_settings.enablePIP && self.pipController && !self.pipController.isPictureInPictureActive && self.pipController.isPictureInPicturePossible) {
|
||||||
|
VideoDecoderRenderer *renderer = self.streamMan.videoRenderer;
|
||||||
|
if (renderer && renderer.displayLayer && self.view.window) {
|
||||||
|
Log(LOG_I, @"Starting Picture in Picture");
|
||||||
|
[self.pipController startPictureInPicture];
|
||||||
|
} else {
|
||||||
|
Log(LOG_I, @"Skipping PiP start: Renderer/Layer/Window not ready OR PiP not possible.");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (_inactivityTimer != nil) {
|
if (_inactivityTimer != nil) {
|
||||||
[_inactivityTimer invalidate];
|
[_inactivityTimer invalidate];
|
||||||
_inactivityTimer = nil;
|
_inactivityTimer = nil;
|
||||||
@@ -888,24 +883,24 @@
|
|||||||
|
|
||||||
// This fires when the home button is pressed
|
// This fires when the home button is pressed
|
||||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||||
Log(LOG_I, @"Application entering background.");
|
|
||||||
|
Log(LOG_I, @"Terminating stream immediately for backgrounding");
|
||||||
|
|
||||||
if (_inactivityTimer != nil) {
|
if (_inactivityTimer != nil) {
|
||||||
[_inactivityTimer invalidate];
|
[_inactivityTimer invalidate];
|
||||||
_inactivityTimer = nil;
|
_inactivityTimer = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// To prevent a race condition, check if PiP is POSSIBLE.
|
// [self returnToMainFrame];
|
||||||
// This property is true even during the slight delay before `isPictureInPictureActive` becomes true.
|
// Don't terminate if pip is active
|
||||||
// If PiP is possible, we should not start a termination timer.
|
if (_settings.enablePIP && self.pipController && self.pipController.isPictureInPictureActive) {
|
||||||
if (_settings.enablePIP && self.pipController && self.pipController.isPictureInPicturePossible) {
|
Log(LOG_I, @"PIP is active, not terminating stream");
|
||||||
Log(LOG_I, @"PiP is possible, avoiding inactivity timer.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
// Only start the timer if PiP is truly not possible.
|
// Terminate the stream if the app is inactive for 60 seconds
|
||||||
Log(LOG_I, @"PiP not possible, starting inactivity termination timer.");
|
Log(LOG_I, @"Starting inactivity termination timer");
|
||||||
_inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:60
|
_inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:60
|
||||||
target:self
|
target:self
|
||||||
selector:@selector(inactiveTimerExpired:)
|
selector:@selector(inactiveTimerExpired:)
|
||||||
@@ -913,6 +908,7 @@
|
|||||||
repeats:NO];
|
repeats:NO];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)expandSettingsView{
|
- (void)expandSettingsView{
|
||||||
self.mainFrameViewcontroller.settingsExpandedInStreamView = true; //notify mainFrameViewContorller that this is a setting expansion in stream view, some settings shall be disabled.
|
self.mainFrameViewcontroller.settingsExpandedInStreamView = true; //notify mainFrameViewContorller that this is a setting expansion in stream view, some settings shall be disabled.
|
||||||
[self.mainFrameViewcontroller expandSettingsView];
|
[self.mainFrameViewcontroller expandSettingsView];
|
||||||
|
|||||||
Reference in new issue
Block a user