gpt4 book ai didi

javascript - Facebook 嵌入视频播放器 api 不会在本地 html 文件中渲染 iframe 视频输出

转载 作者:行者123 更新时间:2023-12-03 01:01:58 29 4
gpt4 key购买 nike

您好,当我复制 fb 嵌入播放器示例代码并粘贴到本地 html 文件中时,视频未呈现。当我在 w3 学校等一些在线 html 编辑器中尝试它时,它工作得很好。其背后的原因是什么? html代码如下:

<html>
<head>
<title>Your Website Title</title>
</head>
<body>

<!-- Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
xfbml : true,
version : 'v2.5'
});

// Get Embedded Video Player API Instance
var my_video_player;
FB.Event.subscribe('xfbml.ready', function(msg) {
if (msg.type === 'video') {
my_video_player = msg.instance;
}
});
};

(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<!-- Your embedded video player code -->
<div
class="fb-video"
data-href="https://www.facebook.com/facebook/videos/10153231379946729/"
data-width="500"
data-allowfullscreen="true"></div>

</body>
</html>

最佳答案

为什么不直接使用 Facebook 中的嵌入视频代码?

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

这也是我本地 html 页面截图上的相同代码: enter image description here

关于javascript - Facebook 嵌入视频播放器 api 不会在本地 html 文件中渲染 iframe 视频输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52584851/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com