kleepklep Posted August 24, 2015 Share Posted August 24, 2015 I'm finding that IE11 often fails to load audio files and will throw an error like so. I'm using M4A for my music so there is no gap when I loop them. MP3s also fail to load sometimes, so it is not specific to a single file type.Phaser.Loader - audio[song3]: error loading asset from URL audio/song3.m4aThis seems to be a memory issue, as it usually happens with larger files. Using game.load.enableParallel = false does not help.This results in the following error which messes up my game because I am using audio onStop listeners that trigger certain events.Phaser.Cache.getSound: Key "song3" not found in Cache.Has anyone else run into this and figured out a fix? Though it could cause my game to hang forever, I tried to reload the audio files that failed, but nothing happens. Maybe I need to wipe out the previous attempt?game.load.onFileError.add(fileError, this);function fileError(key, file) { console.log('fileError', key, file.url, 'trying again'); game.load.audio(key, file.url);} Link to comment Share on other sites More sharing options...
kleepklep Posted September 9, 2015 Author Share Posted September 9, 2015 I never did find a solution for this, but was able to minimize the issue so I thought I'd share my insight in case anyone else runs into this.1. The sounds that fail are always further down the queue, so load any sounds with .onStop listeners first so nothing breaks, followed by sounds that would be the most noticeable if missing, like music. At first I thought it was the larger sounds that failed to load, but I moved all of them (the music) to the top of the queue and no longer have any problems loading them.2. Check the sound key first before playing a sound. If it does not exist use a fallback mechanism that can play audio on the fly. Here is an example using howler.js. Even with this, sounds only sometimes play for me, but it's better than nothing.if (!game.cache.checkSoundKey(key)) { console.log('checkSoundKey error! using fallback for ' + key + '!'); var sound = new Howl({ urls: ['audio/' + key + '.mp3'], autoplay: true, loop: false, volume: volume });}Here's my related post: https://github.com/photonstorm/phaser/issues/2038 Link to comment Share on other sites More sharing options...
georgejfrick Posted September 25, 2015 Share Posted September 25, 2015 I'm finding that IE11 often fails to load audio files and will throw an error like so. I'm using M4A for my music so there is no gap when I loop them. MP3s also fail to load sometimes, so it is not specific to a single file type.Phaser.Loader - audio[song3]: error loading asset from URL audio/song3.m4aThis seems to be a memory issue, as it usually happens with larger files. Using game.load.enableParallel = false does not help.This results in the following error which messes up my game because I am using audio onStop listeners that trigger certain events.Phaser.Cache.getSound: Key "song3" not found in Cache.Has anyone else run into this and figured out a fix? Though it could cause my game to hang forever, I tried to reload the audio files that failed, but nothing happens. Maybe I need to wipe out the previous attempt?game.load.onFileError.add(fileError, this);function fileError(key, file) { console.log('fileError', key, file.url, 'trying again'); game.load.audio(key, file.url);} Yes. I don't try to reload in the fileError method, I find that this works: 1. In your preload method:this.game.load.onFileComplete.add(this.fileComplete, this);1. In your handler, you can use this to both update your progress bar and:fileComplete: function (progress, cacheKey, success, totalLoaded, totalFiles) { if( success ) { this.progress.text = "Loading: " + progress + "%"; } else { log.debug("Retrying key " + cacheKey); this.game.load.audio(cacheKey, this.cacheTemp[cacheKey] ); }},I found that this reloaded everything. However, it doesn't fix audio randomly not playing or 'starting late'. If you find a comprehensive IE audio solution, I'd love to hear it. We tried this and ended up switching back to loading a single audio file with markers. They both work poorly in IE, but with the markers we get great performance everywhere else. Link to comment Share on other sites More sharing options...
kleepklep Posted October 7, 2015 Author Share Posted October 7, 2015 Thanks for sharing your insight I think the only solution here is not to use IE! Link to comment Share on other sites More sharing options...
Recommended Posts