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!
- EmilyBurnettCommunity Member
Hi Bruce,
I have not come across a way to adjust the audio levels. Hopefully someone on here will figure that one out soon.
Belle - you should add a space before and after the line of code. Let me know if this work for you.
</div>
<audio src="bensound-anewbeginning.mp3" preload="auto" autoplay loop></audio>
</body>
</html>Let me know how this works out. Also I noticed that you are using HTML5 - From what I have seen here this trick is not working the same for HTML5 - as far as mobile viewing. Lets see if the updated code works on a browser with HTML5 - I will run a test on my end as well.
Thanks!
- JanicePericichCommunity Member
I don't do html coding but I did try this also and it did not work for me. Does this look right?
</div>
<audio src="27TearsInHeaven.mp4" preload="auto" autoplay loop></audio></body>
</html>I'd like to do this for a class reunion for the people who have passed away. I don't get any sound, however, and my music file in in the same folder as the html file.
- BlingOngCommunity Member
i managed to loop music but i want to mute it in certain slides as i am running video. anyone know how to do it?
- DaveCoxCommunity Member
Hi Emily,
This is so cool! Thank for posting this. I'm am definitely adding this to my library of tricks.
Hi April,
Just FYI, I tested this in IE 11, and it worked fine for me.
Hi Tara,
Yes you can adjust the volume. It just requires some additional code. To make this work I changed the audio statement to include and ID:
<audio id="myAudio" src="bensound-jazzyfrenchy.mp3" preload="auto" autoplay loop></audio>
Next, we need a volume control, so I added a very simple HTML volume control on the next line after the audio tag:
<input id="vol-control" type="range" min="0" max="100" step="1" oninput="SetVolume(this.value)" onchange="SetVolume(this.value)"></input>
And finally, we the the SetVolume function referenced by the volume control that we just added. Place this script in the head section. I placed it right after the default script block.
<script>
function SetVolume(val)
{
var player = document.getElementById('myAudio');
console.log('Before: ' + player.volume);
player.volume = val / 100;
console.log('After: ' + player.volume);
}
</script>I've included the modified file for you to look at.
- KathyRobertson2Community Member
Emily this is brilliant - thank you. It hasn't worked for the particular project I'm working on at the moment as I have different music clips on some slides, and I just wanted to fill in the silences with one background tune, but I then get both tunes playing which I don't want.
I will definitely use this method in the future though.
- RobRabeCommunity Member
Hi Emily!
Great post! Tried it and it worked perfectly. I do have one question. Is it possible to have audio start on different slide. For example after the first slide have the audio begin. I'm just starting to learn HTML so I'm not highly advanced yet. Any info would be much appreciated. Thanks!
- OwenHoltSuper Hero
If you use JavaScript to modify the web page dynamically you can change the audio with different slides.
Link to my post in this thread.
Link to additional discussion thread.
- EmilyBurnettCommunity Member
Hi Robert,
I am honestly not sure how to get it to start on a different slide. This was one of my first attempts at adding custom code to a published file. If anyone in the community here knows, I am sure they will share.
Glad this post is still helping!!
- RobRabeCommunity Member
Thanks for the JavaScript Owen! I was able to modify the script you provided and get my looping audio to begin on slide 3 of my course. Very gratifying.
- OwenHoltSuper Hero
Glad it worked out for you.
- RovieGraceTungpCommunity Member
We tried the steps using SToryline 3, we didn't get the same results. Can anyone help?
- OwenHoltSuper Hero
As far as I can see, the JavaScript solution still works in SL3. See the attached SL3 .story file and the zip of the published content. The .story file has 2 song choices on slide 1 and 2 on slide 2 as well as a volume control dial (found on the slide master). Unzip the file and double click the story_html5.html file.
- DanielBoliaCommunity Member
Hi Owen,
Thank you for posting your example and source files. I used your codes to create an SL file with music that spanning multiple scenes. I also used some of Jason Hamner's codes (https://community.articulate.com/discussions/articulate-storyline/background-music-demo?page=3) to auto play a designated music file at the beginning of the scene and stopped at a designated scene. I was also able to go backward in the timeline and the music would auto-restart at the designated scene.
Your volume control button was also very fancy and works wonderfully. However, my course was designed to show the default player volume control. Is there any way to control the background music using the built-in volume control?
Thank you,
Dan