Search code examples
facebookjquery-mobilehtml5-videofacebook-javascript-sdk

How is Facebook able to autoplay videos on mobile browsers


I realize that many questions have been asked about autoplay videos on mobile devices but before my question is marked as a duplicate, I must say that I looked through a lot of those questions and answers and I have not found a satisfactory answer.

Mostly, all of the answers say that it's not possible to autoplay videos on mobile browsers.

My question: How can Facebook autoplay videos on mobile browsers?


Solution

  • Videos can only be started by user interaction. This is usually clicking a button but you can also use any of the touch events (https://developer.mozilla.org/en-US/docs/Web/API/Touch_events).

    To replicate the functionality, you can use touchmove to detect the user scrolling through the page and use it to trigger a play when the video is visible.