Jump to content

Decode Audio, check if is ready to next state (mobile)


Recommended Posts

Hi, I'm trying to check if the audio is ready before start the MainMenu.

    create: function () {        this.addGameSrc();        Vendor.addSound();        Vendor.addMusic('main_menu', true);        audios = [ music, sfx_Click, sfx_Drop, sfx_Explode ];        console.log(audios);        this.status.setText('DECODING AUDIOS...');        this.sound.setDecodedCallback(audios, this.start(), this);    },    start: function () {        this.status.setText('READY');        setTimeout(function () {            game.state.start("MainMenu");        }, 250);        console.log("Splash\t\tOK");    },

ERROR: TypeError: this._watchCallback is undefined



I also tried this code:

    create: function () {        this.addGameSrc();    },        update: function () {        if (game.cache.isSoundReady('click', 'main_menu')) {            this.startMenu();            } else {            this.status.setText('DECODING AUDIOS...');        };    },        startMenu: function () {        this.status.setText('READY');        this.state.start("MainMenu");        console.log("Splash\t\tOK");    },

But it takes so long for decode, tested with S6 Edge and about 10 seconds waiting, doesn't matter if the audio is an mp3 or ogg with 5k or 500k, if it's one single file or ten files, make no sense for me...

Plz, Someone can help me to fix this? :)



Link to comment
Share on other sites


  • Recently Browsing   0 members

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