Squiffy - How can i change the audio when i click on an other Section/Passage

Hello Guys,

i hope you can help me. I am a newbie at programming and i need a little help. I read some details in the Forum and on the helping page to adding sounds in squiffy: http://docs.textadventures.co.uk/quest/adding_sounds.html

But the link is broken at the section: Playing Multiple Sounds at Once

Me and some collegues (Voice Over Speaker) want to create an interactive story including our voices. I created a little story and saved the audio (.mp3) into my dropbox, created a link and linked it into the script with this code:

 < audio id="Main" src = "link"  controls />

The first step works - fine ;)

Now i want to change the audio after i click for the next section or passage. The first audio should stop and the second audio should start. For example - its german:

Start of the game:
Er setzt sich vor das [Feuer] und [[sieht sich um]](umsehen). 

Es glüht noch ein wenig. Neben dem Feuer liegen noch ein paar trockene Äste. Soll Jack das [Feuer anheizen]?

[Feuer anheizen]: Text...

[[umsehen]]: Text 2...

How can i say squiffy to stop the first audio and start the new one by clicking the next passage or section?

Second question: I want to have music that plays along the journey and it shouldn't change. How can i say squiffy: change the audio in the sections but don't touch the main music?

I read the following topic: https://textadventures.co.uk/forum/squiffy/topic/mkfzgvdu10ksha0tka7xjw/continuous-music-code-issue

But i'm not shure how to implement it. Before the journey starts or between the passages??... newbie^^

Thx for the help. I hope you can understand my broken english ;)

Sorry I can't help you. I remember playing with sound and having only basic luck with it. I seem to recall something that if I played a second back ground music, the first stopped.

Overall, after some futzing with it, I never got anything satisfactory. Not only was it difficult, it made reading the text (I write long passages) had to focus on.

I got nothing here. :(

Well since my post i got a lot of experience and i want to share it.

First create your


Before you start to write your story, link all your audio in this passage.

For example your main song:

 <audio id="Main" src="Your URL.mp3" autoplay loop />

It starts everytime at the beginning of the passage and stops when the track is over or you command it. With loop it will not stop until you command it.

Add in this passage all the other audio elements for each passage or section - but don't use autoplay because all audios will play.

For example audio for section/passage 1:

<audio id="Section1" src="Your URL.mp3"  />

Now create your new section.

::Section 1

and use the following code before you write - use tab and than write, code gets colored:


The ID is the "id" we created in the <audio..> line at the beginning - here it's Section 1. The audio starts to play when you click the linked button before you enter this section.

If a new section/passage e.g. "Section 4" should stop the audio of the previous section(s), write in Section 4:

 ::Section 4
document.getElementByID("ID of your Audio").pause();
document.getElementById("ID of your Audio").currentTime=0;
document.getElementByID("Section 4").play();

The comman [...]currentTime = 0; reset the audio.

Special for @last or @other number:

To play the audio successive -> use setTimout Function:

 setTimeout(function(){squiffy.story.go("Section 5");}, 8000);

When you know the length of your audio in Section 4, write it instead of 8000. 8000 are milliseconds.

Section 5 appears automaticly after 8 seconds(8000 milliseconds) and play the audio you set in section 5.

I host my audio in a dropbox and it works fine. Remember to change the url from dropbox --> dl=0 at the end to dl=1.

Hope my explanation helps =)

This topic is now closed. Topics are closed after 60 days of inactivity.