3
我有產生許多.mp3文件,我需要將其合併到關於電子MP3文件的,我試試這個代碼:合併.mp3文件合併成一個文件.MP3的Android
FileInputStream fist = null;
try {
fist = new FileInputStream("/mnt/sdcard/Flash Library/Resources/sound1.mp3");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
FileInputStream fist2 = null;
try {
fist2 = new FileInputStream("/mnt/sdcard/Flash Library/Resources/sound2.mp3");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
File dir = new File ("/mnt/sdcard/Flash Library/dir1");
dir.mkdirs();
SequenceInputStream sistream = new SequenceInputStream(fist, fist2);
FileOutputStream fostream = null;
try {
fostream = new FileOutputStream("/mnt/sdcard/Flash Library/dir1/output.mp3");
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int temp;
try {
while((temp = sistream.read()) != -1)
{
Toast.makeText(ctx.getActivity(), sistream.toString(), Toast.LENGTH_SHORT).show();
// System.out.print((char) temp); // to print at DOS prompt
fostream.write(temp); // to write to file
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fostream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
sistream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fist.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fist2.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
首先,它會生成文件(output.mp3)只有第一個mp3數據,第二個不會添加到輸出,其次我需要合併很多mp3文件不只是兩個? 我搜索合並MP3文件和上面的例子中推薦的所有。 有沒有解決我的問題的方法?
你有什麼問題@Sameer H.伊布拉? – GrIsHu
@GrIsHu:我需要一個將多個.mp3文件合併到一個文件中的庫? –
如果您發現解決方案,請告訴我,我也有同樣的問題 –