如何嵌入Facebook视频?

时间:2015-10-14 20:36:09

标签: html5 facebook facebook-graph-api

我想知道如何嵌入Facebook视频?

我按照以下说明操作:

https://developers.facebook.com/docs/plugins/embedded-video-player

但它不起作用。这是源代码:

<html>
  <head>
    <title>My Website</title>
  </head>
  <body>
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    <h1>My Video Player</h1>
    <div class="fb-video"
    data-href="https://www.facebook.com/FacebookDevelopers/posts/10151471074398553"
    data-width="500"
    data-allowfullscreen="true"></div>
  </body>
</html>

提前致谢

4 个答案:

答案 0 :(得分:4)

我知道这是一个老帖子。但这个代码就是答案。有关详细信息look here.

<!-- replace {facebook-video-url} with the correct url-->
<iframe 
  src="https://www.facebook.com/plugins/video.php?href={facebook-video-url}&show_text=0&width=560"
  width="560" height="315" 
  style="border:none;overflow:hidden" 
  scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"
></iframe>
<!--example given-->
<iframe 
  src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FPlayStation%2Fvideos%2F10155554431506803%2F&show_text=0&width=560"
  width="560" height="315" 
  style="border:none;overflow:hidden" 
  scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"
></iframe>

答案 1 :(得分:1)

按下接收代码后,点击Iframe的标签。这对我来说效果更好

它看起来像这样:

<iframe src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F10153231379946729%2F&width=500&show_text=false&height=281&appId" 
        width="500" height="281" 
        style="border:none;overflow:hidden" 
        scrolling="no" frameborder="0" allowTransparency="true"
></iframe>

答案 2 :(得分:0)

<iframe 
  src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FPlayStation%2Fvideos%2F10155554431506803%2F&show_text=0&width=560"                                                           
  width="560" height="315" 
  style="border:none;overflow:hidden" 
  scrolling="no" allowTransparency="true" allowFullScreen="true"
></iframe>

这适合我。

答案 3 :(得分:-2)

如果您使用iframe,则可以插入视频,只需要链接

<iframe width="420" height="315"src="http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1"></iframe>

在src标签上只放了你想要的视频链接......

查看完整教程的下面链接

http://www.w3schools.com/html/html_youtube.asp