HomeinetHow to embed a YouTube video with audio in...

How to embed a YouTube video with the sound muted

In this article you will learn how to embed a YouTube video with autoplay enabled but the sound muted. The YouTube video will play automatically when the webpage loads, but with the sound set to zero.youtube

It's easy to embed  YouTube on your website. You can copy the default IFRAME embed code, paste it anywhere on your website and you're good to go. YouTube also offers very basic customization. You can change the dimensions or hide the YouTube branding etc., but if you would like more control over the behavior of the embedded player then you can do so via the YouTube Player API.

This article explains how you can embed a YouTube video that will play automatically when the web page loads, but with the sound muted.

It could be a useful technique for a website selling various products, for example, to start with a short screencast to highlight the products, playing a 5-10 second video on the initial page load, but without sound so as not to disturb the user.

The volume will automatically be set to zero and the user can manually turn the sound on with a click. Similarly, if you are using a YouTube video as a background, it makes more sense to incorporate muting of the continuously running video.

But let's see how you can do it. Go to the YouTube page that contains the video you want and note the video id from the URL. For example, if the YouTube video link is https://youtube.com/watch?v=xyz-123, the video id is XYZ-123 (i.e. all the characters after v= and up to the next & ). Once you have copied the id, all you have to do in the script below is replace YOUR_VIDEO_ID with your own id.

Then integrate the entire above script into your website code and the video will automatically play with the sound muted.

You can further customize the YouTube player by modifying various variables. For example, if you set loop to 1, the video will play in a loop. If you set fs to 1, a fullscreen button will appear within the video player.

Good luck!

📧
Subscribe to the SecNews Newsletter

The most important Security & Technology news in your Inbox.

SecNews
SecNewshttps://www.secnews.gr
In a world without fences and walls, who needs Gates and Windows

SEARCH

FOLLOW US

📧
Newsletter SecNews
The most important Security & Technology news in your inbox.

LIVE NEWS