我想录制语音,并混合mp3文件 但它找不到文件
我通过uses-permission android添加权限:name =“android.permission.WRITE_EXTERNAL_STORAGE”。
这是我的代码
File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+ File.separator + Global.gContext.getResources().getString(R.string.PATH)+ File.separator + "Luyin");
if(!f.exists()){
f.mkdir();
}
String voiceName = f + File.separator;
String sound = Global.UserNumber+"-"+System.nanoTime()+"";
List<String> soundList = new ArrayList<String>();
private void stop() {
mRecorder.stop();
heBingMp3();
File f = new File(voiceName+sound+".mp3");
if(!f.exists()){
Global.show("请先录制声音");
return;
}
wancheng = true;
alertDialog.setMessage("正在合成,请稍后……");
alertDialog.show();
new DecodeAudioTask(voiceName+sound+".mp3").execute();
}
public void heBingMp3(){
File f=new File(voiceName+sound+".mp3");
for(int i=0;i<soundList.size();i++){
try {
File file=new File(soundList.get(i));
FileInputStream in=new FileInputStream(file);
FileOutputStream out=new FileOutputStream(f,true);
byte bs[]=new byte[1024*4];
int len=0;
while((len=in.read(bs))!=-1){
out.write(bs,0,len);
}
in.close();
out.close();
file.delete();
}catch (Exception e){
e.printStackTrace();
}
}
}
try {
mRecorder = new MP3Recorder(new
File(Environment.getExternalStorageDirectory(),voiceName+ File.separator+"temp"+
File.separator + sound + soundNum+".mp3"));
mRecorder.start();
} catch (IOException e) {
e.printStackTrace();
}
soundList.add(voiceName +文件分割符+ “TEMP” +文件分割符+声音+ soundNum +”熔点 3" );