Forum Discussion

JamesWHenry's avatar
JamesWHenry
Community Member
3 years ago

Articulate Storyline 360- Music across specific slides - how to stop it?

Hi all.

I know there have been a couple of threads on this topic. The ones I see are more than a couple of years old, from what I can tell, so I am hoping to get a 2022 perspective if possible. I have background audio that I want to initiate on slide 2 and then continue to play until the learner reaches a specific target layer of say, slide 15.

From previous instructions posted on this topic, I have managed to execute the first part of this; my background music is indeed starting when it's supposed to, and continuing across subsequent slides (Woo!, because I really don't know javascript).

The issue I can't yet solve is how to get it to STOP when we reach the target slide. Below is my initial "execute javascript" trigger.

function add_line() {
var line = document.createElement("audio");
var head=document.getElementsByTagName('body')[0];
line.type = "audio/mp3";
line.src="story_content/audio_files/Jeopardy 3 Minute music Mixdown JHenry.mp3";
line.id="bgSong";
line.autoplay = true;
line.loop = true;
head.appendChild(line);
}
if(document.getElementById('bgSong')==null){
add_line();
var audio = document.getElementById('bgSong');
audio.volume = 0.1;
}

 

Can anyone give me the approach and steps to solve this?