[R 104]Cocoonjs + C2 sound format issue

Bugs will be moved here once resolved.

Post » Sat Sep 29, 2012 1:52 am

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. ThxTheDev2012-09-30 04:08:47
B
4
Posts: 41
Reputation: 407

Post » Sat Sep 29, 2012 4:58 am


Thanks very much TheDevfelixsg2012-09-29 04:59:53
B
61
S
9
G
7
Posts: 176
Reputation: 8,824

Post » Sat Sep 29, 2012 3:29 pm

@TheDev
Thank you for this valuable information.
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Sun Sep 30, 2012 6:29 am

No problem guys.

See updated original post for more details.
B
4
Posts: 41
Reputation: 407

Post » Sun Sep 30, 2012 7:58 am

For me it was the second solution that fixed my game.
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Mon Oct 01, 2012 2:50 pm

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

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

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Mon Oct 01, 2012 7:25 pm

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.TheDev2012-10-01 19:25:25
B
4
Posts: 41
Reputation: 407

Post » Mon Oct 01, 2012 9:33 pm

@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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Tue Oct 02, 2012 3:46 am

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.
B
4
Posts: 41
Reputation: 407

Post » Wed Oct 10, 2012 10:46 am

Closing as a bug for @Ludei.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests