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 :)
- ChristiePollickCommunity Member
Hi, Jane -- Just in case you wanted to check it out, here is some additional info on Publishing and Sharing Storyline 2 Content. Please let us know if you have any other questions! :)
- RyanGranvilleCommunity Member
Just a message to say thanks a lot Jackson and the community! This thread helped me a lot!
- RyanGranvilleCommunity Member
As I said above I used your code Jackson and it worked great. But do you have an idea on how I could use the built-in pause control to have the music pause as well? (with your code only the slides pause when user click on the built in pause button but not the music).
Thanks in advance!! Ryan
- JacksonHamnerCommunity Member
I don't think there is a way to add a trigger to the player's play/pause button. The only way to have both actions triggered with the same button is to make a custom button for it. What would probably work is to have a button that has the trigger "Pause timeline when user clicks" as well as a "Execute Javascript when user clicks" trigger.You would want the javascript to mute the music (I haven't found a good way to pause audio for real), so this code should work:
var audio = document.getElementById('bgSong');
audio.volume = 0.0;
And when you want it to play again have the button execute another script that sets the volume back to normal:
var audio = document.getElementById('bgSong');
audio.volume = 1.0;
Here is a topic about making a custom play/pause button. Just add the scripts to the button triggers and it should work. https://community.articulate.com/discussions/articulate-storyline/pause-play-button-questionLet me know if you run into any problems, I hope this helps!
Hi Ryan!
I'm sure that Jackson is probably still subscribed to this thread, but if you do not hear back soon, you may want to utilize the 'Contact Me' option on his user profile to reach out directly. Good luck with your project.
- RyanGranvilleCommunity Member
Thanks a lot for your answer Jackson! Your solution would provide a great workaround which I could indeed implement if I did not need the seekbar. As I need it and there is no way(that I know of?) to have only the seekbar without the play/pause button I would prefer not to have 2 play/pause button.
- ChristiePollickCommunity Member
Glad you found the answers you needed, Ryan!
I also wanted to stop in to note for anyone who is considering using JS as an option and may not already be aware, unfortunately, we are not able to provide support for JavaScript coding.
Luckily, we have lots of community members like Jackson and others who are more than willing to share their expertise to assist! And here is a sheet on JavaScript Best Practices for those who'd like to check it out. :)
- JacksonHamnerCommunity Member
Yeah other than having 2 buttons or sacrificing the seekbar I don't know how else you could implement this. Maybe somebody from the community has a better idea of how to get that working?
Sorry I couldn't help more, good luck on your project!
- BelenTallon-862Community Member
Brilliant! It worked great for me.
Many thanks for sharing.
- VirakYangCommunity Member
This is a really brilliant demo, Jackson. Thank heaps.
But I have a project that will have the sound of Guitar, paino and vocal on the same slide. I want them to play together. But how can I use Jackson's script to adjust the volume of each audio?
var audio = document.getElementById('bgSong');
audio.volume = 0.0;I've never coded, so I don't really know how to make this work
Any help would be much appreciated?
Thanks,
Virak
- ChristiePollickCommunity Member
Hi, Virak -- Thanks for reaching out and while I am not able to assist you with coding, you are welcome to reach out to Jackson directly via the 'Contact Me' link on his profile page in the event that he is no longer subscribed here.