Jump to content
  • Advertisement
OmniGamer

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

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!