Sign in to follow this  
cwl157

music in SDL

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
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

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

Sign in to follow this