# OpenAl tutorial 8

New Member

• Members
• 2 posts

Posted 05 February 2008 - 11:33 AM

I'm trying to modify the 8'th tutorial on OpenAl and make a fuction that will
stop the sound and then play it again from the start, but i'm having some difficulties with this. Can you post a snippet of how would you write such a function?

### #2ryutenchi

New Member

• Members
• 4 posts

Posted 25 March 2008 - 09:47 AM

you would need to change the while loop in the main() to check for key input and process it ... something like this:
bool running = true;
while(running)
{
char=getKeyBoardInput(); ///not that this needs to not pause the system
if(char == "P"||char=="p")
ogg.playback();
if(char=="S||char=="s")
ogg.stop();
if(char=="q"||char=="Q")
running =false;

ogg.idle();
}

idle() should look something like this:
idle()
{
if(playing)
{
if(!update())
{
alSourceStop(source);
ov_raw_seek(&oggStream,0);
}
}
}

you should be able to make stop just:
stop()
{
alSourceStop(source);
ov_raw_seek(&oggStream,0);
}

if you wanted to do a pause it should simply be:
pause()
{
alSourcePause(source);
}

now I'm no expert, but I think that'll work. if anyone sees anything wrong with that please correct me.
-ryu

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users