0 Favourites

[R 104]Cocoonjs + C2 sound format issue

  • Hello all, thought this could help other people having the same issue.

    Also possibly related to prior sound issues people had in another thread that was closed.

    ----

    I've had an issue with long sound files vs short ones. Long sound files (longer than 20 secs)would play, but short ones wouldn't play on android.

    I contacted Ludei about this and sent them a ZIP.

    Well, looks like the game was not detecting my device correctly (android) and tried to play the short sound files in m4a format which is not working on android (I didn't know). Should be playing ogg files instead.

    Check the debug menu in Cocoonjs during gameplay (fps number box), verify if you see your sound files being loaded in m4a format.

    If so, a temp solution is to do this (you can use Notepad++ on windows):

    Modify line 775 of c2runtime.js and change this line:

    this.isAndroid = /android/i.test(navigator.userAgent);

    for this line:

    this.isAndroid = true;

    Should force a proper detection of your device and play all sound files as ogg.

    By the way, "c2runtime.js" is inside your exported ZIP file for Cocoonjs.

    UPDATE:

    In any case the above fix doesn't work for you, you can also just replace every instance of the word "m4a" with "ogg" in the above JS file.

    Also, make sure you've got the actual ogg files in your game. (C2 creates them for you at the import of sounds)

    Ashley: this issue seems to be related to the way C2 detects what device is running the game after Cocoonjs modifies the useragent. Seems to mess up the detection system. The guys over at Ludei told me they would sort this bug out with you guys. UPDATE: looks like this will be fixed in an update of Cocoonjs. Ludei: "A bug that isn't reporting the user agent correctly and that's what's making Construct use the m4a files." You can close this bug I guess. :)

    ----->Also, is there a way to include only ogg files when we know the game will run on Android? Without the need to delete wav and m4a files manually before the export. Thx

  • Thanks very much ?TheDev?

  • TheDev

    Thank you for this valuable information.

  • No problem guys.

    See updated original post for more details.

  • For me it was the second solution that fixed my game.

  • TheDev - your fix does not make sense. Here's the code Audio currently uses to determine whether or not to use .ogg files:

    if (this.runtime.isDirectCanvas)
         useOgg = this.runtime.isAndroid;          // AAC on iOS, OGG on Android
    else
         useOgg = !!(new Audio().canPlayType('audio/ogg; codecs="vorbis"'));

    so the 'isAndroid' variable should be totally ignored on CocoonJS and therefore should not affect whether .m4a or .ogg is chosen.

    It looks like a bug in CocoonJS, not Construct 2. The line !!(new Audio().canPlayType('audio/ogg; codecs="vorbis"')) needs to return true if .ogg is supported, but it looks like CocoonJS is returning false even when it does support it.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Yep. Like I mentioned in my updated post, after speaking to the guys over at Ludei and further investigation of the issue, they told me it is a CocoonJS bug after all.

  • TheDev - Ludei's response still sounds like they won't have fixed it because the 'canPlayType' function is not related to the user agent. It sounds like they're fixing the detection with 'isAndroid', which will not affect this issue.

  • Alright, I'll let them know.

    I really need (and many people I'm sure)their next version of Cocoon to have a fix for this.

  • Closing as a bug for Ludei.

  • Hi,

    sorry to post in this closed thread, but it seems the most appropriate for my issue here:

    I have an app that plays sounds on press of a button ( one at a time ), and the app is being compiled with CocoonJS. The web version works just fine. However, when compiling and running as native, all the short sounds ( below 20 sec. ) ends up after just 4 or 5 seconds of play. Whatever sounds I play and they are longer then 20", they play just fine.

    In the Cocoon's app launcher debugger I see as the attached screenshot.

    Question: is this change from sound to music a C2 action or Cocoon's? And how/why is this affecting the playing of shorter then 20 sec. sounds?

    As a note, on iOS this doesn't seem to happen.

    Thank you!

    <img src="https://dl.dropbox.com/u/102498471/20121206133719.png" border="0" />

  • xyboox - sounds like an issue with CocoonJS, you should probably contact Ludei about it.

  • OK, thanks Ashley, so I did. I'll post back here the outcome of this.

  • OK, thanks Ashley, so I did. I'll post back here the outcome of this.

    Hi, i'm having the same problem... except... no sounds are playing at all!

    Any developments xyboox?

    Phonegap isn't an alternative because it has a 9.5mb limit...

    -newbie out! <img src="smileys/smiley36.gif" border="0" align="middle" />

  • vila4480 If I remember correctly, the last release of CocoonJS solved that issue. However, I moved to Phonegap for that project. Not the Phonegap Build online service, but using Eclipse IDE with phonegap ( for Android ) and Xcode + phonegap for iOS.

    Good luck!

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