Location of files listed in the manifest file - add ressource files at runtime


#1

I have an app that plays hundreds of mp3 files. That’s why I can’t put them into the manifest.
I load them via phonegap file plugin and (see my previous post) and it works.

   reader.onload = readSuccess
   reader.readAsDataURL(fileBlob)
End Function
Function readSuccess(e)     
    Audio1.src = this.result              
    Audio1.load()
    Audio1.play()            

It loads the file as data uri b64 into the player.

data:audio/mpeg;base64,SUQzAwAAAAAfdlRDT04AAAAFAAAAKDEyKV...

BUT… it doesn’t work on some android phones!!! I have one phone, I can not play mp3 files that are handed over that way.
For example it also doesn’t play this example: https://iandevlin.com/html5/data-uri/audio.php
With that phone I can only play mp3 files that are listed in the manifest file.

THAT’S WHY I asked for the manifest folder so that I can read the mp3 from cordova.file.externalRootDirectory (external storage) and save it to somewhere inside the app (same path as files listed in the manifest) so that I can load/play the files like this:

 Function bDoor_onclick()
     Audio1.src = "mp3/doorDetour.mp3"
     Audio1.load()
     Audio1.play()  
 End Function

Any ideas?


#2

Why can’t you put hundreds of files into the manifest?

Just put the name of the folder they are in. AppStudio will pull out the filenames and put them into the manifest automatically.


#3

good point, but then I can’t deploy with phonegap. the app becomes too big


#4

I can’t believe… It is MUCH, much easier than I thought! I can directly read from “outside”:

loadPath = cordova.file.externalRootDirectory & "door.mp3"
Audio1.src = loadPath
Audio1.load()
Audio1.play()  

I don’t need to “read” the file at all!

But for all other visitors. This might be the answer for my original question:
MsgBox window.location.pathname

The following paths should be known as they are decribed all over the internet:
MsgBox cordova.file.dataDirectory

'cordova.file.dataDirectory - Persistent and private data storage within the application’s sandbox
’cordova.file.cacheDirectory - The OS may delete these files when the device runs low on storage
’cordova.file.externalApplicationStorageDirectory - Application Space On external storage
’cordova.file.externalDataDirectory - App-specific data files On external storage
’cordova.file.externalCacheDirectory - Application cache On external storage
’cordova.file.externalRootDirectory - External storage (SD card) root


SDcard SQL saving
#5

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