Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  78] [ 1]  / answers: 1 / hits: 159928  / 13 Years ago, sun, january 15, 2012, 12:00:00
<iframe class=youtube-player type=text/html src=http://www.youtube.com/embed/JW5meKfy3fY?wmode=opaque&autohide=1&autoplay=1&volume=0&vol=0&mute=1 frameborder=0>&lt;br /&gt;</iframe>


The video isn't muted! I want volume to be 0 when it first plays...


More From » jquery

 Answers
17

Youtube don't provide muting through url parameter (see http://code.google.com/apis/youtube/player_parameters.html).



You have to use javascript for that. see http://code.google.com/apis/youtube/js_api_reference.html for details.



However, please note the warning on the page linked above:
The deprecation of the YouTube JavaScript Player API was announced on January 27, 2015. YouTube Flash embeds have also been deprecated. See the deprecation policy for more information. Please migrate your applications to the IFrame API, which can intelligently use whichever embedded player – HTML () or Flash () – the client supports.



Html



<iframe class=youtube-player id=player type=text/html src=http://www.youtube.com/embed/JW5meKfy3fY?wmode=opaque&autohide=1&autoplay=1&enablejsapi=1 frameborder=0>&lt;br /&gt;</iframe>


please note enablejsapi=1 in the url.



Javascript



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


Update



Previous code had some issues and did not work with current API (playerVars syntax was wrong). Here is the updated code. You may need to tinker with the parameters you need.





         
<div id=player></div>
<script>
// 1. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');

tag.src = https://www.youtube.com/iframe_api;
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 2. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '100%',
width: '100%',
playerVars: {
autoplay: 1,
loop: 1,
controls: 0,
showinfo: 0,
autohide: 1,
modestbranding: 1,
vq: 'hd1080'},
videoId: '1pzWROvY7gY',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}

// 3. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
player.mute();
}

var done = false;
function onPlayerStateChange(event) {

}
function stopVideo() {
player.stopVideo();
}
</script>




[#88009] Friday, January 13, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kamronr

Total Points: 749
Total Questions: 110
Total Answers: 122

Location: Dominica
Member since Sat, Nov 5, 2022
2 Years ago
kamronr questions
Mon, Dec 21, 20, 00:00, 3 Years ago
Fri, Oct 16, 20, 00:00, 4 Years ago
Sat, Oct 3, 20, 00:00, 4 Years ago
Sun, Jul 28, 19, 00:00, 5 Years ago
;