Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html5 audio return error MEDIA_ERR_SRC_NOT_SUPPORTED after 6 audio loaded in IE

i need to load near 20 sounds on my page. i thought maybe i need to load only 2 element separately so that's why you will see inProgress property

loadAudio: function () {
        if (this.inProgress <= 1) {
            this.inProgress++;
            var elem = this.audioQueue.pop();
            if (elem != null) {
                var path = elem.Path + elem.Fileid + ((this.canPlayMp3) ? '.mp3' : '.wav');

                audio = new Audio();
                audio.src = "http://localhost:55578/~/x.mp3";
                audio.addEventListener('loadedmetadata', function (e) { AudioPlayer.audioLoaded(e); }, false);
                //audio.addEventListener('loadeddata', function (e) { AudioPlayer.audioLoaded(e); }, false);
                audio.addEventListener('error', function (e) { AudioPlayer.audioLoaded(e); }, false);
                if (elem.AudioType == AudioPlayerTypes.Keyboard) {
                    this.keyboardAudio[elem.Id] = audio;
                }
            }
        }



 audioLoaded: function (e) {
        var t = e.target;
        if (e.type == "error") {
            var code = e.target.error.code;

            console.log("error" + t.currentSrc + e.target.error.code);
        } else {
            console.log("loaded" + t.currentSrc);
        }
        this.inProgress--;
        this.loadAudio();
    }

As you can see i am loading the same sound just for test but the same problem after 6 audio i got error

LOG: loadedhttp://localhost:55578/~/x.mp3 
LOG: loadedhttp://localhost:55578/~/x.mp3 
LOG: loadedhttp://localhost:55578/~/x.mp3 
LOG: loadedhttp://localhost:55578/~/x.mp3  
LOG: loadedhttp://localhost:55578/~/x.mp3  
LOG: loadedhttp://localhost:55578/~/x.mp3  
LOG: errorhttp://localhost:55578/~/x.mp3 (4 - is error code)

it works pretty cool in Chrome, Firefox but not in IE. I cant find any limitations, and solutions.

Also additional question: I read that some times is better avoid DOM elements so thats why i am workin with audio object because i need to play different elements lots of times.

like image 629
Vova Bilyachat Avatar asked Nov 13 '22 12:11

Vova Bilyachat


1 Answers

Well its really strange, generally error is correct because IE Doesn't have free resources. On my laptop was issue with charger, computer was really slow, and today i changed it, and computer works faster and sounds are loaded in explorer properly :)

like image 170
Vova Bilyachat Avatar answered Nov 16 '22 04:11

Vova Bilyachat