Audio Delay on Android (Possible fix)

Bugs will be moved here once resolved.

Post » Tue Jul 29, 2014 6:39 am

Problem Description
Audio appears to be delayed when it is played from the sounds folder, however when it is played from the music folder, the delay is much less noticeable.

Attach a Capx
Capx is uploaded.

Description of Capx
Capx shows two blocks that when clicked play their audio through the two different folders.

Steps to Reproduce Bug
  • Step 1: Allow audio to preload.
  • Step 2: Play audio from sounds folder by clicking red box.
  • Step 3: Play audio from music folder by clicking blue box.

    Observed Result
    There is a significant delay from audio played from sound folder, when played on android devices.

    Expected Result
    I would expect both to be played with the same delay but they are not.

    Affected Browsers
    • Chrome: (YES)
    • FireFox: (YES)
    • Android Browser: (YES)

Operating System and Service Pack
Windows 8.1

Construct 2 Version ID
R175
You do not have the required permissions to view the files attached to this post.
Image
Download my game ROWyerBOAT on android for free here!
B
8
S
2
G
1
Posts: 39
Reputation: 671

Post » Tue Jul 29, 2014 8:04 am

I had this problem before. But not anymore. I keep the sound in the sound folder and the music in the music folder and it works like a charm. The sound in the sound folder is downloaded the first time they are played while the music in the music folder is streamed and that is why you see the difference in the delay.

I start my game with a loading layout and after the loading is complete I go to the main menu layout.

Then I Usually start by putting the play audio event before any other event. Like on collission wih X play audio followed by the other events like damage or other code.

I also delete all other file formats of every sound, only keeping the .ogg files.

In the new version of construct I think preload sound is forced by default and no preloading is required. But correct me if I'm wrong.

If you are experiencing this while testing on network or in browser on your android device then I think this is the problem. I also see this delay when I test the game thorugh my network. But as soon as I compile and wrap it with CocoonJS the delay disappears.

So if you haven't compiled it and wrapped it yet. Try that and see what you get.

This woked for me when I made this simple android game:
https://play.google.com/store/apps/deta ... appz.dropz
B
58
S
24
G
14
Posts: 775
Reputation: 13,166

Post » Tue Jul 29, 2014 4:21 pm

Thank you for your quick and very useful response. I tried everything that you said and it did not work but I noticed that when I downloaded your game and played the audio was delayed on my phone. (Very nice game by the way, the soundtrack is awesome.)

I also noticed that when I compiled this Capx provided above and wrapped it up in cocoonjs that the audio delay between the two boxes was identical.

So, I have come to the conclusion that the audio delay problem is in my phone itself.

For those interested I have an HTC Droid DNA Android Smartphone.
Image
Download my game ROWyerBOAT on android for free here!
B
8
S
2
G
1
Posts: 39
Reputation: 671

Post » Mon Aug 04, 2014 4:02 pm

Can't reproduce on a Nexus 5 with Android 4.4.4 running Chrome with preview-over-wifi. The latency appears identical. Anyway we don't control the audio stack, it's built in to the phone, and some older Android devices add high latency in the OS. There's nothing we can do about that.
Scirra Founder
B
400
S
236
G
89
Posts: 24,549
Reputation: 195,475

Post » Tue Aug 05, 2014 4:50 am

Ashley wrote:Can't reproduce on a Nexus 5 with Android 4.4.4 running Chrome with preview-over-wifi. The latency appears identical. Anyway we don't control the audio stack, it's built in to the phone, and some older Android devices add high latency in the OS. There's nothing we can do about that.


Ahhh, I see. Thank you for looking into this for me Ashley. Construct 2 is an incredibly powerful and amazing tool.

Keep up the good work!
Image
Download my game ROWyerBOAT on android for free here!
B
8
S
2
G
1
Posts: 39
Reputation: 671

Post » Sun Oct 19, 2014 3:22 pm

Message: frenzyace is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
Anonnymitet wrote:I had this problem before. But not anymore. I keep the sound in the sound folder and the music in the music folder and it works like a charm. The sound in the sound folder is downloaded the first time they are played while the music in the music folder is streamed and that is why you see the difference in the delay.

I start my game with a loading layout and after the loading is complete I go to the main menu layout.

Then I Usually start by putting the play audio event before any other event. Like on collission wih X play audio followed by the other events like damage or other code.

I also delete all other file formats of every sound, only keeping the .ogg files.

In the new version of construct I think preload sound is forced by default and no preloading is required. But correct me if I'm wrong.

If you are experiencing this while testing on network or in browser on your android device then I think this is the problem. I also see this delay when I test the game thorugh my network. But as soon as I compile and wrap it with CocoonJS the delay disappears.

So if you haven't compiled it and wrapped it yet. Try that and see what you get.

This woked for me when I made this simple android game:


Hey I downloaded your app. Cool app, I like the quotes. Question, I'm still kinda confused. How did you preview your loading screen to see if it was working. And when I put my audio on preload, I would wait for about 10 mins, and I would hear nothing.
B
7
S
1
Posts: 25
Reputation: 523

Post » Mon Oct 20, 2014 9:41 am

@frenzyace Thank you. It was my first ever game so its far from perfect :P

Do you mean you have to wait for about 10min on a black screen or is the game still running? And is this happening while you preview or after you have compiled the game?
B
58
S
24
G
14
Posts: 775
Reputation: 13,166

Post » Sat Nov 08, 2014 11:32 pm

Anonnymitet wrote:@frenzyace Thank you. It was my first ever game so its far from perfect :P

Do you mean you have to wait for about 10min on a black screen or is the game still running? And is this happening while you preview or after you have compiled the game?


Basically I have to wait for like 5 mins on the loading screen for the game to start. I set my audio on preload. Also I'm confused, how o I know which one should go in the Sounds and Music folder. Do all the m4g go in the music folder, and all the ogg go in sound folder.
B
7
S
1
Posts: 25
Reputation: 523


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests