kleepklep

IE11 audio loading issues

Recommended Posts

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.m4a
This 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);}

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.m4a
This 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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.