Question

YouTube web version can always play a video automatically on mobile Safari without a user's explicit action to the HTML video element. How does YouTube do this?

Était-ce utile?

La solution

YouTube's actually done something quite tricky, if you click a video related to the current one or in the search, it doesn't actually load another page, it uses JavaScript to update the page to look like a different one, and then uses that same click handler to start the video, so the system thinks that it was user initiated. That's why if you enter the URL for a video straight into the address bar when not in YouTube it doesn't auto-start...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top