0

I want to have a mute button for my site, so when it's pressed it will unmute / mute the audio playing from the background video. The js I have rn is this. Is there any way I can implement a button with this code?

`enter code here

var videos = [
'D1sZ_vwqwcE',
'BC_Ya4cY8RQ',
'HPc8QMycGno',
'JDglMK9sgIQ',
'hgKDu5pp_fU',
'oKMNj8v2gKE',
'TfnRTifSWh0',
'xO3aB5C3dpQ',
'v5hepekcHkk',
'4kjpZ_sPxzc',
];

var index=Math.floor(Math.random() * videos.length);
var html='<div class="video-background"><div class="video-foreground"><iframe frameborder="0" src="https://www.youtube.com/embed/' +videos[index] + '?controls=1&amp;showinfo=0&amp;rel=0&amp;autoplay=1&amp;iv_load_policy=3&amp;&mute=1" allow="autoplay""></iframe></div></div>';
document.write(html);

site for reference: https://enph.la

Zenithvox
  • 73
  • 8
  • Use [YouTube Iframe Player API instead](https://developers.google.com/youtube/iframe_api_reference) - see [working example](http://jsfiddle.net/Bvance/8bzxp9c2/) - credits: [Custom mute/unmute button Youtube API](https://stackoverflow.com/q/45807269/12511801) – Marco Aurelio Fernandez Reyes Feb 11 '22 at 16:02

0 Answers0