Game Development Community

HOW TO STOP THE WAV FILE

by karthikeyanK · in Torque Developer Network · 07/14/2009 (5:01 am) · 2 replies

In My project I have to play an audio file(ogg). When the User click the button audio should play and when the user click the same button the audio should off? how to do that?


Here i found code for playing sound.

function Testing()
{

$AudioTestHandleA = alxCreateSource("AudioIntroMusicProfile", expandFilename("data/sound/crowd.wav"));

if (!alxIsPlaying(%handle))
alxPlay(%handle);

else if(alxIsPlaying(%handle))
alxStop(%handle);

}

when i click the button the song is playing.. but when i click the same button the song is not off...

it is still playing...

my project is when i click the button the song should sing and when i click the same button the song should off...

The song is singing ...IT SHOULD OFF...


#1
07/14/2009 (6:13 am)
There's a couple things going wrong here. First your conditional statements are based on a local variable that has nothing in it, while the handle you want to check against is a global variable. So replace the %handle with $AudioTestHandleA.

The second thing is you'll want to move the CreateSource line out of the function. Every time you run the function as it is you're overwriting the handle.
#2
07/14/2009 (9:51 pm)
Thank You so Much Scott Burns...It is working.. so much thank you...