Forum Discussion
Javascript to MUTE audio?
Is it possible to MUTE audio in Storyline? I'm working on a course with a ground-up custom interface with a button that's supposed to mute/unmute - not pause/play or stop/play - the audio.
Are there any Javascript gurus out there who know if this is possible? And if so, can you provide the scripts for mute and unmute? That would SO make my day.
Dazed and confused...
Patrice
- KirbyWillisCommunity Member
Hosting via my personal website (per web publish) and on Scormcloud (via LMS publish) for testing purposes. In both cases, for the HTML5 output, the Javascript is being ignored. However, if I view the HTML5 file off my desktop, it works just fine.
Hi Kirby,
Javascript is supported in HTML5, but you'll want to ensure you're using an HTML5 supported browser. I'm unable to assist with specific Javascript elements, so you may want to post the example here for others in the community to take a look at.
- deepakmohite-78Community Member
I have simply use storyline audio button to mute the audio. You need to publish the course with audio button option then modify the player.css to get the button up on screen.
Thanks Deepak for sharing your solution here, and although this forum discussion is a bit older I'm sure it'll still be helpful to others who come across it. I did also want to mention that you're welcome and encouraged to share any examples, or step by step instructions that may assist other users as they look to replicating your solution.
- AjayKhatriCommunity Member
Hi Everyone,
I have used javascript code to set volume to 0 (mute audio) and set volume to 0.8 (unmute audio)
the code used is:
$('audio').each(function(){
this.volume=0; //mute audio
});$('audio').each(function(){
this.volume=0.8; //unmute audio
});when testing from a web server, this code is working fine in IE11, Firefox but not working in Chrome.
this code is working fine when reviewed locally in IE11, Firefox and Chrome.
Can anyone suggest me a solution for this issue?
Thanks in advance
Ajay Khatri
- RavindraGardi-1Community Member
Ajay have you got solution?
- AjayKhatriCommunity Member
Hi Ravindra,
Yes I got the solution in another thread, I am posting the solution here too so you can see here.
to mute audio I have used this code and it is working fine:
if (document.location.href.indexOf('html5') < 0) {
} else {var player = GetPlayer();
Audio.setMasterVolume(0);
$('audio').prop('volume','0');
}to unmute audio I have used this code and it is working fine:
if (document.location.href.indexOf('html5') < 0) {
} else {var player = GetPlayer();
Audio.setMasterVolume(0.8);
$('audio').prop('volume','0.8');
}the condition mentioned above ensures that these commands work only in HTML5 version of the course.
- ChristiePollickCommunity Member
Hi, Ajay -- Thanks for reaching out here! JavaScript is not something for which we are able to offer support, but there are lots of members here in the community who are quite knowledgeable and will hopefully be able to assist with what you need!
Thanks for popping in to share Ajay and thanks for helping Ravindra :)
Hi Anitha,
You can also message Ajay directly using the "contact me" button on his profile to see if he's able to share any additional information with you about how to use the above code as it's not something our team can offer support for.
- anithaduraisamyCommunity Member
Hi Ashley,
ok and thanks for your reply.
if you know the answer help me.
Hi Heinrich,
I can't speak to the Javascript element - but if it's not working in your LMS it may be worth testing at SCORM Cloud. It's a free standard for testing LMS content and if it works there you should reach out to your LMS team. Take a look at the directions here for how to test in SCORM Cloud.
- HeinrichMain609Community Member
Hi Ashley,
Thanks for the tip. I've tested it in the ScormCloud. There it does not work unfortunately.
I get the following error message in the console:app.min.js:12 actionator::exeJavaScript - Cannot read property 'volume' of undefined
And when I try over the console:
jQuery('audio').prop('volume','0');
I get the following:
[prevObject: init(1), context: document, selector: "audio"]
context:document
length:0
prevObject:init(1)
selector:"audio"
__proto__:Object(0)It seems, that no audio tags found.