I have followed this tutorial http://www.lavacoms.com/2012/01/embedded-youtube-playlist-autoplay/
it is an excellent tutorial. my question is if I have a playlist embedded on my page but I would like the first video to be let say the second or the third video or even the sisth video of the play list what do I have to do?
Thank you
<iframe src="http://www.youtube.com/embed/VIDEO_ID?list=PLAYLISTURL&autoplay=1&modestbranding=1&fs=2" frameborder="0" width="640" height="385"></iframe>
where it said VIDEO_ID put the video Id that you want to play first from your play list. where it said PLAYLISTURL put the ID of the url.
found on http://911-need-code-help.blogspot.com/2012/07/youtube-iframe-embeds-video-playlist-and-html5.html
hope it helps someone else
Considering an array ($filas
) of VIDEO_ID on php, you can add like follows:
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
videoId: '<?php echo $filas[0]["trailer"]; ?>',
playerVars: { 'autoplay': 1, 'controls': 1, 'enablejsapi': 1, 'frameborder': 0,
'playlist': '<?php for ( $i=1; $i < count($filas); $i++) { if($i == count($filas) -1) echo $filas[$i]["trailer"]; else echo $filas[$i]["trailer"].", "; } ?>' },
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'onError': onError
}
});
}
Please be sure to catch error just in case a video cannot be played