HTML5 如何为JavaScript游戏替换Internet Explorer的WebAudio API

HTML5 How to replace WebAudio API for Internet Explorer for javascript games?

本文关键字:Explorer Internet WebAudio API 替换 游戏 JavaScript HTML5      更新时间:2023-09-26

我是html音频新手。 我找到了一些关于小JavaScript游戏的好例子。 想要我尝试在Internet Explorer中加载游戏,我得到:"此浏览器不支持Web api音频"。

我找到了这个网站:http://caniuse.com/#feat=audio-api,看起来IE浏览器不支持它。

我还发现SoundManager 2似乎适用于所有浏览器。

我的问题,有没有办法检测浏览器是否支持 WebApiAudio 并在不支持时提供回退?

我希望能够在所有不同的浏览器上提供相同的功能,但目前我不知道该怎么做。

一个不错的功能是能够同时播放多种声音,并具有可调节的音量声音(如爆炸)。

我想创建一个可以在PC,Mac,Android和Ipad上运行的helloworld。 可能吗?

非常感谢我的多个问题。

我检查了这个演示:http://www.cocos2d-x.org/wiki/MoonWarriors_-_Cocos2d-JS_Showcase 声音在 Firefox 中工作正常,但在 Internet Explorer 中只有音乐,没有音效

我的问题,有没有办法检测浏览器是否支持 WebApiAudio 并提供回退(如果不支持)?


"use strict"

function audioContextCheck() {
    if (typeof AudioContext !== "undefined") {
        return new AudioContext();
    } else if (typeof webkitAudioContext !== "undefined") {
        return new webkitAudioContext();
    } else if (typeof mozAudioContext !== "undefined") {
        return new mozAudioContext();
    } else {
       // Do stuff with soundmanager or something else if Web Audio API is not supported


    }
}
var audioContext = audioContextCheck();