user2924482 user2924482 - 1 month ago 8
HTML Question

YouTube: How to present embed video with sound muted

I'm trying to embed a video with the sound muted but I can not figure out how it make it work.

Currently I'm using this but doesn't work:

<iframe src="https://www.youtube.com/embed/uNRGWVJ10gQ?rel=0&amp;autoplay=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>


Any of you knows how can I make this work ?

Answer

You're going to have to add Javascript to mute the audio. Add an id to your iframe:

<iframe id="myVideo" src="https://www.youtube.com/embed/uNRGWVJ10gQ?rel=0&amp;autoplay=1" width="560" height="315" frameborder="0" allowfullscreen></iframe>

Then retrieve the id with javascript:

var myVideo =  iframe.getElementById('myVideo'); 
myVideo.mute();

Also see the mute section in the Youtube API reference https://developers.google.com/youtube/js_api_reference?csw=1

And the question: How do I automatically play a Youtube video (IFrame API) muted?

Comments