Forum Discussion
Background Audio Cool Trick
Hi All,
Just wanted to share a way to add audio across all slides in Storyline 2 There are a few posts on here about this, and I found this method to be super simple.
**Please note that this is just a cool trick, and not a built in feature of Storyline 2.
Publish your course, open the story.html file with Notepad, scroll to the bottom and add this code
<audio src="YOURAUDIOHERE.mp3" preload="auto" autoplay loop></audio> with a space before the </body> and place your audio file into the published output folder and there you go. That is it.
Here is an example, http://bit.ly/1sy5dkV and the output folder is attached.
Have fun!
Hello, Everyone! ✨
I'm happy to share that we have released a new update for Storyline 360 (Build 3.79.30834.0).
In this update, we have an enhancement where:
- Background audio is now supported in the published video output.
As a first step, I recommend updating Storyline 360 to the latest version. Here's how:
If you have any questions, please let us know in this thread or privately in a support case.
Have a great day!
- OwenHoltSuper Hero
Here is an attached file where you can see everything in action. The only difference is that with this file, I stream the music from a website rather than load it with SL so the location variable isn't used nor the associated script.
- ShelbyMorrisCommunity Member
This is great and I love your example. However, I can not get mine to work. Does the file have to be an mp3 file?
- ShelbyMorrisCommunity Member
GOT IT! Thank you - works great.
- FoxWilliamGu186Community Member
Hi Shelby, may I know how you got this to work?
- OwenHoltSuper Hero
I use the following JavaScript to load the music on time line start and later adjust its volume:
//load the scripts dynamically into the head of the document
function add_line() {
var line = document.createElement("audio");
var head=document.getElementsByTagName('body')[0];
line.type = "audio/mp3";
line.src="";
line.id="bgSong" ;
line.autoplay = true;
line.loop = true;
head.appendChild(line);
}//but we only want to add these once!
if(document.getElementById('bgSong')==null){
add_line();
var audio = document.getElementById('bgSong');
audio.volume = 0.1;
}//I use a "hidden" web object slide to load my music dynamically. Once I publish the first time, I copy the path to the music file (or files) into a variable titled "location". This is important for the following lines of JavaScript to work.
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src=Location+"Background.mp3";
audio.load();
audio.play();
Then, to adjust the volume, I added 2 buttons (up volume and down volume). The action on the buttons is to adjust a variable (CurrentVolume for example) up or down by increments of 10 as long as it doesn't exceed 100 on the top end or 0 on the bottom.
Next add actions to execute JavaScript if the CurrentVolume variable is equal to each possible volume.For example, if current volume variable is adjusted to equal 50, your JavaScript would be the following:
var audio = document.getElementById('bgSong');
audio.volume = 0.5;
This adjusts the volume to 50%- Cindi-BaneyCommunity Member
This is amazing. Thank you. You just have to remember to place your audio file in the "output" folder AFTER you have published to the Web or LMS. Web version: Update story.html. SCORM for LMS: Update the index.lms.html file.
- OwenHoltSuper Hero
I still believe using JavaScript to modify the HTML code at StoryLine launch is a better method than modifying the published output every time you publish. Save yourselves the headache! Set it, and forget it!
Link to my post in this thread.
Link to additional discussion thread.
I'm more than happy to walk anyone through the JavaScript associated with this alternative method so that you can do more than copy and paste it, you can understand it. :) Just ping me.- LindsayKlotzCommunity Member
Hey so we just need one mp3 to play as background music and loop throughout the course and play automatically when the course starts. Can you help us out? I've tried using the examples before but have not found a way that it can play automatically without user interaction. This is the song we need to play automatically and loop throughout.
- OwenHoltSuper Hero
User interaction is a browser requirement. However, the user only has to interact once and then you can use that interaction to start your media.
My work blocks loading files to the community, however, I included the .story file (SL 360) in the course resources tab. I also included your audio file there as that is where I am playing the file from!
- ChrisTrefzCommunity Member
I've used this trick before, and it was very helpful. But recently it no longer works in Chrome. Still works in IE and Fire fox though.
It sounds like it's a result of a new decision by chrome to mute autoplay adds, and my embedded audio is getting caught up in it.
Has anyone else encountered this, and have a new work around?
- GiuliaBCommunity Member
Hello! I found this trick reaaaally cool and useful but I'd really need to solve this issue with Chrome too :(
Please please please Storyline developers add this feature to the next player upgrade!!!
Hi everyone!
I have some great news to share. We just released another update for Storyline 360. In Update 74, we've included important fixes and new features.
One of the new features we've included is:
- Create immersive experiences with continuous background audio that sets the tone and keeps learners engaged.
Launch the Articulate 360 desktop app on your computer to take advantage of this update, and click the Update button next to Storyline 360. You'll find our step-by-step instructions here.
Please let me know if you have questions!
- KennethColonCommunity Member
Hi Eric,
Is there a fix to get the background audio to publish? I need to publish to an mp4 but the audio doesn't work.
This works great, Emily! Thanks!
- TaraMcCallCommunity Member
This is awesome! Do you know if you can adjust the volume too within the story.html folder?
- EmilyBurnettCommunity Member
Hi Tara,
Glad this worked for you!
Unfortunately i am not aware of a way to adjust the volume. I did try using the Player volume button, and that did not work.
I am sure if there is a way someone will jump in here with a suggestion :)
- AnaVictóriaCommunity Member
Thanks for the tip guys!!