我有一个MP3文件在我的Android手机,让我们这是一个xyz.mp3地方在我的SD卡。 我想通过我的应用程序进行播放。 请帮助我,我不知道这件事。
I have a mp3 file in my android mobile, lets it's a xyz.mp3 somewhere in my sdcard. I want to play it through my application. Please help me I have no idea about it.
只要您可以使用的MediaPlayer
和播放音频文件。请查看这个很好的例子中播放音频:
Simply you can use MediaPlayer
and play the audio file. Check out this nice example for playing Audio:
public void audioPlayer(String path, String fileName){
//set up MediaPlayer
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(path+File.separator+fileName);
mp.prepare();
mp.start();
} catch (Exception e) {
e.printStackTrace();
}
}