0

I want to make a music player that can play all music on my memory card. I use this code for play a music, but i can't play music from memory card, only in raw folder.

MediaPlayer mp = MediaPlayer.create(this, R.id.raw.audio.mp3)

what I should do, so i can play music from SD card ?

  • Possible duplicate of https://stackoverflow.com/questions/19208078/playing-music-from-sd-card-works-on-emulator-but-not-on-phone. – Ellen Spertus Jun 26 '17 at 00:49

2 Answers2

1

You'll want to do something like this

    Uri song = Uri.parse(location-of-song); //location-of-song is where the music is on the sd card
    mPlayer = new MediaPlayer();
    mPlayer.setDataSource(getApplicationContext(), song);
    mPlayer.start();
Pam
  • 78
  • 7
0

Use the version of create that takes a URI, and provide a URI to the local file you want to play.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127