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
Awesome Jackson, thanks for popping in to assist Adam here.
- JacksonHamnerCommunity Member
You're right, I was confused with what I did in the past to make this happen. What I did was not stop the audio but turn the volume all the way down.
So this trigger should stop the music from playing:
var audio = document.getElementById('bgSong');
audio.volume = 0.0;
When you want the audio to start playing again you can set the volume back up. - AdamGagne-dd85aCommunity Member
Perfect. Thanks again.
- PraveenDIxit-75Community Member
Thanks Guys for Javascripting
I am not a developer I don't know javascript.
Could you please provide me the javascript code for audio on / off on a single Storyline button.
Thanks in advance!
Regards,
Praveen
Looks like you found a good group to inquire with Praveen :) Good luck with your project.
- JaneJordan1Community Member
Hi Jackson
I have followed your background_music_version_2.story and loaded the java script as you had although I only have one song to play - however it didn't work - I know I must be missing something but not quite sure what it is
I have attached my file hoping you can help.
Jane
- JacksonHamnerCommunity Member
Hi Jane,
Would you be able to share your .story file so I can see how you've set up your triggers? That would help me pinpoint the error much easier.
I can see in your output files that the trigger adding the <audio> tag is working, but the trigger adding the src value for the audio tag didn't since the src="" is still empty. I would start by looking at that trigger to see if there is a problem with the code.
Since you are only using one song I would just hard code the song name into the audio tag when its initialized so you don't have to set up additional triggers. If you can share your .story file I can help you set up the script to do this
- JaneJordan1Community Member
Hi Jackson
Here is the output file.
Jane
- ChristiePollickCommunity Member
Hi, Jane! I see that you replied to Jackson via email, and I wanted to note that if you try to add an attachment when replying via email, unfortunately, it will not appear here in the thread to be accessible.
I also wanted to clarify that what Jackson would like to see is the .story file (or the source file itself) rather than the published output file, and the easiest way to share that would be to stop over into the forum/the thread, and click on the grey "ADD ATTACHMENT" button in the bottom left corner of the reply box. You will be able to browse for your file from there, and it will appear here in the thread. Please let us know if you have any other questions! :)
- JaneJordan1Community Member
Hi Jackson
here is my source file - if you wouldn't mind taking a look at what is missing to make the background music JS work.
Is it also possible to have the java script not execute on one slide or scene in the project, I will have video inserted and it already has background music?
thank you much appreciated
Jane
- JacksonHamnerCommunity Member
Hi Jane,
It is possible to stop the music and resume it while the video is playing. If you execute this javascript trigger it will mute the music:
var audio = document.getElementById('bgSong');
audio.volume = 0.0;and to resume the music:
var audio = document.getElementById('bgSong');
audio.volume = 1.0;The file you shared is actually the zipped output file, what I need is the test_background_music.story file. The file that you open in Storyline to edit the course is the file I need. I cannot open any zip files into Storyline.
Related Content
- 3 years ago
- 3 months ago