SFML community forums
Help => Audio => Topic started by: virus on September 11, 2010, 12:27:03 am
-
Hello!
I am trying to have sf::Music into a dynamic list (struct below):
typedef struct sound{
sf::Music audio;
char *name;
struct sound *next;
}sound;
When I declare:
sound test;
test.audio.OpenFromFile("music.ogg");
test.audio.Play();
it works.
But when I do:
sound *test;
test = (sound*)malloc(sizeof(sound));
test->audio.OpenFromFile("music.ogg");
test->audio.Play();
It doesn't work.
(I know, I am no treating the char stuff, but i just didn't post it here...)
Why doesn't it work?
-
When using C++ you shouldn't use malloc, use new instead.
sound *test;
test = new sound;
-
It worked o.o"
Such an easy solution!
Thanks a LOT! :P
-
What about playing the same music 2 times at almost the same time without stopping the first?
I mean, i am playing a music, and then I want it to start again, without stopping the first music to play, so it starts again and the same music is playing in 2 different positions.
How can I do that?
-
Have two music objects.
-
There is no other way? It is too slow and heavy.
Afterall, i cannot know how many times will i have to play the same song simultaneously :/
-
I did it!
SoundBuffer + Sound
Thanks for helping :)
-
I think that sf::Music is one of the most light-weight class in the SFML library