Html5 audio return error MEDIA_ERR_SRC_NOT_SUPPORTED after 6 audio loaded in IE

匿名 (未验证) 提交于 2019-12-03 02:52:02

问题:

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.

回答1:

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



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!