Android 播放内部mp3音乐
private void heartSound()
{
try {
AssetManager am = getAssets();//获得该应用的AssetManager
AssetFileDescriptor afd = am.openFd("heartsound.mp3");
mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(afd.getFileDescriptor());
mediaPlayer.prepare(); //准备
mediaPlayer.start();
}
catch (Exception e) {
e.printStackTrace();
}
}
posted on 2017-02-22 14:06 biyangqiang 阅读(303) 评论(0) 编辑 收藏 举报