• Resolved domkarl

    (@domkarl)


    I have embedded a youtube video in my page using elementor HTML editor.
    I have edited the Embed code to autoplay, hide player controls, loop, ect as pasted below and it works perfectly except it will not autoplay on mobile.

    <iframe width=”560″ height=”700″ src=”https://www.youtube.com/embed/F6APMqSpCdk?controls=0&autoplay=1&rel=0&mute=1&loop=1&playlist=F6APMqSpCdk&#8221; title=”YouTube video player” frameborder=”0″ allow=”accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture” allowfullscreen></iframe>

    I have tried to use a work around from stack overflow as pasted below which does autorun on mobile. The problem is i cant resize the player hight (which runs to small) and i loose the ?loop=1 and &rel=0 settings from the original edited embed code above. Can any smart HTML coder help to rectify this problem.

    <!-- 1. The <iframe> (video player) will replace this <div> tag. -->
    <div class="iframe-container">
      <div id="player"></div>
    </div>
    <script>
      // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');
    
      tag.src = "https://www.youtube.com/iframe_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 onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          width: '100%',
          videoId: 'YOUR_VIDEO_ID',
          playerVars: { 'autoplay': 1, 'playsinline': 1 },
          events: {
            'onReady': onPlayerReady
          }
        });
      }
    
      // 4. The API will call this function when the video player is ready.
      function onPlayerReady(event) {
         event.target.mute();
        event.target.playVideo();
      }
    </script>
    
    <style>
    /* Make the youtube video responsive */
      .iframe-container{
        position: relative;
        width: 100%;
        padding-bottom: 56.25%;
        height: 0;
      }
      .iframe-container iframe{
        position: absolute;
        top:0;
        left: 0;
        width: 100%;
        height: 100%;
      }
    </style>

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hey, since opening your ticket we have made some updates and improvements to our Video widget.

    We are iteratively improving the widget UX based on user requests, The current behavior is as follows:

    If autoplay on load is off:

    All videos are started with sound.

    Even when trigger to play is autoplay next

    Even when trigger to play is clicking the item in the list

    Even if the user muted the previous video

    If autoplay on load is on:

    The first video is always muted

    All other videos are always with sound

    Even when trigger to play is autoplay next

    Even when trigger to play is clicking the item in the list

    Even if the user muted the previous video

    Hope this information helps, you can read more here.

Viewing 1 replies (of 1 total)
  • The topic ‘Embedded youtube video wont autoplay on mobile device’ is closed to new replies.