【发布时间】:2017-08-08 08:44:55
【问题描述】:
我想使用 YouTube API 从this tutorial 构建一个自定义 youtube 播放列表,但我在某个点卡住了。 我基本上嵌入了 client.js 脚本并在加载时执行它的功能,然后我还嵌入了 YouTubePlayList.js 文件,如教程中所述。 这是我正在尝试做的事情。我确实在控制台中收到了 YouTubePlayList 对象,但它似乎没有提供任何适当的数据。我需要一个工作脚本示例或有关如何实现它的指导,并在我的客户端中呈现播放列表。在此先感谢,任何帮助表示赞赏!
JS:
<pre>
function YouTubePlayList (id, entries) {
this.id = id;
this.entries = entries;
this.currently_playing = 0;
this.randomizer = false;
}
var requestOptions = {
playlistId: 'PLLzJfby7cTLTbusOgXca-yIpVOImC1mWe',
part: 'contentDetails, snippet',
execute: function(response) {
var entries = [];
$.each(response.items, function(key, val){
var entry = {};
entry.video_id = val.snippet.resourceId.videoId;
entry.image_src = val.snippet.thumbnails.medium.url;
entry.title = val.snippet.title;
entry.note = val.contentDetails.note;
entries.push(entry);
});
}
};
window['PLLzJfby7cTLTbusOgXca-yIpVOImC1mWe'] = new YouTubePlayList('PLLzJfby7cTLTbusOgXca-yIpVOImC1mWe', 1);
console.log(window['PLLzJfby7cTLTbusOgXca-yIpVOImC1mWe']);
</pre>
【问题讨论】:
标签: javascript jquery youtube-api