I’m going to use the Sound component. I just need to play a 4-5 seconds sound (a notification) so according to what I read in this forum Sound is better than the Player component.
However, according to the Sound component help text:
You might get an error if you attempt to play a sound immediately after setting the source
I haven’t experienced the issue but someone else using my app could. Is there a way to avoid it?
It would really help if you provided a screenshot your relevant blocks, so we can see what you are trying to do, and where the problem may be.
To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.
In my app I set the Sound “Source” attribute to the filename I want to play (as I said, it’s a short notification) and then immediately make a call to Sound method “Play”. According to the help, this situation could lead to an error.
My question is: is there anything I can do to avoid that a user see that error?
At the moment I’m not seeing any error but a user of my application could, and I’d like to prevent it.
Yes. Use a Clock timer to start the sound component after setting the source. You probably only need 100-200ms, may depend on the file size (so optimise your sound files)