Forum Discussion
Background Music Demo
I made a demo featuring background music that goes through the whole course (doesn't change from slide to slide). The user can chose from four songs to listen to and can adjust the volume, and the song continues playing through every slide and loops when it completes. I've also added instructions on how to make this work to the module.
I don't know whether someone else has already posted something like this (I couldn't find anything), but hey if so here's one more!
-------
I've put together a second demo that shows a different way to do this. This second version performs the same actions as the first one, but without needing to edit the output files every time you publish! It saves a lot of headaches when you need to edit something in the course because now you don't have to drop the music files into the output folder and you dont have to edit the html file every time you publish!
I've also attached the second version .story file. Its called Background_Music_Version_2.story.
If anyone needs help getting either versions of this to work I'm more than happy to assist :)
203 Replies
- MarceeWilliamsCommunity Member
Hi Marcee,
You'll need to upload all the files within the published output to your LMS to test it. Testing published content locally could cause elements of the content to fail as detailed here.
If you're not ready for it to be live in your LMS, I'd suggest using SCORM Cloud as a testing platform as it's an industry standard for testing SCORM content.
- MarceeWilliamsCommunity Member
Thanks Ashley, but it runs fine in our LMS. I'm just trying to add the continuous audio coding to the html file, per Jackson's suggestion.
- MarceeWilliamsCommunity Member
Thanks Ashley. It runs fine in our LMS, I'm just trying to open the story.html file as suggested here to add the code to that will permit it to play continuous audio throughout the presentation and when I open that specific file, there is no code to modify.
Sorry Marcee - reading to fast and didn't remember that part. Editing the story.html file is not something I can assist with unfortunately, so I'll defer back to the folks that have been helping you here.
- JacksonHamnerCommunity Member
Hi Marcee,
Since opening the html document is causing you problems I would suggest going with the Version 2 option.
1. Create a variable in storyline called 'Location'
2. Create a folder on your desktop, it can be called whatever you'd like.
3. Put all of the music files you want to play in your course in this folder
4. create a new file in the folder called 'index.html'. This file can just be blank
5. Back in your storyline, create a new slide that the learner will never see
6. Create a web object in that slide and link it to the folder you just created with the blank index.html file in it. Make sure to set the web object to load automatically.
7. Publish your file (dont zip) and open the output folder
8. Check under story_content/WebObjects folder and copy the name of the web object folder in there. It will be a series of random characters like 'W7auf51LmL'
9. In storyline set default value of the 'Location' variable to the path whole path 'story_content/WebObjects/[web object name]'
10. Create a trigger that executes javascript when your project starts.
11. paste this javascript into your trigger, it will edit the story.html file for you:
//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.5;
}12. Now you can play your songs with a trigger like this:
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src= location + "SONG1.mp3";
audio.load();
audio.play();remember to change 'SONG1.mp3' to whatever the music file you added was named.
You can adjust the volume (for narration or sound effects or whathaveyou) with this trigger
var audio = document.getElementById('bgSong');
audio.volume = 0.6;That should get it working for you, let me know if you run into any more problems!
- MarceeWilliamsCommunity Member
Thanks Jackson. Now I've got another problem...ugh! I'm just doing the 30-day trial and already a little frustrated. Trying to record brief audio and the audio recorder keeps freezing on me and I have to close the program in Task Manager. :(
- StefanKhlerCommunity Member
Thanks four your input! It works for me! Just one question:
It only works for me, if the trigger for point 12 deals with "If user click on...". When I set up the trigger e. g. "When timeline reach sec 2, than execute javascript", it does not work. Is this normal?
See below.
- BarMazuzCommunity Member
Hey
Thanks a lot; you are very helpful. I follow you, and I am learning a lot!I am no programmer, and I followed exactly your directions, but whenever I try to publish it to Review 360, I do not hear my music. Can you maybe see why?
- ChristiePollickCommunity Member
Hi, Marcee -- I just wanted to stop in to mention that when you reply via email, your signature is displayed publicly here in the threads. You are welcome to edit to remove that information if you wish.
- MarceeWilliamsCommunity Member
Thanks for the heads-up Christine!
- JacksonHamnerCommunity Member
If the audio recorder built into storyline is giving you trouble I would try using a third part program like audacity. Its free to use and seems to do the trick for me.
You may also want to open a support ticket about it crashing on you and see if there's anything the staff can suggest.
- ChristiePollickCommunity Member
Sure thing, Marcee! :)
- AdamGagne-dd85aCommunity Member
This thread is great! Any suggestions on having audio play continuously over a single scene rather than an entire project?
- JacksonHamnerCommunity Member
If you want to stop the song you can run this trigger at the end of the scene or beginning of the next scene.
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src = " ";
audio.load();
audio.play();This will set the song to nothing, so it wont play anything.
If you want to change the music use the same trigger and set audio.src to loctation + the name of your song. You can control when and what song is playing throughout the course.
I hope this helps! Let me know if you need any assistance getting it to work :)
- AdamGagne-dd85aCommunity Member
Thanks so much. I used this code to have the audio run in the background and it worked great:
<audio src="jazzfrenchy.mp3" id="bgSong" preload="auto" autoplay loop></audio>
I then added this exact code as a trigger to be executed when the scene ends but it didnt work:
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src = " ";
audio.load();
audio.play();I am in no way a coding expert. Any idea what I am missing?
Related Content
- 3 years ago
- 3 months ago