我使用的是 http://jplayer.org/ 的最新版本在我的网站上,从 thread 将其加载到 iphone 时遇到问题。
页面 super 简单。
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.js" ></script>
<script type="text/javascript" src="script/jquery.jplayer.js" ></script>
<title>Test iphone</title>
</head>
<body>
Test
<script>
$(document).ready(function () {
$("#jquery_jplayer_1").jPlayer();
});
function SuperSimple() {
$("#jquery_jplayer_1").jPlayer("clearMedia");
$("#jquery_jplayer_1").jPlayer("setMedia", { artist: "Queen", mp3: "/test/examples/blue.monday/music/Innuendo.mp3", title: "Innuendo" });
$("#jquery_jplayer_1").jPlayer("play");
}
function SuperSimpleWithDelay() {
setTimeout(function () {
$("#jquery_jplayer_1").jPlayer("clearMedia");
$("#jquery_jplayer_1").jPlayer("setMedia", { artist: "Queen", mp3: "/test/examples/blue.monday/music/Innuendo.mp3", title: "Innuendo" });
$("#jquery_jplayer_1").jPlayer("play");
}, 5000);
}
</script>
<div id="jquery_jplayer_1"></div>
<br>
<button onclick="SuperSimple()"> SuperSimple </button><br><br>
<button onclick="SuperSimpleWithDelay()"> SuperSimple with delay </button><br><br>
</body>
</html>
如您所见,有 2 个按钮。他们都做同样简单的事情 - 加载媒体并播放它,但第二个功能使用 dalay 功能。它无处不在,但在 iphone 上不行。
我试过那个页面 http://m.musiclib.org/test/examples/blue.monday/iphone.html在少数设备上
- 装有 ios 7.1.2 的 Iphone - 不工作!
- 诺基亚 lumia 720 - 有效!
- 使用安卓 5.1 的 Lenovo Vibe Shot - 不工作!
- pc chrome/firefox/IE - 有效!
所以我的问题是为什么会这样?实际上,对我来说,如果我尝试从非主线程运行播放器,它似乎会停止为 iphone 工作。因为每次我尝试运行播放器时,它都会在一些延迟后停止工作,例如在 ajax 请求之后。
这里有什么帮助吗?我能以某种方式修复它吗?
公爵
最佳答案
尝试
$(window).load(function(){})
代替文档
$(document).ready(function(){})
关于javascript - iphone 的 jplayer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33285552/