Forum Discussion
Javascript to MUTE audio?
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
Ajay have you got solution?
- AjayKhatri9 years agoCommunity 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.
- anithaduraisamy8 years agoCommunity Member
Hi Ajay,
i am new to articulate.
How to use this code?
where to use this code?
can you help me please......
thank you,
Anitha
- AjayKhatri8 years agoCommunity Member
Hi Anitha
This code is applied to triggers on the audio on/off buttons.
on audio off/mute button, add a new trigger and select execute Javascript and paste the following code:
if (document.location.href.indexOf('html5') < 0) {
} else {var player = GetPlayer();
Audio.setMasterVolume(0);
$('audio').prop('volume','0');
}On audio on button,
add a new trigger and select execute Javascript and paste the following code:
if (document.location.href.indexOf('html5') < 0) {
} else {var player = GetPlayer();
Audio.setMasterVolume(0.8);
$('audio').prop('volume','0.8');
}please note that this code will work only in HTML 5 version of the publish course content.
and for Flash version of the published content you can use the mute toggler as explained in this thread.
give me a shout if you need any more help in Articulate Storyline.
Regards
Ajay Khatri
- MayurRaskar-c868 years agoCommunity Member
not working yet. can you show me video or screenshots.
- AjayKhatri8 years agoCommunity Member
Hi Mayur,
Can you tell me what is the exact problem you are facing in implementation.
Sorry I am little busy these days so couldn't reply earlier.
Ajay