Desactivar la reproducción automática en la API de YouTube javascript
Sé sobre el uso de reproducción automática: 0 en params y en url. El problema es cuando uso la función loadVideoByID (). El video inicial parece no siempre iniciarse automáticamente. Pero en el momento en que cargué un nuevo video que se inicia automáticamente. No quiero que el nuevo arranque automáticamente
$(document).ready(function() {
var player;
window.onYouTubePlayerAPIReady = function() {
player = new YT.Player('player', {
height : '390',
width : '640',
videoId : 'JW5meKfy3fY',
playerVars : {
'autoplay' : 0,
'rel' : 0,
'showinfo' : 0,
'egm' : 0,
'showsearch' : 0,
'controls' : 0,
'modestbranding' : 1,
},
events : {
'onReady' : onPlayerReady,
'onStateChange' : onPlayerStateChange
}
});
};
window.onPlayerReady = function(event) {
//event.target.playVideo();
loadNewVid("bHQqvYy5KYo");
};
window.onPlayerStateChange = function(event, element) {
//When the video has ended
if (event.data == YT.PlayerState.ENDED) {
//Get rid of the player
element.style.display = "none";
}
};
function loadNewVid(vidID){
player.loadVideoById(vidID, "large");
}
});