SFML community forums
Help => Audio => Topic started by: Devil0150 on June 12, 2009, 11:39:10 am
-
I am trying to play a wav file but it doesn't play until the end. It plays only the first 3 or 5 seconds. This is the code:
int main()
{
// i make a sprite here
...
// i make some text
...
// here is the sound stuff
sf::SoundBuffer Sound;
if (!Sound.LoadFromFile("C:\\sound.wav"))
return 0;
sf::Sound MySound;
MySound.SetBuffer(Sound);
MySound.SetLoop(true);
sf::Event myEvent;
while (App.IsOpened())
{
while (App.GetEvent(myEvent))
{
if (myEvent.Type == sf::Event::Closed)
App.Close();
}
// Get elapsed time
float ElapsedTime = App.GetFrameTime();
// move sprite on input
...
App.Clear();
App.Draw(Sprite);
App.Draw(Text);
MySound.Play();
App.Display();
}
return 0;
}
Sorry if it is a stupid question, im a beginner.
Im using SFML 1.5 if necessary to know.
-
Why do you call sf::Sound::Play() every loop iteration? Calling it once at the beginning is enough.
-
Which compiler are you using?
Try putting the OpenAL32.dll and libsndfile-1.dll files (somewhere in the SFML package) in the same directory as the ".exe"
Good luck!
-
It worked fine. I just put it out of the loop. Thanks.
-
Try putting the OpenAL32.dll and libsndfile-1.dll files (somewhere in the SFML package) in the same directory as the ".exe"
I guess you normally also need wrap_oal.dll (if it's not in the system directory)...
-
I think OpenAL32.dll is wrap_oal.dll renamed (as OpenAL Soft readme says you can do to avoid the application loading any other OpenAL driver)
Laurent should be the one to answer to that.