How can I import .mp3 files onto a list automatically?

It does work for me. But what did you put for the player1.source?
Because this is not working:
Captura de pantalla 2021-08-09 a la(s) 17.57.34
I don´t know why in some audios it does play but in other ones it returns an error even though they are the same path...

Note:
My app lists all MP3s from the removable SD card if available (from all sub-folders) or from the built-in SD card (also including all sub-folders).

I was trying to add the items from the file list onto the global list_uri but whenever I do it it crashes my app.
Captura de pantalla 2021-08-11 a la(s) 10.40.10

Perhaps because your for each item... is still trying to fill the ListView when you call the second add items to list
BlockOrder
as a guess.

Hmmm, might be but, when I add the set list_uri to file list and add the UriToPath, it doesn´t crash but now the problem is that it says The operation split cannot accept the arguments: , [nothing], ["/"] wich I think is because of the initialize local list block..


But it does play the audio with no problem..

App Inventor processes commands asynchronously, so one command must execute before the next executes. See The model of event processing in App Inventor by Franklyn_A_Turbak

Populating the ListView before all the data is available does not make a lot of sense.
Adding an item based on an ActivityStarter call can cause timing issues.

I read the article, it was a bit confusing for me.. But are you telling me that the error is because of time delay?

Perhaps. I can't test your code. Confusing? the article basically says one process must finish before the next process begins. App Inventor is not multi-threaded.

Using an extension with an ActivityStarter link is suspicious. Put a dummy value in place of the KIO4_Base641 and see if the code block runs. Using the AS causes your app to temporarily yield control to an external process. And it may take a few seconds.

However setting the ListView before the for each loop is probably dangerous . Move the Block out of the loop and test with your KIO4 extension and see if running it independently works.

what do you mean by that? are you telling me to add any block?

Sure. Add any Block. You could use a Text Block with 'testing' in it and the list_uri List should contain 'testing' for as many items as there are items in fileList.

I tried like this but it crashed my app.


but when i did it like this:

it didn´t crashed my app, it onlt gave me the The operation split cannot accept the arguments: , [ nothing ], ["/"] error.
I think that the problem here is this block:
Captura de pantalla 2021-08-11 a la(s) 11.42.38

Impossible to help debug your app since you don't share all the code. Gremlins are hiding everywhere.

Here is some possible help Live Development, Testing, and Debugging Tools

Yeah that´s right so, can I share .aia file with you? So that you can see all blocks and and change them..

I realized that if I did it like this it doesn´t return an error and it doesn´t crash the app

yes, and this was the suggested solution by @SteveJG from the beginning...

Taifun

1 Like

Try my test aia: playFromSDcards2.aia (58.8 KB)

Blocks

1 Like

Thanks for sharing that, it help me with the list names :grin:

I think that my app is working now :star_struck:

Does my aia work for you?
I think so. So where is the problem?

Yes it does!

there is no problem, i just need to add the WRITE_EXTERNAL_STORAGE permission properly.