HTML5如何为javascript游戏替换Internet Explorer的WebAudio API? [英] HTML5 How to replace WebAudio API for Internet Explorer for javascript games?

查看:190
本文介绍了HTML5如何为javascript游戏替换Internet Explorer的WebAudio API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm new with audio in html. I found some nice examples for little javascript games. Want I try to load the games in Internet Explorer, I got : "Web api audio is not supported in this browser".

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

I found this site : http://caniuse.com/#feat=audio-api and look like Internet Explorer doesn't support it.

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

I found also SoundManager 2 that seem to work on all browsers.

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

My question, is there is a way to detect if the browser support WebApiAudio and offering a fallback if is not supported ?

我希望能够在所有不同的浏览器上提供相同的功能,但是我目前还不知道如何做到这一点。

I want to be able to offer the same functionality on all differents browsers, but I have no idea how to do that at this point.

一个不错的功能是能够同时播放多个声音并发出可调音量(如爆炸声)。

One nice feature is able to play multiple sounds in the same time with ajustable volume sound (like explosions).

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

I want to create a helloworld that I could run on PC, Mac, Android and Ipad. Is it possible ?

非常感谢我的多个问题。

thanks a lot for my multiple questions.

我查看这个演示: http://www.cocos2d-x.org/wiki/MoonWarriors_-_Cocos2d-JS_Showcase 声音在Firefox中运行良好,但在Internet Explorer中只有音乐,而不是声音效果

I check this demo :http://www.cocos2d-x.org/wiki/MoonWarriors_-_Cocos2d-JS_Showcase the sound works fine in Firefox, but in Internet Explorer there is only music, not sound effects

推荐答案


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

My question, is there is a way to detect if the browser support WebApiAudio and offering a fallback if is not supported ?







"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();

这篇关于HTML5如何为javascript游戏替换Internet Explorer的WebAudio API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆