Android Question Playing MP3's file from ExternalSD

Wolodymyr

Member
Hello everyone.
Problem is to use StorageExternal to pass required Folder to play files

Before this I successfully play files from External Storage (SD card) by getting permission for whole sd _card: I add
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
in manifest and ask for permission: rp.CheckAndRequest(ServiceModule.rp.PERMISSION_READ_EXTERNAL_STORAGE)

The problem is that AudioPlayer need exact FOLDER_PATH and filename. I'm manually use "/storage/B5FD-1304/MYMP3" folder path and this works great, but prefix for this path is different for every android device and I need that user select this folder by himself. So
Select root folder:
Storage.SelectDir(False)
Wait For Storage_ExternalFolderAvailable
works great, but I cannot use it for AudioPlayer, because cannot extract folder path..
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
The problem is that AudioPlayer need exact FOLDER_PATH and filename. I'm manually use "/storage/B5FD-1304/MYMP3" folder path and this works great, but prefix for this path
This will not work on newer devices.

What is AudioPlayer?

Try with MediaPlayerStream from the Audio library.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
As a last resort you could always copy the file to internal stoarge, play it and delete it afterwards. This is what I do for my huge maps when I display them in my ScaleImagView as ScaleImageView needs random access to the file which you can't do with the ExternalStorage class.
 
Last edited:
Upvote 0

Wolodymyr

Member
This will not work on newer devices.

What is AudioPlayer?

Try with MediaPlayerStream from the Audio library.

My mistake. AudioPlayer is a MediaPlayer object

I use Android 6.0 device. May be You are right, and my "hack" with direct folder path will not work on never devices. So using External storage and MediaPlayerStream is the only possible way

Besides - it is very interesting how my favorite music player app AIMP does whatever it wants with the files on the card

Sorry for bad English
 
Upvote 0

Wolodymyr

Member

I don't think that massive files moving between internal memory and sd card is a good idea. This will degradate the health both of them. But if we kill sd card it is not disaster, but if it is a phones internal emmc..
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…