andrewvasilchuk / vue-lazy-youtube-video

Vue.js component for lazyloading YouTube videos.
MIT License
102 stars 21 forks source link

autoplay not working on mobile #15

Open caweidmann opened 4 years ago

caweidmann commented 4 years ago

Hi there

I'm trying to get autoplay to work on mobile, but haven't been successful. I've tried the following three approaches:

<YouTubeVideo
  :src="`https://www.youtube.com/embed/${video.id}`"
/>

<YouTubeVideo
  :iframeAttributes="{autoplay:true}"
  :src="`https://www.youtube.com/embed/${video.id}`"
/>

<YouTubeVideo
  :iframeAttributes="{autoplay:'autoplay'}"
  :src="`https://www.youtube.com/embed/${video.id}`"
/>

If you open the demo page on a phone you can replicate the issue.

Before tap:

before

After tap:

after

And then I have to tap again to get it playing. Not sure if this is something that can be solved by this plugin?

andrewvasilchuk commented 4 years ago

@caweidmann, Thanks for creating the issue.

On mobile a video should be muted (pass &mute=1 via URL).

This SO question will definitely help you, since library allows you to pass any URL query params, as well as iframeAttributes.

To create YT.Player instance refer to #20.