2
I have several Youtube videos on one page, would like it when I give play in one, if another video was rolling, pause it. Is it possible? Without reloading the page...
2
I have several Youtube videos on one page, would like it when I give play in one, if another video was rolling, pause it. Is it possible? Without reloading the page...
3
To do this you need access to Youtube player events.
function onYouTubePlayerReady(playerId) {
var ytplayer = document.getElementById("MyYouTubePlayer");
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}
function onytplayerStateChange(newState) {
switch (newState) {
case 0:
// Encerrado
break;
case -1:
// Não iniciado
break;
case 1:
// Em reprodução
break;
case 2:
// Pausado
break;
case 3:
// Armazenando em buffer
break;
case 5:
// Vídeo iniciado
break;
}
}
Browser other questions tagged javascript html youtube
You are not signed in. Login or sign up in order to post.