Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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".

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

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

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).

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.

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

like image 854
Sebastien Dionne Avatar asked Dec 04 '25 13:12

Sebastien Dionne


1 Answers

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();
like image 184
William Avatar answered Dec 07 '25 03:12

William



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!