Jump to content

SoundPlay() loop


Baku
 Share

Recommended Posts

Well, it's very quick to explain. I wanna loop this: SoundPlay($sound, 0) . But how? The musicfile has to be played till it the app closes. But how? If loop the plain cmd it doesnt work coz it starts from the beginning all the time. I already tried it with timediff(), but i guess i havnt made that well, maybe someone of u can do that. But well, i'm actually not care how this happens, its just important that it works :whistle: I hope sum1 can help.

thx in advance

Link to comment
Share on other sites

  • Moderators

Never played with avi's before, but try this in your loop to start the avi:

$avi = FileOpen($sound, 0)
If Not $avi = -1 Then
     SoundPlay($sound, 0)
EndIf

That way it just skips over it if it's open in your loop statement.

Hope it works 4 ya!

Edit: Forgot "/" for end code tag :whistle:

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Sorry, sound / clips what the hell... Nah, I've been up for 2 days almost, getting delerious.... That's my bad w/ the $avi... could just name it $CheckSound.

What do you mean it doesn't loop?

Should probably have it like this:

$CheckSound = FileOpen($sound, 0)
If Not $CheckSound = -1 Then
     SoundPlay($sound, 0)
Else
FileClose($CheckSound) <--
EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This will work only if the duration is short.... If your file is 3 mins for instance,I am not sure if this will work due to limitations of autoit maybe.

You will have to take advantage of Adlib in that case and thats because SoundPlay() doesnt have any Return Values.....

AdlibEnable("PlayLoop",30000)


Func PlayLoop()
SoundPlay($sound)
EndFunc

If the duration of sound is 30secs then make adlib check every 30secs(30000ms) and restart the sound....

If duration is much longer then you would have to use Timer in the AdLib section....

I hope this will suit you well...

C ya

Edited by hgeras
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...