Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to enable sound when autoplay is set in facebook embedded video?

I embedded a video from facebook in my website and i set it in autoplay, but the sound is muted unless you click the volume and it will play the sound.

like image 884
enjames Avatar asked Sep 15 '15 11:09

enjames


People also ask

Why do my Facebook videos have no sound?

Scroll down and tap Settings & Privacy then tap Settings. Scroll down to Preferences and tap Media. Below Autoplay, tap or next to Videos Start With Sound to turn automatic sound on or off.

What does it mean to embed a video on Facebook?

To share things from Facebook on your website, you can embed a Public post or video. When you embed a post that contains a video, the message that was posted with the video will be included. When you embed a video, only the video player will be included.

How do I enable embed on Facebook?

Upload video to Creator Studio. Select Allow embedding under the Publishing Options tab.


2 Answers

Just add &mute=0 to the iframe url.

<iframe src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2F.....&height=280&mute=0" width="500" height="280" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"></iframe>
like image 160
Ludovico Grossi Avatar answered Nov 07 '22 10:11

Ludovico Grossi


You can actually use Facebook Embedded Video Player API to control your embedded video in your website, such as unmuting it on page load.

Take note that this doesn't work on embedding videos thru <iframe> tag. Use the <div> tag as mentioned in the link (or see sample below).

Here's a sample script I got from the link, with insertion of my_video_player.unmute() on xfbml.ready event. Make sure you provide the proper FB appId.

<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;
          my_video_player.unmute();
        }
      });
    };

    (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/facebook/videos/10153231379946729/" 
    data-width="500" 
    data-autoplay="true"
    data-allowfullscreen="true"></div>

</body>
</html>
like image 41
Julius Delfino Avatar answered Nov 07 '22 10:11

Julius Delfino