Autoplay video Youtube does not work

1

I have a YouTube video that does not work if I enter from a cell phone. Is this the code I have, does anyone know what's wrong?

<iframe width="891" height="501" src="https://www.youtube.com/embed/b7dmg3jxZ88?feature=oembed&amp;showinfo=0&amp;autoplay=1&amp;controls=0&amp;mute=1&amp;loop=1&amp;playlist=b7dmg3jxZ88" allowfullscreen=""></iframe>
    
asked by Luis Hernandez 11.09.2018 в 05:18
source

1 answer

1

The problem you're having is that since April 2018, Google changed the policy regarding the autoplay of their YouTube videos.

The case is explained in detail in the article entitled: Autoplay Policy Changes by François Beaufort , which explains, among other things, the following:

  

The policy of automatic reproduction released in [the version] M66 stable    effectively blocks approximately   half of unwanted audio and video media plays in Chrome. For Web   Audio API, the automatic playback policy will start in [the version] M70.   This affects web games, some WebRTC applications and others   web pages that use audio functions. The developers   You must update your code to take advantage of this new policy. You can   find more details in the Web Audio API section ...

     

... Chrome's autoplay policies will change in   April 2018 and I'm here to tell you why and how this will affect   playing video with sound ...

     

New behaviors

     

As you may have noticed, web browsers are adopting policies of   automatic reproduction to improve the experience of the   user, minimize the incentives to install blockers   announcements and reduce the consumption of data in expensive networks and / or   restricted. These changes are intended to give greater control of   the reproduction to the users and benefit the editors in cases   of legitimate use.

     

Chrome's automatic playback policies are simple:

     
  • Mute autoplay is always allowed.
  •   
  • Autoplay with sound is allowed if:

         
  •   

Routes of solution

After reading the above, we can conclude that a safe solution to activate the auto-play is indicating that the sound will be muted, simply adding mute=1 in src :

(SO may block the auto-play here, try it on your domain, it works for me):

<iframe id="yt-frame"
        width="891" height="501"
        src="https://www.youtube.com/embed/b7dmg3jxZ88?autoplay=1&mute=1&enablejsapi=1">
</iframe>

If you want an automatic reproduction with sound, keep in mind that it will only be effective in the cases indicated above.

Any other option that does not pass through the activated mute will be relative, because it will depend on the behavior of the client.

Another option that could be more feasible would be to do it through the Youtube API.

    
answered by 11.09.2018 / 06:37
source