Audio

Jul 8, 2010 at 5:59pm
#include <SDL.h>
#include "SimpleAudio.h"
#include <iostream>
int main()
{
Uint8 *keystate = SDL_GetKeyState(NULL);
PlaySound("C:\\Documents and Settings\\Student\\Desktop\\Hamster On A Piano (Eating Popcorn).wav");
while(IsSoundPlaying()) {
if(keystate[SDLK_SPACE]) SDL_PauseAudio(0);
}
}

That's my code. I'm trying to make the audio stop when the space bar is pushed, but it will not work. It doesn't give me any errors, just closes.
Jul 8, 2010 at 6:09pm
Well, I assume IsSoundPlaying() becomes false when you pause the playback and thus the end of main is reached and the program terminates.
Jul 8, 2010 at 6:29pm
I know. So how do I fix it?
Jul 8, 2010 at 6:35pm
You need a differant condition to quite your while() loop. Right now when the spacebar is pressed that finishes the program.
Jul 8, 2010 at 6:41pm
What type of condition?
Jul 8, 2010 at 7:23pm
Is it me, or you're mixing calls of two different libraries? That will just not work.
Topic archived. No new replies allowed.