0

I know there are several questions about this, sadly none of them helps me. (or I am too stupid to apply the answer to my problem).

On my virtual phone I created the folder "Musik" inside this folder a "King.mp3" is located.

I am not able to play this mp3 via media player.

This is the crucial part of my code:

MediaPlayer mp;
mp = MediaPlayer.create(this, Uri.parse(Environment.getExternalStorageDirectory().getPath()+
                "/Musik/King.mp3"));
mp.start();

I already tried it with:

mp.setDataSource(Environment.getExternalStorageDirectory().getPath()+
                    "/Musik/King.mp3");
mp.prepare();
mp.start();

but it is still not working.

https://i.stack.imgur.com/nINGk.png

(I know there is a lot of useless stuff in the code, I just wanted to show the mp3 path (on the right).

I tried pasting the mp3 directly into the "sdcard".

i dont even care if the path would be hard coded like "/storage/sdcard/Musik" (already tried, its not working. not even with mnt/sdcard/Musik

Community
  • 1
  • 1
user3715758
  • 15
  • 2
  • 7

2 Answers2

0

Did you verify what path "Environment.getExternalStorageDirectory()" is? Maybe it is not what you expect it to be. This path doesn't necessarily always point to the external sd card location.

bracken
  • 374
  • 2
  • 3
0

Please check:

http://www.weston-fl.com/blog/?p=2988

You're probably using the wrong path o no permission. I recommend you to check the path and check if exits with File.exists() method.

fpanizza
  • 1,589
  • 1
  • 8
  • 15
  • ty. i now found out that Environment.getExternalStorageDirectory().getPath()+ "/Musik/" exists. but as soon as i add +"King.mp3" it doesnt exist. What am i gonna do about it? as you can see in the screenshot i added the mp3 files. maybe it only allows lower case letters? like king? i will try it. – user3715758 Jun 06 '14 at 17:07
  • check with monitor.bat -> File Explorer . if king.mp3 exists and also the permissions. – fpanizza Jun 06 '14 at 17:10
  • permissions is "-rwxrwx---" as it says in DDMS in eclipse. i dont know what you mean about monitor.bat, i googled it – user3715758 Jun 06 '14 at 17:17
  • maybe it helps: if i open the stock musicplayer on the emulator he finds the song. and i can also play it. – user3715758 Jun 06 '14 at 17:22