thunkable / thunkable-issues

24 stars 9 forks source link

"Then Do" part of Sound component's play function executes immediately not after sound done playing #1233

Open vaskarni opened 1 year ago

vaskarni commented 1 year ago

Platform

This affects: Thunkable Snap In Place Drag and Drop UI - web? No Drag and Drop UI - Android? No Drag and Drop UI - iOS? No

Steps to Reproduce

  1. Create a Sound component.
  2. Load a mp3 file (a song) in Assets and set source to this file
  3. When a button is clicked, associate a Sound 'play' block
  4. Add a Label that shows status of song (playing or done playing)
  5. Inside the "then do" part of the block set the label's text to "Song completed"

Expected Behavior

What did you expect to happen? The sound file plays. When completed, it should enter the "then do" block and change label's text to "Song completed"

Actual Behavior

What actually happens? It executes the block inside "then do" immediately and says "Song completed" when it is still playing. Essentially there is no way of knowing when the file is done playing. This was working as expected earlier (6-8 months ago). Not sure what changed. Please advise.

Project Link

Link to a project copy that shows this behaviour. This is important because most times we cannot reproduce the issues reported just with the list of steps, so please do provide this. Since it is very straight forward, did not include. But if needed I can do it.

Community Link

If there's an ongoing discussion about this behavior in the Community, please link to it here None found.

  STACK TRACE AND/OR SCREENSHOTS
tatiang commented 1 year ago

This is still a reproducible bug. See https://community.thunkable.com/t/sounds-not-playing-one-after-each-other/2289971

agvardha57 commented 1 year ago

Same issue I also faced. https://community.thunkable.com/t/how-to-play-multiple-audio-files-in-series/2361744/2 Please note with the "speech" module you can stack them and they work in series. So there is hint for you to see in the source and fix the play button.

vaskarni commented 1 year ago

The issue has no reasonable workaround. While thunkable is great in many aspects, issues like this make building apps very difficult or in some cases abandoning the app itself. Please review and suggest workarounds or provide a fix. Greatly appreciate it.

agvardha57 commented 1 year ago

image Hi @vaskarni This workaround works smooth. Bit more work but works seamlessly Cheers ananda

vaskarni commented 1 year ago

Thanks for the suggestion. But it is not a deterministic solution. What happens if you pause via a "Pause" button. The 'wait' part does not know that and it goes out of sync. Plus, all I am looking for is to know when a 'play' block is done for subsequent action. Although this is basic, it is unfortunately, impossible. It seems like the 'play' part is a separate thread but when it finishes, it does not communicate back to the one that spawned it and hence is 'lost'.

agvardha57 commented 1 year ago

Yes indeed you are right and I also realized it later. Pause killed it. So I was forced to stitch all of them and make some other adjustments. It is terrible. Let me throw some ideas for Thunkable developers for ideas to fix it: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects I lived my using these two calls. This is what play needs. The funny thing is the say works and you can do this and it happens one after the other image

The only bug is if the user exits the app in the middle of sentence "say" does not stop. Once it starts it keeps on going. That is even a stranger bug than the paly bug :)

vaskarni commented 1 year ago

I don't know if there is a way to reach to Thunkable staff directly. It seems hard to get their attention. All you can do is create a bug here and pray someone looks at it, puts it in queue and provides a ETA. Unfortunate.