SFML community forums

Help => Audio => Topic started by: The Terminator on September 23, 2012, 10:40:26 pm

Title: Music won't work at all
Post by: The Terminator on September 23, 2012, 10:40:26 pm
Hi, on my game the sf::Music class doesn't seem to be working at all. I get no errors, and my path to the file is correct, but no music is being played. Here's some of my code:

//Main music
sf::Music m_mainMusic;

//Load mainMusic into memory and set some propertie    
m_mainMusic.openFromFile("Resources/japanesemusic.ogg");    
m_mainMusic.setVolume(50);  
m_mainMusic.setLoop(true);    
m_mainMusic.play();

It won't work at all, and I tried using sf::Sound and soundbuffer as well and they didn't work either. Any suggestions?
Title: Re: Music won't work at all
Post by: eXpl0it3r on September 23, 2012, 10:45:24 pm
'Stupid' questions: Does your audio driver work? I mean can you listen to music with any other application? Or is the default device set wrongly? ;)
Title: Re: Music won't work at all
Post by: The Terminator on September 23, 2012, 10:47:23 pm
Yes, I tested it out the file with Windows Media Player and the sound file worked fine.
Title: Re: Music won't work at all
Post by: eXpl0it3r on September 23, 2012, 10:56:25 pm
Hmmm, have you tried it with another file than OGG?
Title: Re: Music won't work at all
Post by: The Terminator on September 23, 2012, 10:58:06 pm
Yes, I tried with .mp3, it worked in Media player, but not with SFML :(
Title: Re: Music won't work at all
Post by: Nexus on September 23, 2012, 11:16:31 pm
The mp3 format is not supported by SFML.

Is there a message on the standard output (i.e. console)? Do you even check whether loading succeeds?
Title: Re: Music won't work at all
Post by: The Terminator on September 24, 2012, 01:08:28 am
Just tested, it loads correctly, but still won't play the sound. Very frustrating.
Title: Re: Music won't work at all
Post by: Laurent on September 24, 2012, 08:01:54 am
Can you show a complete and minimal code that reproduces the problem?
Title: Re: Music won't work at all
Post by: Qix on September 28, 2012, 04:53:04 am
Is `openFromFile` returning true?