Pausing and resuming background music
This recipe will help you better understand the concept of pausing and resuming background music.
How to do it...
It is very easy to stop or pause the background music. You don't specify the argument by using these methods. The code for stopping the background music is as follows:
auto audio = CocosDenshion::SimpleAudioEngine::getInstance(); // stop the background music audio->stopBackgroundMusic();
Code for pausing:
// pause the background music audio->pauseBackgroundMusic();
Code for resuming the paused background music:
// resume the background music audio->resumeBackgroundMusic();
How it works...
You can stop the background music that is playing by using the stopBackgroundMusic
method. Alternatively, you can pause the background music by using the pauseBackgroundMusic
method. Once you stop it, you can play it again by using the playBackgroundMusic
method. Further, if you pause it, you can resume playing the music by using the resumeBackgroundMusic...