How do I Autoplay an embedded YouTube video on mobile?

Support » Plugin: Elementor Website Builder » Embedded youtube video wont autoplay on mobile device

Embedded youtube video wont autoplay on mobile device

  • Resolved domkarl

    [@domkarl]


    4 months, 2 weeks ago

    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.

    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.

    // 2. This code loads the IFrame Player API code asynchronously. var tag = document.createElement['script']; tag.src = "//www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName['script'][0]; firstScriptTag.parentNode.insertBefore[tag, firstScriptTag]; // 3. This function creates an [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[]; } /* 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%; }

    Thanks in advance.

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

Viewing 1 replies [of 1 total]
  • victoros

    [@victoros]

    3 months ago

    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]
  • You must be logged in to reply to this topic.

Video liên quan

Chủ Đề