How to Embed a Muted YouTube Video in your Website

It is easy to embed YouTube videos in your website. You grab the default IFRAME embed code, paste it anywhere inside your web page and you’re done. YouTube does offer some basic customization – like you can modify the player dimensions or hide the YouTube branding – but if you would like to exercise more control over the  behavior of the embedded player,  the YouTube Player API is the way to go.

This tutorial explains how you can embed a YouTube video that will auto-play when the web page is loaded but with muted audio.

For instance, a products website may use short screencasts to highlight features and these videos will autoplay when the page is loaded. The volume is however set to 0 and the user can manually click to un-mute the video. Similarly, if you are using a YouTube video background for your website, it makes more sense to use muted embeds that run in a loop

See the demo page.

How to Mute the Embedded YouTube Player

This is easy. Go the YouTube video page and note down the ID of the video from the URL. For instance, if the YouTube video link is http://youtube.com/watch?v=xyz-123, the video id is xyz-123. Once you have the ID, all you have to do is replace YOUR_VIDEO_ID in the following code with that string.

That’s it. Put the code anywhere in your web page and the embedded video would automatically play but muted.

You can further customize the player by modifying the various player variables as commented in the code. For instance, if you set loop as 1, the video will play in a loop. Set fs to 1 to show the fullscreen button inside the video player. Internally, the player is embedded using the YouTube IFRAME API. When the page is loaded, the onReady event runs that mutes the video.

youtube-mute-video-embed.png

The embedded YouTube video will autoplay, but muted.


The story, How to Embed a Muted YouTube Video in your Website, was originally published at Digital Inspiration by Amit Agarwal on 04/06/2016 under Embed, YouTube, Internet.

source:http://ift.tt/1Xrd3KC

Comments

Popular posts from this blog

The 101 Most Useful Websites

Compare MacBook Prices Worldwide with Google Sheets

Interesting Websites to Visit When You’re Bored