我正在尝试使用facebook视频播放器api播放Facebook视频。我已经在bootstrap模式中添加了视频,而且我必须以相同的方式处理多个视频。这是我尝试过的代码。
<script>
var my_video_player;
window.fbAsyncInit = function() {
FB.init({
appId : '2xxxxxxxxxxxxxx',
xfbml : true,
version : 'v2.5'
});
// Get Embedded Video Player API Instance
FB.Event.subscribe('xfbml.ready', function(msg) {
if (msg.type === 'video' && msg.id === '<?php echo $post_id;?>') {
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 = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script>
jQuery(document).on('show.bs.modal','#myModal<?php echo $post_id;?>',
function () {
my_video_player.play();
console.log('play_vid<?php echo $post_id;?>');
}
});
</script>
但这不能正常工作。任何人都可以帮我解决我的问题吗?如何正确使用Facebook视频播放器api?