YouTube provide Iframe code for videos, which you can use anywhere on website page easily. Also some basic customization offer by YouTube like change video dimensions, hide YouTube branding etc. In this post we will explain you How to embed YouTube video with sound muted.
Usually when website page is load on browser video will play automatically with sound. But if you are using two or more videos on same page, than problem will occur. Many videos play at same time create noisy environment, which will not acceptable. Now you can control the behavior of the embedded player.
Embed Youtube Player with Autoplay and Sound Muted:
If you are using simple website, use below script code directly on website source template. Just change the youTube-video-id in given code to for your video.
Get YouTube id from the video url. See below screenshot.
Here is the Script code to embed YouTube video without sound.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<script src="//www.google.com/jsapi"></script> <script src="//ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script> <div id="youtubeNosound"></div> <script type="text/javascript"> google.load("swfobject", "2.1"); function onYouTubePlayerReady(playerId) { youtubePlayer = document.getElementById("myyoutubePlayer"); youtubePlayer.playVideo(); youtubePlayer.mute(); } var params = { allowScriptAccess: "always" }; var atts = { id: "myyoutubePlayer" }; swfobject.embedSWF("http://www.youtube.com/v/youTube-video-id&feature=plpp_play_all? enablejsapi=1&playerapiid=youtubePlayer&allowFullScreen=true&version=3&loop=1&autohide=1", "youtubeNosound", "100%", "380", "8", null, null, params, atts) </script> |
Using this script code you can easily use Youtube video on your website with muted sound.