Android Question ExternalStorage. How to play mp3 from microSD?

Serjio_m

New Member
Hi. I want to play mp3 from microSD, but how to get full filepath to use it with MediaPlayer(Dir, File) ?

I try

B4X:
            Private dir As String = "/storage/191E-0A05/music2/"
            Private fil As String = "02-4_strings-diving.mp3"
            Log(dir & fil)
            mp.Load(dir,fil)
            mp.Play

but..


B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Can use persistant uri!
/storage/191E-0A05/music2/02-4_strings-diving.mp3
main_listview1_itemclick (java line: 530)
java.io.FileNotFoundException: /storage/191E-0A05/music2/02-4_strings-diving.mp3 (Permission denied)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:231)
    at java.io.FileInputStream.<init>(FileInputStream.java:165)
    at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1186)
    at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1164)
    at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1131)
    at anywheresoftware.b4a.objects.MediaPlayerWrapper.loadAfterReset(MediaPlayerWrapper.java:99)
    at anywheresoftware.b4a.objects.MediaPlayerWrapper.Load(MediaPlayerWrapper.java:66)
    at b4a.example3.main._listview1_itemclick(main.java:530)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA$1.run(BA.java:352)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 
Top