KEE*_*EES 13 youtube youtube-api
我正在尝试使用此JavaScript API播放youtube播放列表,用于今年1月推出的iframe嵌入. http://apiblog.youtube.com/2011/01/introducing-javascript-player-api-for.html
请注意下面的iframe标记和带有"/ p"的链接以表示其播放列表.
<iframe src="http://www.youtube.com/embed/p/ID" width="100%" height="500" frameborder="0"></iframe>
Run Code Online (Sandbox Code Playgroud)
但是,即使在http://code.google.com/apis/youtube/iframe_api_reference.html上的文档中,我也无法找到如何使用onYouTubePlayerAPIReady()通话播放播放列表.
jbx*_*jbx 37
由于此处未提供使用播放列表ID的播放列表的正确答案(即不对视频列表进行硬编码),如果您仍希望使用Javascript Youtube IFrame API,则可以使用此方法.如果播放列表ID在playerVars中指定,则可以省略videoID,如下所示:
function onYouTubePlayerAPIReady()
{
player = new YT.Player('player',
{
height: '390',
width: '640',
playerVars:
{
listType:'playlist',
list: '<YOURPLAYLISTID>'
}
});
}
Run Code Online (Sandbox Code Playgroud)
希望它有助于谁在寻找它(就像我一样).
小智 14
我找到了答案.
只需将'播放列表'添加到您的playerVars和播放列表String | Array.
playerVars:{'autoplay':0,'controls':1, '播放列表':['your_video_id','...'] },
像下面的例子:
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'your_video_id',
playerVars: { 'autoplay': 0, 'controls': 1, 'playlist':['your_video_id', '...']},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25843 次 |
| 最近记录: |