Sign in to follow this  
FoxMulder900

SDL Mix_PauseMusic() not working

Recommended Posts

I am working on an OpenGL/SDL project and I am just learning to use the SDL_mixer. I have the following code which is supposed to play the music when I get within 40 units of an object, and pause it when I am further than 40 units. The music starts to play correctly when it is supposed to, but the Mix_PauseMusic function doesn't seem to work! I replaced it with Mix_HaltMusic and everything worked perfectly except of course when I use Mix_HaltMusic, my music will not resume where it left off which is what I want! void manageSound() { Vector3 v = Cam.getPosition() - objects[0].getPosition(); if(v.length() < 40 && Mix_PlayingMusic() == 0) { Mix_PlayMusic(music, -1); cout << "play" << endl; } else if(v.length() > 40 && Mix_PlayingMusic() == 1 && Mix_PausedMusic() == 0) { Mix_PauseMusic(); cout << "pause" << endl; } else if(v.length() < 40 && Mix_PlayingMusic() == 1 && Mix_PausedMusic() == 1) { Mix_ResumeMusic(); cout << "resume" << endl; } } Any ideas on why Mix_PauseMusic() doesn't work here would be much appreciated!

Share this post


Link to post
Share on other sites
What kind of music file are you playing? I think some of the music functions only work for music module formats. If you're using MIDI you can convert to .XM or .IT format using ModPlug Tracker. If you're using Ogg Vorbis or MP3, you may be in trouble. I don't know if there is a way to pause those formats.

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