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
- RavindraGardi-19 years agoCommunity Member
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