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
Thanks for your continued assistance Jackson.
- JaneJordan1Community Member
- ChristiePollickCommunity Member
You got it, Jane! I was just about to clarify that we were basically just hoping to see the .story file that you work in before you hit the Publish button, and that you should see a small, pinkish-purple "a" icon with your file name where you have saved the file (probably on your C: drive). Glad you got it sorted out! :)
- JaneJordan1Community Member
thanks Christie - bit dozy its the middle of the night here is Oz
- JacksonHamnerCommunity Member
Thanks Jane!
So firstly, the location variable goes back too far, the current one is:
"C:\Users\Jane\Documents\My Articulate Projects\test background music - Storyline output\story_content\WebObjects"
and all you need for that variable is: story_content\WebObjects\6VUFHlYBLQO
The last bit, the 6VUFHlYBLQO part, can be found in the WebObjects folder after you publish your storyline file. If you ever add any additional songs or change the song that you included in the course you will need to find that folder again and update the variable with the new random string of numbers and letters.
Secondly, the trigger setting the song to start playing is missing. In your case, since it is just a single song, I would just lump that trigger into the same javascript trigger you already have to make it easier.
Use this trigger:
//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 = 1.0;
}
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src=Location+"SONGNAMEHERE.mp3";
audio.load();
audio.play();and replace "SONGNAMEHERE.mp3" with the real name of the song. The bold part of the script is the new part and you can add it to your trigger. This should get your music starting when the timeline starts.
Let me know if you run into any more issues! I hope this helps :)
- JaneJordan1Community Member
Wow thank you so much for your help Jackson I will try that out asap - cheers and much appreciate your time
Sent from my iPhone
- ChristiePollickCommunity Member
Understandable, Jane -- happens to us all on occasion! And Jackson, you are a wiz as always, so thanks for all of the assistance you have provided! :)
- JacksonHamnerCommunity Member
Haha, no problaemo guys :)
Its cool seeing other people using this!
- JaneJordan1Community Member
Hi jackson
Couldn't sleep so I got up and tried your solution - I must be missing a step as I couldn't get the music to play, have attached the source file and screen shots of my file locations and web object content and location. hoping you can help thanks Jackson
- JacksonHamnerCommunity Member
Hey Jane,
So I have to apologize, there was an error my previous post that stopped your file from working.
This is what I told you to set the variable as: story_content\WebObjects\6VUFHlYBLQO
It should have been this: story_content/WebObjects/6VUFHlYBLQO/
Notice that the slashes are facing the other direction and there is an additional one at the end. I corrected my mistake and your file started working! I attached the working file to this post so you can see this change.
Sorry about that! Let me know if you run into any more snags :)
- JaneJordan1Community Member
thanks Jackson working perfectly
- JaneJordan1Community Member
Hi Jackson
everything working beautifully - just one thing I came across - when I left
the module and then came back into it where I left off I noticed there
wasn't any music!
Is this because we have the Java script on the first slide and so it
doesn't know if I come in at slide 11 to activate the script.I guess I could put the Java script trigger on every slide or do you know a
quicker way?Thanks again
Jane - JaneJordan1Community Member
Hi Jackson
just wondered if you had a fix or some script for this issue - when the user moves to a different part of the course via the menu the background music stops. And when the user leaves the course Then returns to the course there is no music.
maybe it's not possible - so closeJane
Sent from my iPhone
Maybe you can sleep now Jane :)
Thanks again Jackson.
- JaneJordan1Community Member
Leslie 6am not time to get up now - it was worth it thanks guys
Haha! I know the feeling. Glad you have a great start to your day!!
Related Content
- 12 months ago
- 3 years ago