Daniil Andreev
Daniil Andreev

Reputation: 41

How to play audio by absolute path? - android

I save audio to internal storage and get absolute path. Looks like this: /data/user/0/com.example.example/files/example/605f7c482b0cb60c71832080.mp3. When I put this path into mediaplayer it doesn't work. How can I play audio using this path?

Edit: Code snippet:

audioUrl = "/data/user/0/com.example.example/files/example/605f7c482b0cb60c71832080.mp3";
try {
   mPlayer.setDataSource(getContext(), Uri.parse(audioUrl));
   mPlayer.prepareAsync();
} catch (IOException e) {
   e.printStackTrace();
}

Upvotes: 1

Views: 390

Answers (1)

Civan Korkmaz
Civan Korkmaz

Reputation: 104

You should add permission to your manifest file

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Upvotes: 1

Related Questions