This stops the music when the game goes into pause, it restarts it when the game resumes. This works fine on desktop but not so good on mobile with Phonon...

This commit is contained in:
Xawotihs
2011-09-03 15:13:12 +00:00
parent bc3250fadc
commit 354f9788cc
2 changed files with 17 additions and 5 deletions

View File

@@ -281,7 +281,7 @@ void GameApp::Destroy()
SAFE_DELETE(Subtypes::subtypesList);
playMusic("none");
stopMusic();
Translator::EndInstance();
WCFilterFactory::Destroy();
@@ -425,12 +425,12 @@ void GameApp::SetNextState(int state)
void GameApp::Pause()
{
stopMusic();
}
void GameApp::Resume()
{
playMusic();
}
void GameApp::DoTransition(int trans, int tostate, float dur, bool animonly)
@@ -486,7 +486,9 @@ void GameApp::DoAnimation(int trans, float dur)
void GameApp::playMusic(string filename, bool loop)
{
if (filename.compare(currentMusicFile) == 0)
if(filename == "") filename = currentMusicFile;
if (filename.compare(currentMusicFile) == 0 && music)
return;
if (music)
@@ -503,3 +505,12 @@ void GameApp::playMusic(string filename, bool loop)
currentMusicFile = filename;
}
}
void GameApp::stopMusic()
{
if (music && currentMusicFile != "")
{
JSoundSystem::GetInstance()->StopMusic(music);
SAFE_DELETE(music);
}
}