1. Home
  2. Web
  3. How to embed a youtube video with the volume muted

How To Embed A YouTube Video With The Volume Muted

A vast majority of videos on Facebook are watched with the volume muted. As you scroll through your timeline, whether it’s from your desktop or the smartphone app, videos play automatically but the volume doesn’t play unless you tap and open the video. There’s no harm in this at all and it keeps you from bothering other people as you watch the fiftieth cat video in your timeline. If you would like to embed a YouTube video with the sound turned off by default then you can use a little script written by Amit Agarwal of Labnol that lets you do just that. The videos auto-play but the sound is muted. Users who visit your website and view the video will have to manually turn the volume up. Here’s how it works.

Visit the YouTube video you want to embed and note the video’s ID from the URL/address bar in your browser. It’s the string of text that follows right after ‘https://www.youtube.com/watch?v=’


Here’s the script you need to embed the video. Simply replace the ‘YOUR_VIDEO_ID’ in the eighth line with the video ID you’ve just copied.

<div id="muteYouTubeVideoPlayer"></div>

<script async src="https://www.youtube.com/iframe_api"></script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('muteYouTubeVideoPlayer', {
videoId: 'YOUR_VIDEO_ID', // YouTube Video ID
width: 560, // Player width (in px)
height: 316, // Player height (in px)
playerVars: {
autoplay: 1, // Auto-play the video on load
controls: 1, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // Hide the Youtube Logo
loop: 1, // Run the video in a loop
fs: 0, // Hide the full screen button
cc_load_policty: 0, // Hide closed captions
iv_load_policy: 3, // Hide the Video Annotations
autohide: 0 // Hide video controls when playing
events: {
onReady: function(e) {
// Written by @labnol

Use this embed code and the YouTube video will be muted. This is what it will look like (screenshot below).


We should mention that this won’t work on videos that can’t be embedded i.e. have restrictions on embedding but will work for just about every other type of video.

Via Labnol


    • loop: 1, // Run the video in a loop
      playlist: ‘VIDEO_ID’, // comma separated playlist to loop through, 1 video will simply repeat

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.