Android Question Media player load file from phone question

edm68

Member
Licensed User
Hello,

I'm trying to use Erel's example from here: http://www.b4x.com/android/forum/threads/mediaplayer-tutorial.6591/

I'm trying to play a mp3 on phone already, not one included on files tab(I saw her standing there).
I'm not sure what I'm doing wrong, tried a few options, not sure how to insert the file I want to play.
Only thing I've changed is in Sub Activity_Create(FirstTime As Boolean)

B4X:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     MediaPlayer1.Initialize( )
     'MediaPlayer1.Load(File.DirAssets, "IsawHerStandingThere.mid")     'from Erel's example
   
'     /sdcard/Music/Joe Walsh/There Goes the Neighborhood/03 Down on the Farm.mp3     'file loc on phone that i try to play

   'my first attempt To load from phone sd card
'       MediaPlayer1.Load(File.DirDefaultExternal,/Music/Joe Walsh/There Goes the Neighborhood/03 Down on the Farm.mp3)
     'didn't compile - undeclared var Music

   'my second attempt
     MediaPlayer1.Load(File.DirDefaultExternal,"Down on the Farm.mp3")
'     compile okay but when run
'     gives result of:
'     java.io.IOException: Prepare failed.:
'     status=0x1

     timer1.Initialize("timer1", 1000)
   End If
   Activity.LoadLayout("1")
   Looping_CheckedChange(Looping.Checked) 'set the default value
End Sub
Just realized after previewing this do I need to move somewhere other than 'Sub Activity_Create(FirstTime As Boolean)'

Thanks for any help
 

edm68

Member
Licensed User
I think when I bought the phone I'm testing this on I transferred music thru USB cable from PC to phone.
I also have added since original question:
B4X:
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
Not sure if it was needed but the same result.
Thanks.
 
Top