Android Question When loading a file from DirAssets, name altered???

wdegler

Active Member
Licensed User
Longtime User
I wish to load files from my DirAssets directory, one of which has the name g1d302.mp3.
The code is, in part,

dim I as integer
dim FilLst as List
dim FilNam as string


FilLst.Initialize
FilLst=File.ListFiles(Dir.Assets)
For I=0 to FilLst.Size-1
FilNam=FilLst.get(I)
---------------------------

When the file (named above) is loaded, FilName has the value

g1d302.mp3.unblocked.

Why has ".unblocked" been appended? How do I avoid that?
Can someone explain this and provide a solution?
Help!



 

wdegler

Active Member
Licensed User
Longtime User
The suffix is unpacked not unblocked, right?

It is related to the virtual assets folder. You should just load the file like you load any other file:
B4X:
MediaPlayer.Load(File.DirAssets, "g1d302.mp3")

Erel:
You are right! The changed file name is "g1d302.mp3.unpacked".


I used FilLst=File.ListFiles(Dir.Assets) because the app needs to process ALL the files in File.DirAssets without prior knowledge of their names or number of files.
MediaPlayer.Load(File.DirAssets, "g1d302.mp3") requires specifying the name. Please advise.


Walter
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is always prior knowledge about the assets files as they are added before compilation.

Listing the files under File.DirAssets is problematic. I recommend you to add a text file with the file names and use it instead.

You can disable the virtual assets folder feature with the #DebuggerForceStandardAssets attribute. Still you may encounter unexpected files.
 
Upvote 0

wdegler

Active Member
Licensed User
Longtime User
There is always prior knowledge about the assets files as they are added before compilation.

Listing the files under File.DirAssets is problematic. I recommend you to add a text file with the file names and use it instead.

You can disable the virtual assets folder feature with the #DebuggerForceStandardAssets attribute. Still you may encounter unexpected files.
Erel:

Thank you for your response, Erel; this is exactly the information I need!

Walter
 
Upvote 0
Top