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

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

问题描述

在除用户执行的单击事件处理程序之外的任何情况下,我似乎都无法在 iOS 4.2.1 上的 Mobile Safari 中播放音频媒体.即便如此,如果以任何异步方式(ajax、setTimeout 等)调用 player.play(),它也不起作用.

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.

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

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.

所有在 iOS 4.2.1 之前有效的漏洞似乎都已关闭.有什么想法吗?

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

推荐答案

从iOS 4.2.x开始,如果没有用户输入事件,比如touchstart,将不会开始下载媒体.

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

所以答案是,没有通过 JavaScript 或其他方式自动播放媒体的方法.

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天全站免登陆