【发布时间】:2017-05-12 04:49:56
【问题描述】:
我想实现一个简单的媒体播放器。如何从 android 的内部存储中检索 Mp3 歌曲的完整路径。
【问题讨论】:
-
你有什么努力吗?
标签: android
我想实现一个简单的媒体播放器。如何从 android 的内部存储中检索 Mp3 歌曲的完整路径。
【问题讨论】:
标签: android
mpintro = MediaPlayer.create(this, Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/Music/intro.mp3"));
mpintro.setLooping(true);
mpintro.start();
【讨论】:
如果您有任何问题,请先搜索。努力你会发现的... 这是一个链接试试吧Get Mp3 from SD card
【讨论】:
试试这个检查文件是否存在
public static String rootPath = Environment.getExternalStorageDirectory() + "/YourDirectory/";
File file = new File(Environment.getExternalStorageDirectory()
+ "/YourDirectoryFolder/Audio/" + NmaeofFile + "/");
if (!file.exists())
return false;
else{
//Do your work here
}
然后只需启动媒体播放器
player.setDataSource(rootPath);//rootpath is the path of your file
player.prepare();
player.start();
【讨论】: