我有一个中文mp3文件,我想和MediaPlayer
一起玩,但是没有播放。我的代码是这样的:
AssetFileDescriptor afd=getAssets().openFd("music/formes/ZH/三角形.mp3");
mySound = new MediaPlayer();
mySound.setDataSource(afd.getFileDescriptor(),
afd.getStartOffset(), afd.getLength());
mySound.prepare();
mySound.start();
logcat输出是:
java.io.FileNotFoundException: music/formes/ZH/三角形.mp3
答案 0 :(得分:0)
ArrayList al = new ArrayList();
String[] fileNames =getAssets().list("music/formes/ZH/");
for(String name:fileNames){
al.add(name);
System.out.println(name);
}
AssetFileDescriptor descriptor = getAssets().openFd("music/formes/ZH/" + al[0]);
播放
MediaPlayer player = new MediaPlayer();
long start = descriptor.getStartOffset();
long end = descriptor.getLength();
player.setDataSource(this.descriptor.getFileDescriptor(), start, end);
player.prepare();
player.setVolume(1.0f, 1.0f);
player.start()