How does YouTube web start a video playback automatically on mobile Safari without a user's action?

StackOverflow https://stackoverflow.com/questions/15070658

Вопрос

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?

Это было полезно?

Решение

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...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top