取消静音Facebook直播视频 [英] Unmute facebook live video
问题描述
我目前正在尝试嵌入一个将自动播放的音频未静音的Facebook直播视频。我试图使用解决方案在这篇文章中,由于xfbml.ready事件似乎没有被调用,所以在实时视频中似乎不起作用。有没有人想出了一种在实况嵌入式视频中启用音频的方法?
诀窍是,你不应该使用自动播放然后取消静音,而是通常嵌入视频,然后通过 msg.instance.play()
。
查看下面的代码,或尝试此链接: http://shoepimper.com/fb.html
< script>
window.fbAsyncInit = function(){
FB.init({
appId:'{your-app-id}',
xfbml:true,
version :'v2.5'
});
//获取嵌入式视频播放器API实例
FB.Event.subscribe('xfbml.ready',function(msg){
if(msg.type ===' video'){
msg.instance.play();
}
});
};
(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>
<! - 您的嵌入式视频播放器代码 - >
< div
class =fb-video
data-href =https://www.facebook.com/GoSportsLive/videos/vb.1481996068797424/1779032592427102/
data-width =500
data-allowfullscreen =true>< / div>
I am currently trying to embed a facebook live video that will auto play with the audio unmuted. I've tried to use the solution in this post however it does not seem to work on live videos as the xfbml.ready event does not seem to get called.
Has anybody figured out a way to enable the audio on a live embedded video?
The trick is, that you shouldn't use autoplay and then unmute, rather normally embed the video, then start it by msg.instance.play()
.
See the code below, or try this link: http://shoepimper.com/fb.html
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
xfbml : true,
version : 'v2.5'
});
// Get Embedded Video Player API Instance
FB.Event.subscribe('xfbml.ready', function(msg) {
if (msg.type === 'video') {
msg.instance.play();
}
});
};
(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>
<!-- Your embedded video player code -->
<div
class="fb-video"
data-href="https://www.facebook.com/GoSportsLive/videos/vb.1481996068797424/1779032592427102/"
data-width="500"
data-allowfullscreen="true"></div>
这篇关于取消静音Facebook直播视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!