视频自动播放不适用于所有iPhone [英] Video autoplay doesn't work on all iphone

查看:58
本文介绍了视频自动播放不适用于所有iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此首页的顶部,我有一个具有静音,自动播放和playinline属性的视频

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

视频正在台式机上自动播放;我测试过的移动设备(Chrome,Safari,Firefox).令人惊讶的是,很多iPhone用户都无法播放视频,他们显示了PLAY按钮,然后需要进行交互.

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.

这是我的代码:

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

有人知道为什么有人会有这个问题以及如何解决吗?遇到此问题的人是在iOS 11.4上.

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

谢谢

推荐答案

如果iPhone处于省电模式,它将不会自动播放视频.否则,它将与您的代码一起播放.

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

我也不认为您需要任何js来自动播放.

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

这篇关于视频自动播放不适用于所有iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆