media in APK file

Jim T

Member
Licensed User
Longtime User
I have a timer app with an mp3 file. Works fine and plays the mp3 if the mp3 file is manually installed on the SD card. The mp3 is in the APK file under Objects, but does not seem to get installed when I use the APK file to install the program. Either that or it is installed in the wrong spot. It needs to be in the SD root to play (I guess). Any ideas?

Thanks

Jim T
 

stevel05

Expert
Licensed User
Longtime User
When you install the APK, any files you have loaded into the IDE are available to the program under File.DirAssets.

You can load them and play them from there. If you need them anywhere else for whatever reason, you will have to copy them within the program. You can't delete them from File.DirAssets it's read only.

Steve
 
Upvote 0

Jim T

Member
Licensed User
Longtime User
Hmmm. I tried that before, and I just tried it again now. When I change the code to File.DirAssets I get a java error "file not available". Now the mp3 in question is in my project folder. It is definitely in the APK file, but it doesn't seem to install properly.

I am loading it thusly: Ding1 = SP.Load(File.DirAssets,"Ding2.mp3")

Now if I change the code to Ding1 = SP.Load(file.DirRootExternal,"Ding2.mp3") it will work fine, but I have to manually install the mp3 to the SD card.

Any idea why the File.DirAssets won't work?

thanks
Jim T
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Strange that the error is 'file not available', it implies that the file is there but can't be used for whatever reason. I would have suggested that the file system is case sensitive, but then I would have expected a 'file not found' error.

It maybe a permission problem, but I don't know enough about that to track it down. Perhaps someone else can throw some light on this one.

Steve
 
Upvote 0

Jim T

Member
Licensed User
Longtime User
Sorry, I was paraphrasing!:sign0161:

Actual error:

java.io.FileNotFoundException: ding2.mp3 Continue?

Now my actual mp3 file and my line of code use "Ding2.mp3" and the error code says "ding2.mp3" - is it mandatory to use lower case?

Jim T
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Have you added the file in the IDE? can you see it listed in the files tab on the right hand side. You need to add files here for them to be visible to File.DirAssets
 
Upvote 0

Jim T

Member
Licensed User
Longtime User
It was not showing there, but still was in the APK file. Still, I added it to the IDE files and compiled again. No change. Same error message.

Jim T
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
Try to rename your file to "ding2.mp3"?
 
Upvote 0

LittleEddie

Member
Licensed User
Longtime User
Always be case sensitive when dealing with files.

Try this
Dim mylist as list
mylist = File.ListFiles(File.DirAssets)
msgbox(mylist, "mylist")

Should give you a list of your files
 
Upvote 0

Jim T

Member
Licensed User
Longtime User
Renaming worked. The strange thing is that I started with a file named "Ding2.mp3" and used the same name in my code. I actually had to rename the file to "ding2.mp3" and change the case in my code. I have no idea where the lower case came from in the first place!

Anyway, it works now! Only with File.DirAssets, not File.DirRootExternal, but still ... it does the job!

Thanks to all!

Jim:sign0060:
 
Upvote 0
Top