How to play sound from sdcard with mediaplayer

DOM85

Active Member
Licensed User
Longtime User
Hi,

I have to play sounds as external files located in sdcard.
Is it possible with mediaplayer? (I tried to replace "file.dirassets" parameter with my sdcard directory, but dont' work).
Thanks for help.
 

margret

Well-Known Member
Licensed User
Longtime User
Play sounds on SDcard

You should use the File.DirRootExternal and then the path/filename to play the file. File.DirRootExternal set permissions to the SDcard and returns "/mnt/sdcard". Add your path like:

MyAudio.Load(File.DirRootExternal & "/myfiles/audio", "mysound.mp3" )

Hope this helps.

UPDATE: I just tried this myself and I am getting NullPointer errors on the load command. I am looking into this to see if I can find out why. I'll post what I find.

Margret
 
Last edited:
Upvote 0

DOM85

Active Member
Licensed User
Longtime User
Play sounds on SDcard

You should use the File.DirRootExternal and then the path/filename to play the file. File.DirRootExternal set permissions to the SDcard and returns "/mnt/sdcard". Add your path like:

MyAudio.Load(File.DirRootExternal & "/myfiles/audio", "mysound.mp3" )

Hope this helps.

UPDATE: I just tried this myself and I am getting NullPointer errors on the load command. I am looking into this to see if I can find out why. I'll post what I find.

Margret


Thank you Margret !!
I used your information like that and it works fine :
MyAudio.Load(File.DirRootExternal,"mydir/mysound.mp3")
Thank you very much!!!

But where did you find this parameter (File.DirRootExternal). I have such documentation problem with all the libraries. Thx.
 
Last edited:
Upvote 0
Top