问题
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?
回答1:
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>
来源:https://stackoverflow.com/questions/38978695/unmute-facebook-live-video