App crashes after trying to play several files at the same time

I have not found in the forum anything similar to what happens to me.

I use the extension of @Taifun File

I get the list of files in a folder.
For each element of the list I get the path.
That path I put it to the source player.

In the companion it works perfect and the music of the file in the folder is played.

Now I create the apk and test it on the phone and the app closes.

@Taifun you know what could be happening?

Is there any other way to get the path of a file knowing only its name?

My Blocks:

Your topic title asks for a different question,

This sentence means you are reporting an issue.

And this sentence says another different question.

Can you exactly say what you want to achieve? If you want to get a full file list without knowing its directory, just enable includeSubdirectories and set directoryName to “/” or “/storage/emulated/0/”

Also it is normal to your app crashing because you are trying to play a lot of files at the same time with one component since loops has no any additional delay.

see the jukebox example here App Inventor Extensions: File | Pura Vida Apps to find out, how to play several files one by one
Taifun

1 Like

Yes @yusufcihan I’m sorry. That’s two questions. And this was just out of curiosity in case the above doesn’t work.

Thank you @Taifun . When I have a moment I’ll try it!

1 Like

Are you getting an error message when the app closes / crashes?

No. The app closes immediately without giving any error message.

Is permission granted

this happens because and as @yusufcihan already said

see this how to do it

Taifun

1 Like

But inside Foreach there is an IF that is only true when the file name coincides with the item in the list. The names are long and without spaces and there are no two equal, so it should reproduce only one. In fact in the companion only one is reproduced and everything works perfect. It is when I compile the apk that the application closes itself…

So it does not seem to be a permission issue. Show all relevant blocks or the AIA.

Here is the solution:

See also in the Taifun File extension description
https://puravidaapps.com/file.php:

Since you don’t have permission to READ from external storage, the (not shown) error is:
java.lang.NullPointerException: Attempt to get lenght of null array at com.puravidaapps.TaifunFile.getList(TaifunFile.java.xxx)
But this error message is not displayed because the app crashes immediately.

So, ask for READ permission before:

Correction, it is.

Thank you very much!
Just last night I was doing tests. I put the exoplayer and when I play music, the player asks for permissions…

Boban was right hehe!

Thank you all very much for answering!

1 Like

Since it worked on companion but not as apk, that was my only conclusion

Yes, but the question should be correct here:
Was the permission READ_EXTERNAL_STORAGE requested before TaifunFile.FileListAsync is triggered and then also granted?
This is obviously not the case, as I have shown.

No, the correct question should have been: Did you ask for READ permission before TaifunFile is triggered and then also have granted it.

It’s true, you’re right.
I had no idea it could be the permissions.
Thank you very much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.