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!

240 Replies
Julius David Natividad

Hi Deirdre Sherman,

That was my problem too when I tried this trick.
The easiest way for me to do, that time, is to manually edit the background
music.
I just used free software to do it and it worked fine.
I hope this helps.

Thanks,
David

David Natividad
Instructional Designer
Pearson People Services

Pearson Management Services Philippines, Inc.
7F North Tower, Rockwell Business Center
Sheridan corner United Street, Mandaluyong City, PH 1552
Mobile Number +63 922 8654739

Learn more at pearson.com

[image: Pearson]

Jerry Beaucaire

For me, the need to use layers for a consistent BG music track doesn't actually continue to the quiz, I like for the audio to change when something really different is onscreen.  So the quiz at the end of a layered scene could be on a slide of it's own with its own special "thinking" music background. 

After the quiz/knowledge check is over, we start the next layered scene.

Edward Jassin

Hi All, If I am using the below JavaScript to play an audio file for background music, what would I need to do to make sure it loops continuously?

Using SL360...not working when I edit code  <audio src="YOURAUDIOHERE.mp3" preload="auto" autoplay loop>

var audio = new Audio('jazz1.mp3');
audio.play();

Nandhakumar S

Hi  All,

I'm adding background music to my course. The BGM should play throughout my course continuously. So, I have used the javascript as provided in this discussion. It works well. But if I move to the next slide by clicking the next button, the BGM is starting over from the beginning. It would not start from the beginning. Need a solution to that. Can anyone help me out of this?

One more thing the next button that I used is a player default.

Lindsay Klotz

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. 

OWEN HOLT

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.

See it in Action HERE.

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!

OWEN HOLT

The audio file can be anywhere on the internet or a server. I add mine to the course resources so it gets published with the rest of the project and stay with them. Once I know the published path, I can use that to point to the file, update my code with the path, and republish.

Regarding publishing as a movie, I doubt this would work as JavaScript is a programming language used on the web.  For music to play across a published StoryLine movie, you would need to add the "soundtrack" using any video editing software. 

OWEN HOLT

Following which advice? Editing the html code or integrating JavaScript?
I've never had the JS code ruin a project, however, I totally agree with the "save a back-up".
I always have (at least) 2 versions of a file at any given time. One that is an archive of the last working version (updated as things work) and a working version were I make changes.

Ren Gomez

Hi Alden,

So sorry to hear your file is coming across corruption issues! I've opened a support case on your behalf to connect you with one of our support engineers to see if we help in any way.

To clarify, your .story file and your published output files are two separate items, and although we don't support modifying published output files, it shouldn't have affected your .story file in any way. It's most likely something else that's causing the corruption.

Look out for an email from support@articulate.com shortly!

Travis Jerovetz

Hello, i have been trying to use this method as well but i cant get it to auto play.  Here is a snip of the code I added:

</script>

<link rel="stylesheet" href="html5/data/css/output.min.css" data-noprefix />
</body>
<script src="html5/lib/scripts/ds-bootstrap.min.js"></script>

<audio src="perspectives.mp3" preload="auto" autoplay loop></audio>

</html>

I aslo have the mp3 added on the same level as the story.html file.

Any suggestions?

Thank you!

Dave Cox

Hi Travis,

Why are you adding these lines to your html file?

<link rel="stylesheet" href="html5/data/css/output.min.css" data-noprefix />
</body>
<script src="html5/lib/scripts/ds-bootstrap.min.js"></script>

I suspect you don't have those paths, or those files in your project, which will cause a file not found error, or a path not found error. The script line loads the bootstrap library, which isn't needed in Storyline. The Link statement probably loads the accompanying css for that library. If you were going to use this library, you would need to load these statement before the <body> tag to work correctly.

You also have the audio section inserted after the closing body tag, </body>. You may need to move that resource into the body section of the code. (Before the </body> tag.)

Travis Jerovetz

Thank you for your quick reply, Dave.

The only code i actually added was the audio file (<audio src="perspectives.mp3" preload="auto" autoplay loop></audio>).    The rest of that snip was just showing placement.  I tried moving that audio file to the body section but that hasn't corrected the issue.

I assume that i can add that mp3 file within the course contents on the same level as the story.html file, but for whatever reason, the audio file still doesn't play.

Ryan Carlson

Hi, Travis, hope that someone didn't already  cover this in the thread as I haven't been able to read the entire thing. If you're fairly certain you're following the instructions, it could also be that your browser is actually launching the "story_html5.html" file (as opposed to the story.html). Are you editing both of those files that are contained in the publishing storyline output?  

Dave Cox

Hi Travis,

That's interesting. I haven't seen Storyline include the bootstrap library in anything I've published so far. That doesn't mean that is doesn't though. I also haven't tried this code in the HTML5 files yet, so I'm not sure if it will still work.

One thing that I can suggest is to try this to troubleshoot:

  • Launch the course in your browser.
  • When the course loads, press F12 on your keyboard. 
  • In the debug window, locate and display the console.
  • Click you browser refresh button to reload the course in the browser.
  • Watch the console window to see if if reports any Javascript errors.

I hope that this helps.

Ryan Carlson

Great solutions, Dave. I can confirm from my own experience that depending on the browser, you may also have to update the story_html5.html with the same code change that is described from the OP. If you're using Chrome, I believe that's when it will do the "browser sniffing" and decide to flip over to the html5.html file.  It's worth editing both of the files to ensure that's not the problem at least.