简体   繁体   English

如何在移动设备上自动播放HTML5视频

[英]How to Autoplay an HTML5 video on Mobile

I'm working on a fairly simple mobile App, geared more towards people who may have trouble with technology. 我正在开发一个相当简单的移动应用程序,更多地面向可能在技术方面遇到麻烦的人。 As such, it needs to be as easy to use as possible and I need to be able to play HTML5 audio/video files on start. 因此,它必须尽可能易于使用,并且我需要能够在开始时播放HTML5音频/视频文件。 The problem, as many of you may know, is that mobile devices tend to turn off Autoplay of video content for bandwidth purposes. 你们中许多人可能知道,问题是移动设备倾向于出于带宽目的而关闭视频内容的自动播放。 I'm told there are ways around it using some mild scripting, but all the resources I've found seem to either be outdated, or unsuited to my needs. 有人告诉我,可以使用一些温和的脚本来解决它,但是我发现的所有资源似乎都已经过时,或者不适合我的需求。 The development tool I'm using allows me to plug in HTML5 code, but I need to be able to plug in a video that will run without user input. 我使用的开发工具允许我插入HTML5代码,但是我需要能够插入无需用户输入即可运行的视频。 It should also be noted that these video's must be hosted online somewhere (ie, It cant have the video load from inside the app). 还应注意,这些视频必须在线托管在某个地方(即,不能从应用程序内部加载视频)。

Any Help you could give me on this issue would be greatly appreciated. 您可以在这个问题上给我的任何帮助将不胜感激。

You didn't specify OS or device or browser. 您未指定操作系统,设备或浏览器。 It's been a long time and you probably don't care anymore but if anyone else comes past this, my answer. 已经有很长时间了,您可能已经不在乎了,但是如果其他任何人都过去了,我的回答是。

Try placing "playsinline" inside the video tag. 尝试将“ playsinline”放置在视频代码中。

Eg. 例如。 <video playsinline> </video>

I can confirm this works in iOS 10. 我可以确认这可以在iOS 10中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM