autoplay html5 video with external link on mobiles

人走茶凉 提交于 2019-12-11 19:47:38

问题


I have created a web page that auto plays a full screen background video.

On top of the video is a div that contains text & a link to an external site - this works fine in all desktop browsers.

How do i recreate the same setup to play on mobile devices - would I need to use javascript in order to achieve this?

I have spent many hours trawling google for a definitive answer and am now very confused.

Thanks in advance.


回答1:


Autoplay for HTML5 video is not allowed on mobile devices such as iOS or Android. You can read this for the whys and hows on iOS.

On iPhone the video plays in the default (fullscreen) Quicktime player. So there is no real background notion (this could be accomplished in a native app where inline playback of video is allowed but not in the Safari/web browser). You would need to stick to an image I guess.

On the iPad or on Android in order to accomplish what you want you will need to bind your video tag to a touch event/button (like when a user 'touch' to enter your site), and on this event initiate the play sequence for the video (in your case the video being set to occupy the full width and height of the viewport).

Thanks



来源:https://stackoverflow.com/questions/22614988/autoplay-html5-video-with-external-link-on-mobiles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!