YouTube API:YouTube 播放列表代码示例?

发布于 2025-01-06 04:40:27 字数 756 浏览 1 评论 0原文

我想创建一个播放列表来加载特定用户上传的所有视频。

建议我使用以下代码(假设要引入的帐户是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑,眼淚并存 2025-01-13 04:40:27

不确定查看您的代码片段,但您似乎无法识别要加载的播放器对象。对象语法为:

player.loadPlaylist({list:String,
                     listType:String,
                     index:Number,
                     startSeconds:Number,
                     suggestedQuality:String}):Void

以下是 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:

player.loadPlaylist({list:String,
                     listType:String,
                     index:Number,
                     startSeconds:Number,
                     suggestedQuality:String}):Void

Here is the YouTube link with more detail info on cueing and loading playlist:

https://developers.google.com/youtube/iframe_api_reference#Queueing_Functions

给妤﹃绝世温柔 2025-01-13 04:40:27

如果您只想嵌入视频,您可以使用:

https://www.youtube.com/embed/videoseries?list=USERID

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:

https://www.youtube.com/embed/videoseries?list=USERID

And the USERID is your youtube user id with 'UU' appended.

For example, if your user id is TlQ5niAIDsLdEHpQKQsupg then you should put UUTlQ5niAIDsLdEHpQKQsupg.
If you only have the channel id (which you can find in your channel URL) then just replace the first two characters (UC) with UU.

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.

See answer on duplicate

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文