1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Pause and resume the movies when the window lost the focus

This commit is contained in:
Mathieu Schroeter 2017-02-05 18:21:32 +01:00
parent 36d0a341bb
commit c7e79eb8f4
3 changed files with 28 additions and 0 deletions

View File

@ -324,6 +324,8 @@ void WindowProc2 (const SDL_Event &event)
}
SDL_SetWindowTitle (g_window, "Blupi");
if (g_pSound != nullptr) g_pSound->RestartMusic ();
if (g_pMovie)
g_pMovie->Resume ();
return;
case SDL_WINDOWEVENT_FOCUS_LOST:
@ -333,6 +335,8 @@ void WindowProc2 (const SDL_Event &event)
}
SDL_SetWindowTitle (g_window, "Blupi -- stop");
if (g_pSound != nullptr) g_pSound->SuspendMusic ();
if (g_pMovie)
g_pMovie->Pause ();
return;
}
break;

View File

@ -250,6 +250,28 @@ void CMovie::Stop()
SDL_RenderSetLogicalSize (g_renderer, 0, 0);
}
void CMovie::Pause ()
{
if (!m_bEnable || !m_fPlaying)
return;
if (Kit_GetPlayerState (m_player) != KIT_PLAYING)
return;
Kit_PlayerPause (m_player);
}
void CMovie::Resume ()
{
if (!m_bEnable || !m_fPlaying)
return;
if (Kit_GetPlayerState (m_player) != KIT_PAUSED)
return;
Kit_PlayerPlay (m_player);
}
bool CMovie::Render ()
{
if (!m_bEnable || !m_fPlaying)

View File

@ -21,6 +21,8 @@ public:
bool IsExist(char *pFilename);
bool Play(RECT rect, char *pFilename);
void Stop();
void Pause ();
void Resume ();
bool Render ();
protected: