This is the iframe I create to autostart a video (music, mostly) in my blog :
< iframe width="140" height="105" src=";amp;showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>
It's all perfect. The only problem is the Audio, because the Volume is too high and I would decrease it-
So I added this part on my code : "&player.setVolume(5)"
The final code, then, is this one:
< iframe width="140" height="105" src=";amp;showinfo=0&autoplay=1&player.setVolume(5)" frameborder="0" allowfullscreen></iframe>
The problem is that it wont works and the Volume is still the deafault one- (but the code still works with autoplay and all other pref).
What is going wrong?
This is the iframe I create to autostart a video (music, mostly) in my blog :
< iframe width="140" height="105" src="https://www.youtube./embed/tGzl_AB4poI?rel=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe>
It's all perfect. The only problem is the Audio, because the Volume is too high and I would decrease it-
So I added this part on my code : "&player.setVolume(5)"
The final code, then, is this one:
< iframe width="140" height="105" src="https://www.youtube./embed/tGzl_AB4poI?rel=0&showinfo=0&autoplay=1&player.setVolume(5)" frameborder="0" allowfullscreen></iframe>
The problem is that it wont works and the Volume is still the deafault one- (but the code still works with autoplay and all other pref).
What is going wrong?
Share Improve this question edited May 15, 2016 at 23:37 Smittey 2,49010 gold badges29 silver badges35 bronze badges asked May 15, 2016 at 22:48 Francesco Di RedaFrancesco Di Reda 111 gold badge1 silver badge3 bronze badges1 Answer
Reset to default 6In IFrame API reference, you can use player.setVolume() to set the volume after the player is ready.
If you want to control the volume, you have to write some code in Javascript:
function onYouTubeIframeAPIReady() {
// iframeId parameter should match your Iframe's id attribute
var player = new YT.Player('iframeId', {
width: 140,
height: 105,
videoId: 'tGzl_AB4poI',
events: {
'onReady': function (event) {
event.target.setVolume(0);
event.target.playVideo();
}
}
});
}