我正在编写一个 html5 / javascript 游戏,并且阅读了很多关于 iOS 只能使用 html5 音频标签在任何时候播放一个音轨的各种博客文章。这似乎已在 iOS6 中得到修复,但我没有看到很多关于 Android 支持的信息。我有几个 Android 设备 - 运行 Jelly Bean (v4.2.1) 的三星 Galaxy Nexus 和运行最新版本 (10.2.4) 的 Kindle Fire,我认为这是冰淇淋三明治的改编版本。Galaxy nexus 在任何时候都只会播放一首曲目,但 Kindle Fire 会播放多首曲目。我假设这是因为 Kindle Fire 上的 Silk 浏览器比默认的 Android 浏览器对音频标签的支持更好,但我想确认这一点,以便我可以尝试衡量问题的影响有多大.
这是在 Galaxy Nexus 上无法正常工作的代码:
<audio id="audio1" controls>
<source src="http://dl.dropbox.com/u/1538714/article_resources/cat.m4a" type="audio/mpeg" />
<source src="http://dl.dropbox.com/u/1538714/article_resources/cat.ogg" type="audio/ogg" />
</audio><br />
<audio id="audio2" controls>
<source src="http://dl.dropbox.com/u/1538714/article_resources/song.m4a" type="audio/mpeg" />
<source src="http://dl.dropbox.com/u/1538714/article_resources/song.ogg" type="audio/ogg" />
</audio><br />
<button onclick="play();">Play</button><br />
<script type='text/javascript'>
var play = function() {
var audio1 = document.getElementById('audio1');
var audio2 = document.getElementById('audio2');
audio1.play();
audio2.play(); // this will stop audio1 on the Galaxy Nexus
}
</script>
其他运行 Ice Cream Sandwich 或 Jelly Bean 的 android 设备一次只支持一个轨道吗?
这个网页提供了一个很好的快速测试。如果您单击“播放”,则两者应一起播放。我对在 Android 之上运行专有软件的设备特别感兴趣,而不仅仅是 Galaxy Nexus 上的“纯”Android。