【问题标题】:How to put youtube video on the same site [duplicate]如何将 youtube 视频放在同一个网站上[重复]
【发布时间】:2018-04-12 13:51:53
【问题描述】:

如果您访问《守望先锋》官方网站 (https://playoverwatch.com/en-us/) 并单击“观看预告片”按钮,则 youtube 视频将出现在同一网站上,而无需将您定向到该视频所在的原始 youtube 页面从。他们是怎么做到的?

【问题讨论】:

  • Youtube 为您在页面 HTML 中插入的每个视频提供了一个嵌入标签。

标签: html css video youtube


【解决方案1】:

它被称为使用嵌入视频。你可以使用iframes

YouTube 视频 ID

当您打开视频时,YouTube 会显示一个 ID(如 vhjTYfG)。您可以使用此 ID,并在 HTML 代码中引用您的视频。

要在网页上播放您的视频,请执行以下操作:

- Upload the video to YouTube
- Take a note of the video id
- Define an <iframe> element in your web page
- Let the src attribute point to the video URL
- Use the width and height attributes to specify the dimension of the player
- Add any other parameters to the URL (see below)

这是一个示例代码,

 <iframe width="420" height="315"
src="https://www.youtube.com/embed/vhjTYfG">
</iframe> 

*在此处阅读更多信息。 w3schools

【讨论】:

    【解决方案2】:

    Vishwa 先生是对的。我只是想补充。

    请看一下这个网址 https://developers.google.com/youtube/iframe_api_reference

    playoverwatch.com 正在使用类似的技术

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-27
      • 1970-01-01
      • 2014-08-13
      • 1970-01-01
      • 2017-10-02
      • 2015-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多