Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to repeat music?  (Read 4790 times)

0 Members and 1 Guest are viewing this topic.

StrengthSauce

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to repeat music?
« 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();

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: How to repeat music?
« Reply #1 on: April 27, 2015, 11:57:34 pm »
if(mTheme.getStatus() != sf::Music::Status::Playing)
      mTheme.play();
 

documentation.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: How to repeat music?
« Reply #2 on: April 28, 2015, 12:08:06 am »
Or even simpler:

mTheme.setLoop(true);

Link to setLoop


AlexAUT

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: How to repeat music?
« Reply #3 on: April 28, 2015, 07:21:41 am »
Well that's a bit ironic on my part. Guess I should get my eyes checked.

 

anything