Android Question path to audio files inside the program

AlexDan

Member
Dim i As Intent ' output Audio from internal folder "Files"

Dim Vpath = File.DirRootExternal,"Regym2.mp3"
i.Initialize(i.ACTION_VIEW,Vpath)

i.setType("*/*")
StartActivity(i)

--------------------
Audio output from internal folder fails
what is my mistake?
 

AlexDan

Member
I open audio files from the phone folder "Dowload" so
Dim i As Intent
Dim Vpath = "/sdcard/Download/Vitafon/audio/Regym2.mp3" As String
i.Initialize(i.ACTION_VIEW,Vpath)
'i.SetType("Audio/*")
i.setType("*/*")
StartActivity(i)

I open audio files from the phone folder "Dowload" so
But from the internal folder "Files" my program does not work, I can not correctly register the path.

What needs to be changed in this line?
??? Dim Vpath = "/sdcard/Download/Vitafon/audio/Regym2.mp3" As String ?????

Please tell me as a beginner in programming
 
Upvote 0

AlexDan

Member
You need a link to the files added in the "Files" tab of the program itself

What needs to be changed in this line?
??? Dim Vpath = "Files/Regym2.mp3" As String ?????

Please tell me as a beginner in programming
 
Upvote 0

AlexDan

Member
Thanks for the help, but this is not the case. I need an example of using files that are not in external folders, but in the APK itself.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I need an example of using files that are not in external folders, but in the APK itself.
Solution: Use FileProvider!
 
Last edited:
Upvote 0

Midimaster

Active Member
Licensed User
As I understand your question, you want to start a MP3, which is in your File.DirAssets.
So you first have to copy the file to a directory, where also the related Audio Intent App can find/load it.


This is exactly one SUB of the sample Erel shows in his link to FileProvider:
B4X:
Sub btnViewImage_Click
    Dim FileName As String = "b4a.png"
    File.Copy(File.DirAssets, FileName, Starter.Provider.SharedFolder, FileName)
    Dim in As Intent
    in.Initialize(in.ACTION_VIEW, "")
    Starter.Provider.SetFileUriAsIntentData(in, FileName)
    'Type must be set after calling SetFileUriAsIntentData
    in.SetType("image/*")
    StartActivity(in)
End Sub

I would think, that for audio it is the same procedure....
 
Upvote 0
Top