简体   繁体   English

如何自动播放HTML5 <video> 和 <audio> iOS上的标签?

[英]How to autoplay HTML5 <video> and <audio> tags on iOS ?

My team and I are tying to make a web application autoplay HTML5 video/audio tags on iPad . 我和我的团队都想使Web应用程序在iPad上自动播放HTML5视频/音频标签。 So far no luck after many attempts with CSS and JavaScript . 到目前为止,在使用CSSJavaScript进行了许多尝试之后,仍然没有运气。

The question is: What other option is there to make it autoplay ? 问题是: 还有什么其他选项可以使其自动播放?

I'm thinking native app with integrated browser with iOS API calls to simulate a touch/click and thus making the video/audio tags autoplay. 我正在考虑将本机应用程序与集成浏览器一起使用iOS API调用来模拟触摸/点击 ,从而使视频/音频标签自动播放。

Is it possible and if yes, how and with which iOS version ? 是否可以,如果可以,如何以及使用哪个iOS版本?

Thanks 谢谢

you can't auto-play videos and audios on iOS in normal mode, you may use trick like simulate user input to auto-play videos and audios. 您无法在正常模式下在iOS上自动播放视频和音频,可以使用诸如模拟用户输入之类的技巧来自动播放视频和音频。

Safari HTML5 Audio and Video Guide Safari HTML5音频和视频指南

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. 在iOS上的Safari(适用于包括iPad在内的所有设备)上的Safari中,用户可能位于蜂窝网络上,并按数据单元收费,因此禁用了预加载和自动播放功能。 No data is loaded until the user initiates it. 在用户启动数据之前,不会加载任何数据。 This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. 这意味着除非用户操作触发了play()或load()方法,否则JavaScript play()和load()方法在用户启动播放之前也处于无效状态。 In other words, a user-initiated Play button works, but an onLoad="play()" event does not. 换句话说,用户启动的“播放”按钮有效,但onLoad =“ play()”事件无效。

This plays the movie: <input type="button" value="Play" onclick="document.myMovie.play()"> 这将播放电影: <input type="button" value="Play" onclick="document.myMovie.play()">

This does nothing on iOS: <body onload="document.myMovie.play()"> 这在iOS上不起作用: <body onload="document.myMovie.play()">

Have you found solution for autoplay video on iOS device? 您是否找到了在iOS设备上自动播放视频的解决方案? If not, I've just find a solution here, you can use WeChat of iPhone to open it (just support WeChat of iPhone but not support iPad WeChat), it use video.js player, related code as below: 如果没有,我只是在这里找到一个解决方案,您可以使用iPhone的微信打开它 (仅支持iPhone的微信而不支持iPad的微信),它使用video.js播放器,相关代码如下:

<video id="example_video_1" class="video-js vjs-default-skin" controls autoplay preload="auto" webkit-playsinline="true" x-webkit-airplay="true" width="750" height="460" poster="" data-setup="{}">

It also has solution for support video play without full screen on iOS/Android/PC. 它还提供了在iOS / Android / PC上支持视频播放而无需全屏显示的解决方案。

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

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