-1

This is the previous post.
About mp3 player And the picture below is my A.mp3 path I find in my phone. ` screenshot

  mediaPlayer.setDataSource("/storage/sdcard1/A.mp3") 

  File file =new   File(Environment.getExternalStorageDirectory(),"A.mp3");
  mediaPlayer.setDataSource(file.getPath());

There are two paths above..According the picture,it should be the first one,but it does not work.

I push A.mp3 into the internal storage,and play is ok.

  mediaPlayer.setDataSource("/system/A.mp3");   
Community
  • 1
  • 1
vanke xu
  • 109
  • 1
  • 8
  • I've try 4 or 5 paths.But you can see the picture,/storage/sdcard1/ seems to the right one,it did not work . – vanke xu Jun 21 '15 at 16:17

3 Answers3

1

enter image description here

I finally find that the two files got different permission.I don't know what do those "wrdrrwrwrwrw*****" mean.So I need to search it .

vanke xu
  • 109
  • 1
  • 8
  • I did not put permissions in my manifest,but I can play A,mp3 when the path is "/storage/A.mp3" – vanke xu Jun 22 '15 at 15:28
  • Look at what files?I have two sdcard dir.On the picture above you can see sdcard0 and sdcard1.I don't know what's different – vanke xu Jun 22 '15 at 15:42
  • The sdcard1's directories are what I can see directly from my computer – vanke xu Jun 22 '15 at 15:46
  • And I use adb shell to see the sdcard0's list.There are some floders that sdcard1 also have. – vanke xu Jun 22 '15 at 15:48
  • What kind of chat tool do you use..I got some strange problems to ask..and I need to send picture to you..But it's a little inconvenient here. – vanke xu Jun 23 '15 at 02:09
1
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

This permission was forgotten.Now is ok

vanke xu
  • 109
  • 1
  • 8
0

Firstly- Check that the SD card is mounted and readable.

if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED));

or

if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY));

From your question here: You are using:

File file =new   File(Environment.getExternalStorageDirectory(),"A.mp3");
mediaPlayer.setDataSource(file.getPath());

and have tried:

mediaPlayer.setDataSource("/storage/sdcard1/A.mp3")

Then try:

Edit: add in Music folder.

mediaPlayer.setDataSource("/sdcard1/Music/A.mp3");

Also: this http://www.bogotobogo.com/Android/android24Media.php#SDCard is an interesting link. So you can explore you files in Android Studio.

Community
  • 1
  • 1