Autoplay youtube video on mobile

Asked

Viewed 505 times

0

I wonder how I can put the youtube video in autoplay on mobile, because it is not working, on mobile it is not in autoplay, do not run the video without having to press.

My Script.

   <script>      
          // 2. This code loads the IFrame Player API code asynchronously.
          var tag = document.createElement('script');
          tag.src = "http://www.youtube.com/player_api";
          var firstScriptTag = document.getElementsByTagName('script')[0];
          firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

          // 3. This function creates an <iframe> (and YouTube player)
          //    after the API code downloads.
          var player;
          function onYouTubePlayerAPIReady() {
            player = new YT.Player('player', {
              playerVars: { 'modestbranding':0,'autoplay': 1, 'controls': 0,'autohide':2,'wmode':'opaque','showinfo':0,'rel':0,'loop':0,'disablekb':1,'playlist':1,'playerapiid':0,'enablejsapi':1,'list':1,'listType':1, 'iv_load_policy':3 }, 
              videoId: 'RC0Wrd12sno',
              events: {
                'onReady': onPlayerReady
                }


            });


          }


          // 4. The API will call this function when the video player is ready.
          function onPlayerReady(event) {
            event.target.mute(true);
             event.target.loadPlaylist(['RC0Wrd12sno']);
             event.target.setLoop(true); 
          }


</script>
  • What have you been trying to do? Show your code.

  • so, it works perfect on the web but does not work on mobile, I could not find anything to put autoplay when it is mobile

  • I didn’t use the google API on a system I made, I used iframe see:http://answall.com/questions/80969/refused-to-display-in-a-frame-because-it-set-x-frame-options-to-sameorigin.

  • I’ve tried to use only iframe, but can’t let the video mute without using the api, which is what I did up there, but he doesn’t want to have autoplay on his cell phone.

  • you have already looked on the console if there are any mistakes?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.