Android Question how to get a file path? i need send to a library . this file i have put in DirAssets.

hears

Active Member
Licensed User
Longtime User
how to get a file path? i need send to a library . this file i have put in DirAssets.
 

drgottjr

Expert
Licensed User
Longtime User
i've used the steps shown in the link referenced by lucams above. works fine. it pre-dates the .aar approach (i don't think .aar existed at that point).
 
Upvote 0

hears

Active Member
Licensed User
Longtime User
Best way to include assets files is by creating an AAR file that is referenced from your library and it includes an assets folder with the files. AAR file = zip file.
i mean i need get this file link in sring mode , the libary is a video player .

this libary is working with URL now ,but i donot know how to pass local media path into it.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you need a function/method in your library that accepts parameter from the app, and you just call it from the app, passing that parameter. how do you set the player in motion anyway? did you write a wrapper? or are you using some .jar you found? if you wrote a wrapper, you add the method. if it's an external .jar, it needs to have such a public method in place already, and you tap into it with a javaobject.runmethod() call
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
you can't modify the method that takes a url? eg:
B4X:
' (you'd need java, of course;).  this is pseudo b4a)
if string starts with "http" or "https" or "rtmp" or "whatever..." then
    play url
else
    play local file
end if

or are you saying, you don't know how to play a local file even if you had its name and location? b4a has had several media players that stream and play locally. not sure what your library does
 
Upvote 0

hears

Active Member
Licensed User
Longtime User
you can't modify the method that takes a url? eg:
B4X:
' (you'd need java, of course;).  this is pseudo b4a)
if string starts with "http" or "https" or "rtmp" or "whatever..." then
    play url
else
    play local file
end if

or are you saying, you don't know how to play a local file even if you had its name and location? b4a has had several media players that stream and play locally. not sure what your library does
thanks for reply.
this library can play and record video send into it, just need the URL or the file path. now don't know how to get file path... in window it is always like "file://111/111.mp4" ,in Android it is different i think.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
android works something like this: file:///android_asset/whatever.mp4 sometimes, with 2 //'s seems to work. but there is a problem with dir.asset: the files are stored compressed. when you load a file from dir.assets in b4a, b4a unzips it automatically. i don't think passing its name is going to unzip it, and i don't think your player will know what to do if it gets a compressed file. you might have to add an unzip function to your library.

or you could copy the file to dir.internal first and pass it from there (it's unzipped before the copy). in that case the local link needs to be different.

i don't believe file:///android_dirinternal works. so what you will probably have to do is assign file.dirinternal to a string to get the real path. then you can do:
dim realpath as string = file.dirinternal
and pass the real path: file:///real_path/whatever.mp4. if you log file.dirinternal, you can see the actual path. (and don't be surprised if someone comments that you're not supposed to refer to file.dirinternal by what it actually resolves to. i would guess we use file.dirinternal because it could point to somewhere different whenever google feels like pointing it somewhere different. i would think assigning it to a string in this case would be safe. but if there is an approved way and somebody tells you, take note and go with it.)
 
Upvote 0
Top