Play a sound from Shared folder
/Musicon Android 11+ (but some also applies to Android < 11)
I copied an audio file (sound.ogg) from the assets into the
/Music and wanted to play it from there with the
Player component. (It doesn’t matter here how I copied it from the assets.)
/storage/emulated/0/Music/sound.ogg (absolute path).
Problems / bugs (with APK):
The sound is not played
READpermission is required here (incorrectly) and must therefore be declared in the Manifest (which is not the case).
(This should be only required if the file was not created by the app itself.)
After I added this permission to the Manifest (using my extension
DeclareReadWrite) the permission is not requested automatically.
After I did this manually, the sound is again not played (“unable to load …”)
Only after changing the absolute path to a full path (
Player.Source) it finally works.
Some bugs / problems too much for most (at least for a “normal” user), I think!
Hence my suggestion/recommendation to the Kodular team (same applies for MIT):
The easiest and best way to deal with all these permission bugs/problems (not just this problem here with the
Playercomponent) is the following (IMHO):
WRITEup to Android 10).
Remove all automatic requesting of storage permissions from all components.
Let the user decide where, when, which storage permission should/must be requested manually on which Android version.
Usually as follows: (For more details see → here )
If API < 30, request
READand / or
WRITE, else request
READ(only if the file is a media file and is not created by the app itself).
Google has overcomplicated the new Android filesystem (totally unnecessarily) so that NOBODY can avoid looking into it deeply before anyone builds apps since
Sorry if not everyone can follow me because this is really advanced stuff.