如何自动播放HTML5< video>和<音频> iOS上的标签? [英] How to autoplay HTML5 <video> and <audio> tags on iOS ?

查看:140
本文介绍了如何自动播放HTML5< video>和<音频> iOS上的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的团队正试图在 iPad 上制作Web应用程序自动播放HTML5视频/音频标签。在使用 CSS JavaScript 进行多次尝试后,目前还没有运气。


问题是:还有什么其他选择让它自动播放?


我认为本机应用程序带有集成浏览器, iOS API 调用模拟触摸/点击,从而使视频/音频标签自动播放。



是否有可能,如果是,如何以及使用哪种iOS版本?

Thanks

解决方案

您无法在正常模式下自动播放iOS上的视频和音频,您可以使用模拟用户输入以自动播放视频和音频。

Safari HTML5音频和视频指南


在iOS上的Safari中(适用于所有设备,包括iPad),用户可能在蜂窝网络上并按数据单元收费,预加载和自动播放被禁用。直到用户启动它才会加载数据。这意味着,除非用户操作触发play()或load()方法,否则JavaScript play()和load()方法在用户启动播放之前也处于非活动状态。换句话说,用户启动的播放按钮有效,但onLoad =play()事件不起作用。


此播放电影:< input type =buttonvalue =播放onclick =document.myMovie.play()>



iOS上没有任何功能:< body onload =document.myMovie.play()>


My team and I are tying to make a web application autoplay HTML5 video/audio tags on iPad. So far no luck after many attempts with CSS and JavaScript.

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.

Is it possible and if yes, how and with which iOS version ?

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.

Safari HTML5 Audio and Video Guide

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. 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. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.

This plays the movie: <input type="button" value="Play" onclick="document.myMovie.play()">

This does nothing on iOS: <body onload="document.myMovie.play()">

这篇关于如何自动播放HTML5&lt; video&gt;和&lt;音频&gt; iOS上的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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