#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.
Well, I assume IsSoundPlaying() becomes false when you pause the playback and thus the end of main is reached and the program terminates.
I know. So how do I fix it?
You need a differant condition to quite your while() loop. Right now when the spacebar is pressed that finishes the program.
Is it me, or you're mixing calls of two different libraries? That will just not work.