0 votes
by (260 points)

Hi there,

I'm trying to figure out how to get my audio files to loop but only on a certain passage. I have a "Storyinit" passage that stores all my audio files:

<<cacheaudio "whitneybg_smc2002" "music/whitneybg_smc2002.mp3">>
<<cacheaudio "citypark_ambience" "music/citypark_ambience.mp3">>

And on my story passages, I have them like this:

<<audio whitneybg_smc2002 play loop>>
<<audio citypark_ambience play loop>>

But after moving on to the next passage or going back to a previous passage, the audio coontinues to play.

Could anyone help me make these audio files loop, but only on the passage I've inserted them in?

Thank you so much!

1 Answer

0 votes
by (44.7k points)

That's basically normal behavior for audio loops.

To stop that you'll want to have any passages which are immediately before or after those passages have something like:

<<audio ":all" stop>>

to stop any audio when you enter those passages.  See the <<audio>> macro documentation for details (and ignore the comment about the <<stopallaudio>> macro, since that macro has been depreciated).

There are other methods, such a setting a variable to determine what audio to play, and then having some code which automatically triggers in every passage transition to play (or not play) the appropriate audio based on the value of that variable (possibly using a special passage, like StoryCaption or PassageFooter, which is triggered on each passage transition).

Hope that helps!  :-)

by (260 points)
Ah, such a quick fix! Thank you so much. And for the link to the <<audio>> macro documentation. Seriously!