Advertisement

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

Started by November 26, 2018 07:35 PM
2 comments, last by OmniGamer 6 years 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.

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.

Advertisement
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