Is there any way to disable all sound on a browser window that may have embedded videos?
I'm not looking for particular solutions such as targeting Youtube with js etc... I need something general that will shut off all sound for that page so if any video plays it has NO sound. Need something that shuts off sound at the page level, not individually addressing each player via js etc...
I'm not aware of anything that could do that but thought I'd ask.
Many thanks if you could point me in the right direction.
PS: I know about How to mute all sound in a page with JS? but it's not what I need.
To mute all sound in a page with JavaScript, we can set the muted property of each audio element to true . to add the audio elements. We select all the audio and video elements with querySelectorAll . Then we loop through each element in elems and set the muted property of it to true to mute the audio.
If you don't want to jQuery, here's the vanilla JavaScript: ///Mute var video = document. getElementById("your-video-id"); video. muted= true; //Unmute var video = document.
You necessary have to iterate in all audio/video tag and set volume to 0.
<div id="mute-button"><img src=""/><div>
$('#mute-button').on('click', function(){
$('audio,video').each(function(){
$(this).volume = 0.0;
});
});
Alternatively you can pause source:
$(this).pause();
For other embedded tag (youtube, vimeo..), take a look at this discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With