var player1
var player2
function onYouTubeIframeAPIReady() {
player1 = new YT.Player('player1', {
height: '248',
width: '330',
videoId: '-Fa_1nhmV4s',
playerVars: {
'autoplay': '0',
'rel': '0',
'loopplaylist': '0',
'showinfo': '0',
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
},
playerVars: {
'autoplay': '0',
'rel': '0',
'loopplaylist': '0',
'showinfo': '0',
}
});
player2 = new YT.Player('player2', {
height: '248',
width: '330',
videoId: 'yzVnwzJpyaM',
playerVars: {
'autoplay': '0',
'rel': '0',
'loopplaylist': '0',
'showinfo': '0',
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
},
playerVars: {
'autoplay': '0',
'rel': '0',
'loopplaylist': '0',
'showinfo': '0',
}
});
}
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.mute();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
event.target.mute();
// if (event.data == YT.PlayerState.PLAYING && !done) {
// setTimeout(stopVideo, 6000);
// done = true;
// }
}
function stopVideo() {
player.stopVideo();
}