diff options
author | Sylvain CECCHETTO <cecchetto.sylvain@me.com> | 2020-03-31 17:11:53 +0200 |
---|---|---|
committer | Sylvain CECCHETTO <cecchetto.sylvain@me.com> | 2020-03-31 17:11:53 +0200 |
commit | 57d4b580e5775b3812e9821629f12b65d1690fe5 (patch) | |
tree | b33846f459e7b10f06f9b2ae63183fbdf3cf92b4 | |
parent | 249709484ac1cdca47ef46d258890342def703b1 (diff) |
[tvOS] Do not stop player when applicationWillResignActive
-rw-r--r-- | xbmc/platform/darwin/tvos/XBMCApplication.mm | 17 | ||||
-rw-r--r-- | xbmc/platform/darwin/tvos/XBMCController.h | 1 | ||||
-rw-r--r-- | xbmc/platform/darwin/tvos/XBMCController.mm | 15 |
3 files changed, 21 insertions, 12 deletions
diff --git a/xbmc/platform/darwin/tvos/XBMCApplication.mm b/xbmc/platform/darwin/tvos/XBMCApplication.mm index a267b67a90..eb0b2e1048 100644 --- a/xbmc/platform/darwin/tvos/XBMCApplication.mm +++ b/xbmc/platform/darwin/tvos/XBMCApplication.mm @@ -26,15 +26,19 @@ - (void)applicationWillResignActive:(UIApplication*)application { - [self.xbmcController pauseAnimation]; - [self.xbmcController becomeInactive]; + // Occurs when Kodi is interrupted by something + // (e.g. Siri triggered by user, Control center opened by user, Mutlitask opened by user ...) } - (void)applicationDidEnterBackground:(UIApplication*)application { + // Occurs when Kodi has been backgrounded + // (e.g. when user uses remote to go to tvOS homescreen) + // applicationWillResignActive() will always be called before this method if (application.applicationState == UIApplicationStateBackground) { // the app is turn into background, not in by screen lock which has app state inactive. + [self.xbmcController pauseAnimation]; [self.xbmcController enterBackground]; } } @@ -48,6 +52,15 @@ - (void)applicationDidBecomeActive:(UIApplication*)application { + // This function occurs: + // * on the first start of Kodi + // * when Kodi has been activated after a beeing suspending by applicationWillResignActive() + // * when Kodi has been foregrounded after applicationDidEnterBackground() +} + +- (void)applicationWillEnterForeground:(UIApplication*)application +{ + // Occurs only after an applicationDidEnterBackground() [self.xbmcController resumeAnimation]; [self.xbmcController enterForeground]; } diff --git a/xbmc/platform/darwin/tvos/XBMCController.h b/xbmc/platform/darwin/tvos/XBMCController.h index 19385f39cb..85f2db72cc 100644 --- a/xbmc/platform/darwin/tvos/XBMCController.h +++ b/xbmc/platform/darwin/tvos/XBMCController.h @@ -48,7 +48,6 @@ class CFileItem; - (void)enterBackground; - (void)enterForeground; -- (void)becomeInactive; - (void)setFramebuffer; - (bool)presentFramebuffer; - (void)activateKeyboard:(UIView*)view; diff --git a/xbmc/platform/darwin/tvos/XBMCController.mm b/xbmc/platform/darwin/tvos/XBMCController.mm index 47011984d9..900f6f508a 100644 --- a/xbmc/platform/darwin/tvos/XBMCController.mm +++ b/xbmc/platform/darwin/tvos/XBMCController.mm @@ -191,8 +191,13 @@ XBMCController* g_xbmcController; #pragma mark - AppFocus -- (void)becomeInactive +- (void)enterBackground { + m_bgTask = [self enableBackGroundTask]; + m_bgTaskActive = YES; + + CLog::Log(LOGNOTICE, "%s: Running sleep jobs", __FUNCTION__); + // if we were interrupted, already paused here // else if user background us or lock screen, only pause video here, audio keep playing. if (g_application.GetAppPlayer().IsPlayingVideo() && !g_application.GetAppPlayer().IsPaused()) @@ -204,14 +209,6 @@ XBMCController* g_xbmcController; CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_PAUSE_IF_PLAYING); g_application.CurrentFileItem().m_lStartOffset = g_application.GetAppPlayer().GetTime() - 2.50; } -} - -- (void)enterBackground -{ - m_bgTask = [self enableBackGroundTask]; - m_bgTaskActive = YES; - - CLog::Log(LOGNOTICE, "%s: Running sleep jobs", __FUNCTION__); CWinSystemTVOS* winSystem = dynamic_cast<CWinSystemTVOS*>(CServiceBroker::GetWinSystem()); winSystem->OnAppFocusChange(false); |