minor fixes

This commit is contained in:
TrueZhuanjia
2025-07-13 00:09:42 +08:00
parent b83811cc62
commit 6ea23d94cb
2 changed files with 26 additions and 20 deletions
@@ -74,6 +74,7 @@
SettingsViewController* settingsViewController;
StreamFrameViewController* streamFrameViewController;
id navBarAppearanceStandard;
bool _viewJustAppeared;
NSTimer *_foregroundHostUpdateTimer;
@@ -1625,9 +1626,13 @@ static NSMutableSet* hostList;
-(void)beginForegroundRefresh
{
if (!_background) {
if (!_background || _viewJustAppeared) {
// This will kick off box art caching
_viewJustAppeared = false;
[_foregroundHostUpdateTimer invalidate];
_foregroundHostUpdateTimer = nil;
_foregroundHostUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:5 repeats:YES block:^(NSTimer *timer) {
[self updateHosts];
@@ -1693,7 +1698,11 @@ static NSMutableSet* hostList;
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:NO];
_viewJustAppeared = true;
[self beginForegroundRefresh];
// [self setupHostViewTitle];
// [self reloadScrollHostView]; //remove this for proper test
[self attachWaterMark];
@@ -1774,8 +1783,6 @@ static NSMutableSet* hostList;
[self retrieveSavedHosts];
_discMan = [[DiscoveryManager alloc] initWithHosts:[hostList allObjects] andCallback:self];
[self beginForegroundRefresh];
}
- (void)viewDidDisappear:(BOOL)animated
@@ -859,26 +859,13 @@
//[self.pipController startPictureInPicture];
//sleep(1);
if (_inactivityTimer != nil) {
[_inactivityTimer invalidate];
_inactivityTimer = nil;
}
#if !TARGET_OS_TV
// Terminate the stream if the app is inactive for 60 seconds
Log(LOG_I, @"Starting inactivity termination timer with %d min", _settings.backgroundSessionTimer.intValue);
_inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:60*(double)_settings.backgroundSessionTimer.intValue
target:self
selector:@selector(inactiveTimerExpired:)
userInfo:nil
repeats:NO];
#endif
}
- (void)inactiveTimerExpired:(NSTimer*)timer {
Log(LOG_I, @"Terminating stream after inactivity");
[self returnToMainFrame];
_inactivityTimer = nil;
@@ -901,9 +888,21 @@
NSLog(@"did enter background, %d, %@, %d", _settings.enablePIP, self.pipController, self.pipController.isPictureInPictureActive);
if (_settings.enablePIP && self.pipController && self.pipController.isPictureInPictureActive) {
Log(LOG_I, @"PIP is active, not terminating stream");
return;
//Log(LOG_I, @"PIP is active, not terminating stream");
}
if (_inactivityTimer != nil) {
[_inactivityTimer invalidate];
_inactivityTimer = nil;
}
// Terminate the stream if the app is inactive for ...
Log(LOG_I, @"Starting inactivity termination timer with %d min", _settings.backgroundSessionTimer.intValue);
_inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:60*(double)_settings.backgroundSessionTimer.intValue
target:self
selector:@selector(inactiveTimerExpired:)
userInfo:nil
repeats:NO];
#if !TARGET_OS_TV