How to use the SoundRecorder & Player component and avoid problems/bugs with it

In fact, it is not at all surprising that many people have difficulties with the SoundRecorder and/or the Player component. So here is a guide on the subject.

There are numerous issues with the SoundRecorder and Player components when not saving to and playing from the ASD. I won't list them all here (just the most important). Everyone can test it themselves.

  1. You cannot record .3gp files in the Shared folder /Music on Android 11+.

  2. READ permission is incorrectly requested for the Player component also on Android 11+ for the Shared folders.

  3. The Player component cannot play audio files with the absolute path /storage/emulated/0/... from the Shared folders (at least not on Android 11+). The full path ( file:///storage/emulated/0/...) must be used or the abolute path: /scard/...

  4. The TaifunPlayer cannot play from the path /scard/... but only from these paths:
    /storage/emulated/0/... (absolute path) or
    file:///storage/emulated/0/... (full path).

  5. In order for the SoundRecorder component to also work on devices with Android < 11, WRITE permission must be declared in the Manifest and should then be requested automatically. Both is not the case.

  6. If WRITE was declared in the Manifest on Android < 11 (by enabling WritePermission in the Designer in the File component), it will not be requested automatically. This has to be done manually.

As I said, these are not all but the most important things to consider. If anyone notices any other discrepancies / bugs, please post them here. Test with Companion & APK.

recPlaySoundPath.aia (36.1 KB)

To make it short, there are ways to avoid these problems, as I have shown.
However, I would recommend the following:
If the app is only to be created for Android, use a wavRecoder instead of the SoundRecorder. Firstly, this produces a far better sound quality and secondly avoids the storage permissions problems (especially on Android 11+). But if you want to stick with the SoundRecoder component, I generally recommend saving the recording with the .mp3 extension, regardless of the fact that the audio format is still a 3gp (container) format. For the player component, it's best to always use a full path. If you want to avoid the storage permission issue with the Player component on Android 11+, use the TaifunPlayer from @Taifun.