SFML doesn't play music when music.play() called from angelscript function

Started by
2 comments, last by OmniGamer 5 years, 5 months ago

void PlaySound(string &filename){
	Music music;
	music.openFromFile(filename.c_str());
	music.play();
}

This code doesn't play music, but if I try to play music in main.cpp, everything is ok.

Advertisement

This is not an SFML forum.

But to answer your question, you probably need to keep the Music object alive longer than the scope of the function.

16 hours ago, Miss said:

This is not an SFML forum.

But to answer your question, you probably need to keep the Music object alive longer than the scope of the function.

Thank you very much ;)

This topic is closed to new replies.

Advertisement