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.
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
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.