App does not run sdcard files

Hi guys. Today I have a problem and I couldn’t find a solution here in the topics. I put together an app that loads all .mp3 files and plays randomly. I have mp3 files on both my phone and sdcard. I made a label that tells me the name of the mp3 that is playing and the storage location.
When the mp3 is on the phone, its name appears on the label and plays normally. The problem is when the mp3 is on the sdcard. The label sets the name correctly but does not play the mp3. It gives an error message 2101. The file was not found. Can someone help me with this problem please?

INTERNAL and SD CARD location is not same try to give SD card location to get MP3 files or use filetools extension (If it works )

I’ve already done this through the global list variable “ListaVolumes”. In the block “ReceberMusica” I add the text “file: //” with the index that is 1, thus selecting the SDcard. In the “AfterFilesListAsync” block I already select the internal storage using index 2.

It seems that you forgot to add “file://” to the list item 2. Or else it will treat as a relative path, which will be /storage/emulated/0/storage/emulated/0
See here for more: App Inventor Extensions: File | Pura Vida Apps

List 2 does not need to add “file: //” because the kodular will do exactly as you said. And it works that way. It’s like saying that the app has root access, understand?

My problem is actually accessing the SDcard. The app finds the file but does not run the player.

By root access you mean superuser? Then no.
Anyways,

Error code reference: Error codes - and what it means

In your case, the player doesn’t doesn’t find the file. I’m not sure why tho.

I mentioned the term root because it is written like that in the extension documentation. Not a super user. It finds the file name, but the player does not run. It is.

this does not make sense


read the documentation about how to use the blocks, see also the screenshot by @WatermelonIce
Unbenannt2
Taifun

In my global ListaVolumes variable, I receive two values. It is a list that receives the available stores as shown in my blocks in first post. The part that you circled in blue causes the directory to be configured for the 2 item in the list mentioned. And in this case that 2 is the internal storage. And I repeat that this part is working. The problem is that the player does not play the selected file when it is on the sdcard.

I read the documentation a lot before coming, but the documentation is a little vague and that’s why I came to clear up the doubts that I can’t understand with the documentation.

can you provide an example path you are trying to use with the player component?
Taifun

Try this APK:

It should work on all Android versions and on all devices.
You can pick and play mp3 files from every path of the external storage including an external (removable, micro) SD card and display the corresponding paths.

Let us know if it works for you (btw, what’s your device / Android version?).

@Taifun, I didn’t understand what you asked for. Could I post the apk for you to understand what’s going on?

@bodymindpower, This apk worked, but only through manual selection. Can you pass the .aia so I can study it?

My android is version 9.

What does that mean "only through manual selection?

It means that I need to go to the folder where the mp3 is and select what I want. I need to tell your app which folder and which way it can play the song.

What I intend to do is make this process automatic, without user intervention. If you can give me the .aia of this apk and if it is not wrong I ask for it I would be very grateful.

Show your blocks where you set the path for the Player.
I’ll show you how to correct it.

Ok.

Connect your device to Companion and make a right mouse click → Do it on this block:

and post the result.

Here it is, as you asked.

But I just realized something. When building the list, the extension is changing the name of the store. For example … my device’s external storage is this … “/ storage / 50F0-1611 /”. The internal storage would be this … “/ storage / emulated / 0”. And the variable “global Musica”, is setting the path for all items as “/storage/emulated/0/myfile.mp3”. so I think the error is here. It helps me to understand if this extension is configured correctly.

The result for the

  1. external (removable) SD card should look like this:

grafik

  1. for the root directory of the external storage:

/storage/emulated/0/music-1.mp3

Here are the blocks to get the correct paths: