Button taking too long to respond and play a sound

Whenever I click on a button in my application, the button takes a long time to execute the task (it takes about 1 or 2 seconds to execute), I've tried several things but have not been successful.

Welcome. And what task would that be?

1 Like

Hi, I'm trying to make it play a sound when the button is pressed, but as I said, it's taking a long time to respond. And I think the problem would not be the sound, because when I click on the button, the button animation also takes time to happen.

Sorry if I said something wrong, I'm using Google translate.

Maybe, but for the root cause analysis you can share you relavent blocks which are concerned about the button and for playing sound.

20220917_002557
Sorry for the low quality image

How are you testing. Are you working on the companion or after building? What kind of device do you have? Which android version? Can you post your aia?

I test both. I have a Galaxy j4. Android 10. I will send my aia tomorrow

How big (file size) are the sounds?
Where are the sounds located (on device or on internet) ?
How have you set the source for each sound ?
Why use so many sound components when you could just use one, and change the source?

1 Like
  1. How long (duration in sec) are the sound files? (They shouldn't be longer than 4-5 sec, if the Sound component is used.)
  2. What is the audio format (mp3, ogg, m4a, wav, ...)?
  3. How many Sound components do you use?
  4. Do you want the sounds to play simultaneously, or just one at a time?
  5. Try the Player component instead of the Sound component (and only use 1 component if only 1 sound should be played at the same time, as Tim said).

Do that. That way we don't have to guess anymore.
And then we can most likely present the solution in a few seconds. :wink:

1 Like

Which animation?

Hello Regis

You could achieve the same with a ListView rather than a ton of buttons.

Concerning the time lag - do you swap Screens? Does the App use a Clock Timer?

Here is my .aia:
EfeitosDoRodrigoFaro.aia (3.9 MB)

No need to post your aia twice.

I thought I hadn't sent it, sorry

Just tested your aia. No problems for me. Working fast on my Pixel 4a with Android 13 using the companion.

You should really use only one sound component.

your phone is 4 years old and was originally with Android 8. I saw somewhere you could only update it to Android 9. How did you update to Android 10? Maybe your phone can not switch fast enough between sounds.

Tested (Companion app, chromebook to Google Pixel 4a), no problems with any of the sound files, no delay to any button selections.

I got the android 10 update even though it is not supported

  1. Does the problem occur with all sounds (wav, mp3)?
  2. Does the problem occur with Companion and / or the APK?
  3. Remove all Sound components except one and try again (with wav & mp3). Same result?
1 Like

That may well be an issue!

Here is a version of your App using just one Sound component and without 20 individual Button Click Blocks. Managing your code this way is much easier to edit in the future.

I don't expect it to fix your bug, which seems to be only on your device.

EfeitosDoRodrigoFaroEdit.aia (3.9 MB)

Note, you should not define your GUI in pixels - that makes it a bad fit on other devices.
https://www.professorcad.co.uk/appinventortips#TipsGui

1 Like