YouTube API:YouTube 播放列表代码示例?
我想创建一个播放列表来加载特定用户上传的所有视频。
建议我使用以下代码(假设要引入的帐户是 YouTube):
loadPlaylist( { listType: 'user_uploads', list: 'youtube' } );
我也查看了 API 页面:http://code.google.com/apis/youtube/js_api_reference.html
但我找不到使用加载播放列表的实际示例代码。作为 YouTube API 的新手,我不知道需要什么类型的包装器代码才能使上述工作正常进行。像这样的东西(当然我缺少部分):
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
loadPlaylist( { listType: 'user_uploads', list: 'youtube' } );
</script>
或者如果有人可以提供原始 loadplaylist 行的工作示例,那就太好了,我可以从那里自己处理我需要的其他细节。
I'd like to create a playlist that loads all the videos a specific user has uploaded.
I was suggested to use the following code (assuming the account to pull in is YouTube):
loadPlaylist( { listType: 'user_uploads', list: 'youtube' } );
I have looked over the API pages as well: http://code.google.com/apis/youtube/js_api_reference.html
But I can't find an actual example code that uses load playlist. Being completely new to YouTube API I have no idea what type of wrapper code I need to make the above work. Something like this (of course I'm missing parts):
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
loadPlaylist( { listType: 'user_uploads', list: 'youtube' } );
</script>
Or if someone could provide working example with the original loadplaylist line that would be great, and I can work on the other details I need on my own from there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定查看您的代码片段,但您似乎无法识别要加载的播放器对象。对象语法为:
以下是 YouTube 链接,其中包含有关提示和加载播放列表的更多详细信息:
https: //developers.google.com/youtube/iframe_api_reference#Queueing_Functions
Not sure looking at your snippet, but it appears you don't identify the player object to load. The object syntax is:
Here is the YouTube link with more detail info on cueing and loading playlist:
https://developers.google.com/youtube/iframe_api_reference#Queueing_Functions
如果您只想嵌入视频,您可以使用:
USERID 是您的 YouTube 用户 ID,并附加“UU”。
例如,如果您的用户 ID 是
TlQ5niAIDsLdEHpQKQsupg
,那么您应该输入UUTlQ5niAIDsLdEHpQKQsupg
。如果您只有频道 ID(可以在频道 URL 中找到),则只需将前两个字符 (
UC
) 替换为UU
。所以最后你会得到一个像这样的 URL:
<代码>
https://www.youtube.com/embed/videoseries?list=UCTlQ5niAIDsLdEHpQKQsupg
顺便说一句
。您可以附加
&index=2
来指定应播放哪个视频。If you just want to embed the videos, you could use:
And the USERID is your youtube user id with 'UU' appended.
For example, if your user id is
TlQ5niAIDsLdEHpQKQsupg
then you should putUUTlQ5niAIDsLdEHpQKQsupg
.If you only have the channel id (which you can find in your channel URL) then just replace the first two characters (
UC
) withUU
.So in the end you would have an URL like this:
https://www.youtube.com/embed/videoseries?list=UCTlQ5niAIDsLdEHpQKQsupg
BTW. you can append
&index=2
to specify which video should be played.