+1
Answered

Loop a sound file.

doug 8 years ago updated by ajakhua 7 years ago 6
This might be a feature request, maybe not. I am trying to loop a sound action using the "sync" tag, but no dice. Is there a work around?
Are you looking for an infinite loop?
You could set up 2 actions that call a <play> tag that goes back and forth between the two sound tags.


<action name="sound1">
<sound action="play" source="sound" type="mp3" />
<play anim="sound2" />
</action>
<action name="sound2">
<sound action="play" source="sound" type="mp3" />
<play anim="sound1" />
</action>
That sounds like that would work. I'll give it a shot. Thanks.
I have the same problem. the code above doesn't seem to be working. It produces a lot of sound streams and crushes application. I need background sound loop in my app but can't figure out how to do it...
I was able to get the code above to work by adding a delay to the play action for the length of time that the audio file is. This will allow it to play back to back without issue.


<actions>
<action name="sound1">
<sound action="play" source="pennant" type="mp3" />
<play action="sound2" delay="1"/>
</action>
<action name="sound2">
<sound action="play" source="pennant" type="mp3" />
<play action="sound1" delay="1"/>
</action>
</actions>
Thanks Ian! It works now.

I was doing the same but using "sync" and it was not working as I expected.