• Advertisement
Sign in to follow this  

music in SDL

This topic is 3517 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok so i have been able to get wav, mid and mp3 files to play with SDL_Mixer so people talking about needing extra stuff to do this... i don't know what your talking about because its all worked for me. But now i am thinking that if it can read mp3 files then i was thinking instead of putting music in the game just put the folder and let the user add songs to it and it would play these songs. I know how to go through files in a directory and i would just go through them and load them in an array of songs. My big question with this is though how do i loop through and play 1 song after another while the game is going on. If i make a while loop that loops through all the files in the directory and plays each song and put it before the game that loop will have to finish before the game is even played. Do i have to do something like create a new thread that would be the function that loops through the music directory and plays the files in it and have that thread run while the game is running?

Share this post


Link to post
Share on other sites
Advertisement
There are many ways to accomplish this. It will really depend on how you want to manage a playlist in your application and your knowledge of the APIs you are using. It could be accomplished with callbacks on song completion, using a different thread, timers etc. For example, creating a timer the same length as a song could make it so that you could change to the next song each time a song completes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement