首页 > android浏览器无法同时播放多个音频文件?

android浏览器无法同时播放多个音频文件?

制作一个小游戏,有背景音乐。

在交互时也有音乐。然而交互音乐响起的时候背景音乐就停掉了,有没有解决方案?

测试iphone是没问题的。android上有什么解决方案又不会影响到iphone效果。


有尝试其它浏览器吗?如果不是浏览器的问题,尝试下以下几个类似问题的解决办法:

类似问题1 Current support on Android for playing multiple audio tracks at a time using the html5 audio tag

类似问题2 Play multiple sound at the same time
及其解决办法:

With JavaScript and the HTML5 Audio API you could do something like this:

    var snd1  = new Audio();
    var src1  = document.createElement("source");
    src1.type = "audio/mpeg";
    src1.src  = "audio/Dombra.mp3";
    snd1.appendChild(src1);

    var snd2  = new Audio();
    var src2  = document.createElement("source");
    src2.type = "audio/mpeg";
    src2.src  = "audio/(TESBIHAT).mp3";
    snd2.appendChild(src2);

    snd1.play(); snd2.play(); // Now both will play at the same time

类似问题3 Multiple tracks on mobile devices

You need to consider the difference between WebAudio and HTML5 audio. WebAudio supports multiple tracks quite happily, whereas HTML5 audio is much more limited (and often painful to use!). Some devices will allow playing more than one HTML5 audio sound at once and others don't. On the whole my experience of HTML5 audio is that it is hugely unreliable and inconsistent, laggy, and generally unpredictable. If you want to use multiple tracks you are definitely better off looking at using WebAudio. But bear in mind that not all mobile browsers support it, although most do these days. In particular the Android stock browser does not support WebAudio.

一篇参考文章Fixing HTML5 Audio Problems in iOS and Android Mobile Browsers to Overcome the Limitations

【热门文章】
【热门文章】