-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The double-tap / mobile issue. Autoplay doesn't consistently work #6
Comments
Interesting. I've seen this sometimes on Android Chrome but not consistently.
AFAIK, it's due to the user gesture requirement. In our case, a user gesture triggers the creation of an iframe, with loads an HTML document, which has a This requires some debugging to figure out if our behavior or impl can be improved. Update Nov 2021. I've done a bit more research...
|
Just my 2 cents here :) Videos won't autoplay on IOS and IpadOS if the video has sound. So autoplay will most probably only work if the video is muted. Maybe it's possible to do a hack which will start the video, and when the video is playing unmute the sounds |
I've been testing on a Pixel 3 (Android 9.0, Chrome) and consistently have this issue too |
I made a similar plugin for WordPress five years ago and had the same issue. I'm interested to know if there's a solution for this. |
The moment you add some delay between the tap and the In cases like this, the delay is caused by the deferred loading of the iframe. The only way to fix it, is to load the iframe as soon as possible instead of after the tap; this way the time between tap and |
Use |
One way we could possibly handle this is use an IntersectionObserver on the videos. When they're within some delta, pop the iframe in. This means videos that are initially above the fold (or very close) will load in right away waiting for the gesture. But any other still lazily load so on sites displaying many videos it would immediately saturate network operations trying to initialize all the iframes. Slightly wasteful since if a user never starts the video, the network space goes unused. But that's the trade-off on mobile where gesture interaction is enforced in areas like this. |
Same issue using Kiwi Browser on Android (which is a fork of Android Chromium) |
It also happens with me in Firefox, but on Desktop PC.
This video from examples requires two clicks to play as well, for example: upd removing params="autoplay=0" makes video play after a single click, but it injects two iframes instead of one and they both play. |
It would be great if the browser would allow videos to autoplay in an |
Is there any solution to this? Loading heavy youtube embeds like this is best practices. Google Pagespeed even links to Dev which links directly to your solution for reducing page speed, but its strange that on mobile there seems to be no way around requiring 2 clicks |
As I said before, the best work-around is to use an intersection observer. If the node is in view or reasonably near it, go ahead and swap in the iframe. That can be done by calling This detail is a mobile browser pattern aimed at improving user interactions on the web. It is unlikely to change in that space and work-arounds on the front to prevent a double tap in this scenario are likely to be patched. If Paul decides that the component should do the observer internally, then in the upgrade notes it will be called out that if you're doing this then you can stop. |
@Garbee If using an intersection observer to replace the facade with an |
The difference with the loading attribute is, browser support: https://caniuse.com/loading-lazy-attr . Also possibly other side effects, not sure how positioning is handled with those. Could possibly cause layout recalc in the right conditions. I'd need to do some testing on that to verify. |
can anyone confirm adding |
Adding |
Hello! |
Hello @paulirish, I just created this pull request that fix the double tap issue on Mobile among other things. Looking forward to your feedback 👍 |
I've updated an earlier comment of mine with some additional research: #6 (comment) also i retitled this issue, so it's more canonical. and i've put up a PR that may hopefully address this: #109 |
Thanks for the YT API merge. It’s now working with one click/tap on almost all browsers except ipadOS Safari (and most likely iOS, but I don’t have an iPhone to test). Tested and worked well on Firefox Desktop, Chrome Desktop, Safari Desktop and Chrome mobile. |
Any plan on creating a new tag/release, so it's easier for people to use the updated version through a cdn? |
Hello! Testing the demo page on Instagram in-app browser it needs double-tap. On Facebook in-app browser works fine. Tested on Android device. |
Hello! I have the same problem. Did you find a solution? |
Bumping this one. I'm seeing the same thing as discussed in #149: works great on desktop PC, desktop Mac, and mobile Android -- but not mobile iOS, which requires double-tap to play. Issue seems to be device/OS-level as all browsers on each device behave identically. It looks like there have been commits in the past that have apparently solved this, but as the issue is still present I'm guessing Apple did some update in the interim that made this a problem again. A fix is outside my wheelhouse, but any chance we can get smarter folks than I to take another look at this? Thanks! |
The text was updated successfully, but these errors were encountered: