Unmute facebook live video

≯℡__Kan透↙ 提交于 2019-12-11 02:20:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!