[Finally solved] CocoonJS on resume bg music bug.

0 favourites
  • 4 posts
From the Asset Store
800+ assets with UI, BGs and animations for your arcade games
  • Probably you have noticed that when you resume your app wrapped with CocoonJS 1.4 on android the bg music plays twice. I finally found the problem and managed to resolve it.

    The new CocoonJS audio engine seems to handle itself the onsuspended and onresume conditions, so I had to remove some code lines in c2runtime.js that also handled the same conditions making the bg music duplicate.

    To apply this workaround you have to follow these steps.

    1) Export your project without minifying your code.

    2) Uncompress c2runtime.js and open it with a text editor (I suggest Notepad++)

    3) Find the following lines of code

    C2AudioInstance.prototype.setSuspended = function (s)

         {

              

              switch (this.myapi) {

              case API_HTML5:

                  ?if (s)

                  ?{

                        if (this.isPlaying())

                        {

                             this.instanceObject["pause"]();

                             this.resume_me = true;

                        }

                        else

                             this.resume_me = false;

                  ?}

                  ?else

                  ?{

                        if (this.resume_me)

                             this.instanceObject["play"]();

                  ?}

                  ?break;

    4) delete everything in the middle of case API_HTML5 and break. It should look like this:

    case API_HTML5:

    break;

    5) Save and put the modded c2runtime.js in your project zipped file

    6) Enjoy <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley

    Any comment on this ?

    Knifegrinder

    Maybe you can submit a bug report on this issue.

  • This will break music on other platforms (e.g. it will continue to play music in the background when switching tab in a browser). It's a CocoonJS bug, you should report it to Ludei.

  • This will break music on other platforms (e.g. it will continue to play music in the background when switching tab in a browser). It's a CocoonJS bug, you should report it to Ludei.

    True. And this issue has been reported to Ludei by various users on their forum.

    That's why I suggested to work on the c2runtime.js created with the cocoonjs exporter instead of editing directly the audio plugin runtime.js.

    This way you don't break anything and works as a temporary workaround.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)