Video autoplay doesn't work on all iphone

一个人想着一个人 提交于 2021-02-18 19:00:28

问题


On the top of this homepage, I have a video with muted, autoplay and playsinline attributes.

The video is autoplaying on desktop & mobile I've tested (Chrome, Safari, Firefox). Surprisingly, the video is not playing for lots of iPhone users, they have a PLAY button showing, requiring interaction then.

Here is my code :

<video id="vid" width="100%" height="auto" preload="auto" autoplay muted playsinline>
  <source src="http://www.nevada-club.com/wp-content/uploads/2018/06/Nevada_Club.mp4" type="video/mp4" />
  <source src="http://www.nevada-club.com/wp-content/uploads/2018/06/Nevada_Club.webm" type="video/webm" />
  <source src="http://www.nevada-club.com/wp-content/uploads/2018/06/Nevada_Club.ogg" type="video/ogg" />
</video>

<script>
     var herovide = document.getElementById('vid');
       herovide.autoplay=true;
       herovide.load();  
</script>

Does someone knows why some people have this issue and how to fix it ? Somebody who has this issue was on iOS 11.4.

Thanks


回答1:


If iPhone is in battery save mode it will not autoplay videos. Otherwise it should play with your code.

Also i don't think you need any js to autoplay.



来源:https://stackoverflow.com/questions/51226793/video-autoplay-doesnt-work-on-all-iphone

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