我想创建录音机的近似功能已完成,但是,我需要为此功能实现暂停和恢复功能,我需要合并我的两个音频文件,但我无法获得准确的结果。我已经使用了序列输入流,但是这个只合并第一个文件这是我的代码
FileInputStream fis1 = new FileInputStream(mergeFile.get(0));
@SuppressWarnings("resource")
FileInputStream fis2 = new FileInputStream(mergeFile.get(1));
Vector<FileInputStream> v = new Vector<FileInputStream>();
v.add(fis1);
v.add(fis2);
Enumeration<FileInputStream> e = v.elements();
String filepath = Environment.getExternalStorageDirectory()
.getPath();
File file = new File(filepath, "Test");
file.mkdir();
// InputStream inputStream1 = new FileInputStream(recording1);
// InputStream inputStream2 = new FileInputStream(recording2);
@SuppressWarnings("resource")
SequenceInputStream sistream = new SequenceInputStream(e);
FileOutputStream fostream = new FileOutputStream(file
+ "/myfile.mp3");
int temp = 0;
while ((temp = sistream.read()) != -1) {
// System.out.print( (char) temp ); // to print at DOS prompt
fostream.write(temp); // to write to file
}
fostream.close();
sistream.close();
// recording1.close();
// r/ecording2.close();
}
当我播放最终结果时,它只播放第一个文件。