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

Author Topic: Music only plays if directly preceded by a loop? (SFML2)  (Read 2687 times)

0 Members and 2 Guests are viewing this topic.

fatum

  • Newbie
  • *
  • Posts: 47
    • MSN Messenger - bowsers7@hotmail.com
    • AOL Instant Messenger - therealblah569
    • View Profile
    • http://boards.psynetfm.com
Music only plays if directly preceded by a loop? (SFML2)
« on: September 16, 2011, 09:32:30 pm »
I have this bit here:

Code: [Select]

sf::Music test;

if (!test.OpenFromFile("test.ogg"))
{
std::cout << "Oh No!" << std::endl;
}
elsae
{
test.Play();
}


Which doesn't play the audio!  However, if I append this right after "test.Play();"

Code: [Select]

for (;;);


The Music plays as expected.  I've also tried adding test.Play(); in the ::update(); method that's called every frame.

What could the issue be?  Thanks for any help!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Music only plays if directly preceded by a loop? (SFML2)
« Reply #1 on: September 16, 2011, 09:46:23 pm »
What is there after this code? If the Music instance is local to the function, it's destroyed immediately and thus is stopped. It must be alive as long as you want to play it.
Laurent Gomila - SFML developer

 

anything