【问题标题】:I want to embed youtube video and also show gallery/playlist [closed]我想嵌入 youtube 视频并显示画廊/播放列表 [关闭]
【发布时间】:2017-09-08 18:32:29
【问题描述】:

我想在画廊中展示我们 youtube 频道中的所有视频。我正在使用<iframe>,但它只显示一个视频。如何显示我们频道中的所有视频?

<div>
<iframe src="https://www.youtube.com/embed/Wyq6YeoM2ZA?ecver=2" width="640" height="360" frameborder="5" style="position:absolute;width:70%;height:60%;left:15%" allowfullscreen playlist></iframe>
</div>

【问题讨论】:

  • 是否有使用 iframe HTML 标签的特定原因?您可能想在这里了解为什么它被认为不好:stackoverflow.com/questions/23178505/…
  • 欢迎来到 StackOverflow。请花点时间阅读指南。

标签: javascript web youtube youtube-api youtube-iframe-api


【解决方案1】:

您可以在 Youtube API 中观看。它在几种编程语言中都有很好的记录。这是javascript中的sn-p:

// Sample js code for playlists.list

// See full sample for buildApiRequest() code, which is not 
// specific to a particular youtube or youtube method.

buildApiRequest('GET',
                '/youtube/v3/playlists',
                {'channelId': 'UC_x5XG1OV2P6uZZ5FSM9Ttw',
                 'maxResults': '25',
                 'part': 'snippet,contentDetails'});

更多关于https://developers.google.com/youtube/v3/docs/playlists/list

【讨论】:

  • 我阅读了文件,它很复杂,因为我已经提到我正在学习,所以我想现在对我来说有点难。有没有其他方法可以完成?
【解决方案2】:

此 HTML 将嵌入一个播放器,该播放器将显示您的所有视频。将 YOURCHANNELNAME 替换为您的频道名称。

<iframe src="http://www.youtube.com/embed/?listType=user_uploads&list=YOURCHANNELNAME" width="480" height="400"></iframe>             

【讨论】:

猜你喜欢
  • 2013-04-13
  • 2016-03-14
  • 2013-01-25
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
  • 2015-02-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多