2

I read in billions of foruns and posts on the stackoverflow, and nothing. When I found a solution or something like that, not work anymore.

I tried with Google API and nothing too.

I can autoplay video in the IOS native player, putting de direct mp4 link on tag ''

But in Android, I try with iframe, video tag, direct mp4 link, nothing works.

There's no way to do this works on the Android platform?

rist
  • 578
  • 2
  • 9
Luã Melo
  • 113
  • 3
  • 10

3 Answers3

2
 <div id="player"></div>
<script>
       var tag = document.createElement('script');
       tag.src = "https://www.youtube.com/player_api";
       var firstScriptTag = document.getElementsByTagName('script')[0];
       firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
       var player;
       function onYouTubePlayerAPIReady() {
            player = new YT.Player('player', {
                  height: '480',
                  width: '853',
                  videoId: 'YOUR ID',
                  events: {
                       'onReady': onPlayerReady,
                       'onStateChange': onPlayerStateChange
                  },
                  playerVars: {
                        'autoplay': 1,
                        'showinfo': 0,
                        'controls': 0
                                }
                            });
                        }
                        function onPlayerReady(event) {
                            event.target.playVideo();
                        }

                        var done = false;
                        function onPlayerStateChange(event) {
                            if (event.data == YT.PlayerState.PLAYING && !done) {
                                done = true;
                            }
                        }
                        function stopVideo() {
                            player.stopVideo();
                        }
                    </script> 
Qui Nguyen
  • 21
  • 3
0

When you use the Player in a browser that has Flash disabled, playback is handled via HTML5 tags.

Apple explicitly prohibits autoplaying media in tags in iOS Safari.

This is also the case for at least recent versions the default Android Browser or in Chrome. I'd strongly suspect that Android Firefox has the same restriction.

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
-3
   <iframe src='http://www.youtube.com/embed/bhRqrw82P3A?autoplay=1&modestbranding=1&showinfo=0&fs=0' width='300' height='175' frameborder='0' >
    </iframe>
codercat
  • 22,873
  • 9
  • 61
  • 85