mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Fixed audio on android to properly pause when the app is inactive, and resume when the app becomes active again.
This commit is contained in:
@@ -510,22 +510,6 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
||||
msg = new Message("joystickremoved", vargs);
|
||||
}
|
||||
break;
|
||||
#ifdef LOVE_ANDROID
|
||||
case SDL_WINDOWEVENT_MINIMIZED:
|
||||
{
|
||||
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
|
||||
if (audio)
|
||||
audio->pause();
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
{
|
||||
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
|
||||
if (audio)
|
||||
audio->resume();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -590,6 +574,21 @@ Message *Event::convertWindowEvent(const SDL_Event &e) const
|
||||
if (win)
|
||||
win->onSizeChanged(e.window.data1, e.window.data2);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MINIMIZED:
|
||||
case SDL_WINDOWEVENT_RESTORED:
|
||||
#ifdef LOVE_ANDROID
|
||||
{
|
||||
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
|
||||
if (audio)
|
||||
{
|
||||
if (e.window.event == SDL_WINDOWEVENT_MINIMIZED)
|
||||
audio->pause();
|
||||
else if (e.window.event == SDL_WINDOWEVENT_RESTORED)
|
||||
audio->resume();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
// We gave +1 refs to the StrongRef list, so we should release them.
|
||||
|
||||
Reference in New Issue
Block a user