Missing sound in mp3 player

1 year ago i made a customized mp3 player and installed it on my tablet.
Yesterday I wanted to improve it with some small changes.
When I installed the new version the player had no sound.
I undid the changes and installed it again. Still no sound.
The original installation still works.
Any help is appreciated. :slight_smile:

Hello Preben

What is the file path to the sound files? If your Tablet is Android v10+, Google have introduced new security measures that limit the directories that an App can access.

The file path is: file:///storage/emulated/0/Music/name
Why does the old versions still function?
also the new version works on my phone.

Preben

are you saying, both versions work after building the app (apk file), but the new version does not work anymore using the companion app? Do you play the sounds from the assets? Starting from Android 10, the assets directory was moved to the ASD - application specific directory, which might be your issue here? Unfortunately you did not show any blocks so we only can guess... Also you forgot to mention the Android version of your device...

EDIT: it seems to be another issue... according to your path you are playing from the internal (emulated) sdcard...

Taifun

The tablet -where the new versions don't work is Android 10.
The phone -where both old and new versions work is Android 7.

Thanks for your answer. I'll read more about ASD

It would really help if you provided a screenshot of 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.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

I would like to send you the relevant blocks, but I have no idea which blocks are relevant.

the relevant blocks are setting the source of the sound and playing the sound
also a screenshot of the media section would help, so we could see the names of the sound files in the assets

you also can test another project, for example the jukebox example downloadable from here App Inventor Extensions: File | Pura Vida Apps

it does not work using the companion app, after building the app or both?

Taifun

If the sound (MP3 file) is already saved in this folder, it should work on all versions of Android (even if AI2 is targeting Android 11, Aug 2021). But the key question is where does the sound come from? How is this stored in external storage: file:///storage/emulated/0/Music/soundName.mp3?

I am not sure I understand what you mean.
The mp3 files are stored in the folder
file:///storage/emulated/0/Music and this is where I pick the files.

Is it really that hard to understand what I meant?
Where / when was the sound / music recorded and saved in this folder? So where does the source of the MP3 file come from?

How - in what way?
Post your blocks ...

Can we see your Blocks Preben? Right-mouse in the Blocks work area and select "Download Blocks as image"

Can I put Anke's question another way? How do the mp3 files get to be in the folder you have mentioned?

The music is mostly my own. Recorded and put in the folder a year ago and is still playable in the versions I didn't update. However, if I build a working version (without making any changes) it will not play any music.

There are MANY blocks, so it would be better if I could only show you the relevant blocks, but I don't know which blocks are relevant.

Ok, then it should work.

We only need to see the blocks where you

  • set the Player.Source,
  • ask for permission,
  • start the Player
  • and maybe the error (if there is one?).

This is all you need (and this are the relevant blocks):

Change the sound name to one of your (existing) file names.

Because on Android < 10 READ_EXTERNAL_STORAGE permission is requested automatically, but no longer on Android ≥ 10. (I think this is a bug).

So you must ask for this permission manually for Android 10+ devices, as I've shown in my blocks.

If AI2 targets Android 11 (Aug 2021), it will no longer be possible to save to this directory via the app. But of course you can still access files from this directory (or any other dir in the external storage), read files, play music and list files from this directory. In this respect, READ_EXTERNAL_STORAGE should actually still be requested automatically also on Androd 10+.

I think @ewpatton can say something about it.

The user downloads the music files to a folder of his choice using the device's file manager.
First time the app runs the user is asked to find the folder and click on one of the files.
This establishes the folder in which the files are kept.
The playlist is saved to TinyDB.
I am sure all of this could have been made much easier and simple, but then again it has worked flawlessly for me till now :slight_smile: