简体   繁体   中英

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();
}

You should add permission to your manifest file

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM