user2018783
user2018783

Reputation: 89

JS: Audio Method not implemented in IE 10 of server 2008 R2

Here is my script:

<script>
var bgMusic = new Audio("../song.mp3");
var bgMusic2 = new Audio("");
</script>

IE10 of server 2008 R2 throw this error: Not implemented.
I tried in IE10 of normal desktop like window 8 and no this error.

Please help, Thanks!!

Upvotes: 0

Views: 697

Answers (1)

George Filippakos
George Filippakos

Reputation: 16569

If sound support has been disabled (the default in windows server), then IE throws an error when trying to access the html5 Audio object.

You could use Try Catch block to test for audio support like this:

//test file type support:
var snd = null;
var mp3support = false;
var oggsupport = false;
try {
    snd = new Audio();

    if (snd.canPlayType('audio/ogg')) {
        //play your ogg file
        oggsupport = true;
    }
    else if (snd.canPlayType('audio/mp3')) {
        //play your mp3 file
        mp3support = true;
    }
} catch(e) {
    return;
}

I have tried this and it works great.

Upvotes: 3

Related Questions