我如何在iOS中自动播放媒体> = 4.2.1 Mobile Safari? [英] How can I autoplay media in iOS >= 4.2.1 Mobile Safari?

查看:124
本文介绍了我如何在iOS中自动播放媒体> = 4.2.1 Mobile Safari?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在iOS 4.2.1的移动版Safari中使用除用户执行的点击事件处理程序之外的任何情况下的音频媒体。即使如此,如果以任何异步方式( ajax,setTimeout 等)调用 player.play() 't work。



我曾尝试在 player之前调用 player.load() .play()。我试过在处理程序调用 player.play()的dom元素上触发一个click事件。我尝试过使用音频和视频标记。



iOS 4.2.1之前的所有漏洞似乎都已关闭。任何想法?

解决方案

从iOS 4.2.x开始,如果没有用户,则不会启动媒体下载这样的答案是 no ,没有办法通过JavaScript或其他方式自动播放媒体。

p>

I cannot seem to get audio media to play in Mobile Safari on iOS 4.2.1 in any situation other than the handler of a click event performed by the user. Even then, if player.play() is called in any asynchronous fashion (ajax, setTimeout, etc) it doesn't work.

I've tried calling player.load() before player.play(). I've tried triggering a click event on a dom element whose handler calls player.play(). I've tried using both audio and video tags.

All the loopholes that worked prior to iOS 4.2.1 seem to be closed. Any ideas?

解决方案

Starting from iOS 4.2.x, the download of media will not be started if there isn’t a user-input event, like touchstart.

So the answer is no, there is no method to autoplay media by JavaScript or something else.

这篇关于我如何在iOS中自动播放媒体> = 4.2.1 Mobile Safari?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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