在iOS5中自动播放HTML5音频/视频 [英] Autoplay HTML5 audio/video in iOS5

查看:201
本文介绍了在iOS5中自动播放HTML5音频/视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有音效的HTML5网络应用程序。我试图让这些效果在iOS5中运行,而且不能用于我的生活。



想知道是否有人有任何解决方法来获得JS的控制权HTML5音频/视频控制在iOS5中。



甚至可以通过一次点击来控制多个音频文件。就目前而言,如果我有10个声音效果,我需要10个用户点击来控制所有声音效果,这是 荒谬

解决方案

荒谬,但你必须从iPhone或任何手机的角度来看它。这是一款移动电话,通过带宽限制的蜂窝网络,许多人从最近的Sprint广告中知道。他们不希望用户超过他们的带宽限制,因为有些网站正在给他们的手机发送大量数据,而他们本身并没有采取行动。

以下是摘自官方 Safari开发者图书馆以获取更多详细信息。


用户通过蜂窝网络控制下载



在iOS上的Safari(包括iPad在内的所有设备上),用户可能在$蜂窝网络上购买
并按数据单元收费,预加载和
自动播放功能被禁用。直到用户启动它才会加载数据。
这意味着JavaScript play()和load()方法在用户启动回放之前也是非活动
,除非用户操作触发play()或load()方法
。换句话说,用户启动的Play
按钮可以工作,但onLoad =play()事件不会。



播放电影:< $ c $< input type =buttonvalue =PlayonClick =document.myMovie.play()>



这对iOS没有任何帮助:< body onLoad =document.myMovie.play()>



I have an HTML5 web-app that has sound effects. I'm trying to get these effects working in iOS5 and can't for the life of me.

Wondering if anyone has any work-arounds to get JS control of an HTML5 audio/video control in iOS5.

Or even a way to control multiple audio files with one click. As it stands right now, if I have 10 sound effects, I'd need 10 user clicks to get control of all of them, which is absurd!

解决方案

Absurb, but you have to see it from iPhone or any mobile phone's point of view. It is a mobile phone going over a cellular network with bandwidth limitations, which many people know about from the recent Sprint commercial. They do not want users going over their bandwidth limit because some site is sending their phone a large amount of data without them taking action themselves.

The following is an excerpt from the official Safari Developer Library with more details.

User Control of Downloads Over Cellular Networks

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()">

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

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