我已经按照本教程 http://www.lavacoms.com/2012/01/embedded-youtube-playlist-autoplay/
这是一个很好的教程。 我的问题是,如果我的页面上嵌入了一个播放列表,但我希望第一个视频被说出播放列表的第二个或第三个视频,甚至是sith视频,我该怎么办?
谢谢
<iframe src="http://www.youtube.com/embed/VIDEO_ID?list=PLAYLISTURL&autoplay=1&modestbranding=1&fs=2" frameborder="0" width="640" height="385"></iframe>
它说VIDEO_ID把你想播放的视频ID放在播放列表中的第一个。 它说播放列表网址的地方放了网址的ID。
在 http://911-need-code-help.blogspot.com/2012/07/youtube-iframe-embeds-video-playlist-and-html5.html 上找到
希望它能帮助别人
考虑到 php 上的VIDEO_ID数组 ( $filas
),您可以添加如下:
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
}
});
}
请务必捕获错误,以防万一无法播放视频