There was a problem with trying to play music with MediaPlayer today,
Mp.setdatasource (This, Uri.parse ("/sdcard/music/adele.mp3"));
This line of code for MediaPlayer set to play the music address, code execution to this line will always error, error message is: Setdatasource failed
Suddenly on the failed, why will not say Ah, on the Internet to check some information after a variety of attempts to use, and then use one of the overloaded method Setdatasource (filedescription filedescription) Finally, a decent error message is given: Open failed:eacces (Permission denied)
With this after a good solution, so with hundred poison search, in this article (portal) found the answer: because I want to play the SD card music, so I need to write the SD card permissions (why do I need to write permission to play music? ), you need to add the following permissions to the manifest file:
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE" ></uses-permission>
Remember to remember ~
Android MediaPlayer Setdatasource failed