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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user