SFML community forums

Help => Audio => Topic started by: StrengthSauce on April 27, 2015, 11:48:18 pm

Title: How to repeat music?
Post by: StrengthSauce on April 27, 2015, 11:48:18 pm
Can I repeat the background music of my game forever until I want it to stop?

All I have right now is:
        // Load music and play.
        sf::Music mTheme;
        if (!mTheme.openFromFile("Theme.wav"))
                return -1;
        mTheme.play();
Title: Re: How to repeat music?
Post by: dabbertorres on April 27, 2015, 11:57:34 pm
if(mTheme.getStatus() != sf::Music::Status::Playing)
      mTheme.play();
 

documentation (http://www.sfml-dev.org/documentation/2.2/classsf_1_1Music.php).
Title: Re: How to repeat music?
Post by: AlexAUT on April 28, 2015, 12:08:06 am
Or even simpler:

mTheme.setLoop(true);

Link to setLoop (http://www.sfml-dev.org/documentation/2.2/classsf_1_1SoundStream.php#a43fade018ffba7e4f847a9f00b353f3d)


AlexAUT
Title: Re: How to repeat music?
Post by: dabbertorres on April 28, 2015, 07:21:41 am
Well that's a bit ironic on my part. Guess I should get my eyes checked.