Jump to content

New event onFileComplete for decoded audio files


efusien
 Share

Recommended Posts

Hi,

 

On an audio file, is there a way to fire the event Loader.onFileComplete only when the file is decoded ?

 

Phaser states logic is based on preload and create functions.

When preload is endend we call the create function. But sounds are not always decoded.

Is there a way to upgrade this behavior?  I would like to start the create function only when sounds are fully decoded.

 

Please note I don't need a specific flag on my side to wait until my sounds are decoded. I need a Phaser logic here.

 

I guess a new parameter in the Loader.audio function could do the job:

game.add.audio(key, urls, autoDecode, fireFileCompleteEventOnDecoded)
Link to comment
Share on other sites

I ask this request because sounds on small mobile devices can take few seconds to decode.

 

On IOS devices sound decoding is quite fast (like on desktop).

But on last generation of Google Nexus or Samsung Galaxy tab the decoding takes few seconds.

Average 3-4 seconds for a 250K MP3 sound file  :o

Link to comment
Share on other sites

Yes, but I need the onFileComplete event to take care of the isSoundDecoded callback, if autoDecode is true.

 

Phaser calls the create method right after firing the onLoadComplete.

I would like it calls the create method after all sounds are decoded.

Link to comment
Share on other sites

That wouldn't really make sense. It's up to you to poll when the audio is ready and continue with your game. If you look at the Project Templates they all have a Preload state that doesn't advance to the MainMenu until the audio is decoded. Do something similar.

Link to comment
Share on other sites

I understand, I'm doing this in a similar way for my current game.

But the goal was to use the create() function after preloading.

 

In Project Templates we use the update() function. In this way create() is already fired.

I could have my own callback(), but some third part script, such as Transition Plugin, use the create function because it's part of the Phaser framework.

 

Plus, the onFileComplete event is usually used to display a progress bar.

Using the update function() like in Projet Templates doesn't do the job.

Again I can write the progress display myself, but why not use the Phaser one?

 

Maybe I'm only in this case. It's my own wish list :-)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...