Commit e374a09e authored by 周亚武's avatar 周亚武

修改合并mp3文件规则

parent 415761c3
No related merge requests found
......@@ -698,8 +698,8 @@ public class MainWindow {
}
audioList.add(people+"kk.mp3");
String url = SpliceMp3Util.heBingMp3(audioList);
// String url = AddMp3Util.mergeMp3s(audioList);
// String url = SpliceMp3Util.heBingMp3(audioList);
String url = AddMp3Util.mergeMp3s(audioList);
if(url != null){
if(speaker.equals("en")){
......@@ -849,8 +849,8 @@ public class MainWindow {
}
audioList.add(people+"kk.mp3");
String url = SpliceMp3Util.heBingMp3(audioList);
// String url = AddMp3Util.mergeMp3s(audioList);
// String url = SpliceMp3Util.heBingMp3(audioList);
String url = AddMp3Util.mergeMp3s(audioList);
if(url != null){
if(english){
......
......@@ -18,7 +18,7 @@ import java.util.List;
public class AddMp3Util {
public static String mergeMp3s( List<String> inputPaths) throws IOException, InvalidDataException, UnsupportedTagException {
public static String mergeMp3s( List<String> inputPaths) throws IOException{
String outputPath = "/tmp/";
if(System.getProperty("os.name").startsWith("Windows")){ //windows电脑测试路径
outputPath= "F:\\\\";
......@@ -28,21 +28,22 @@ public class AddMp3Util {
file.delete();
}
FileOutputStream fos = new FileOutputStream(outputPath+"new.mp3");
byte[] buffer = new byte[4096];
int length;
for (String inputPath : inputPaths) {
ClassLoader classLoader = AddMp3Util.class.getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(inputPath);
String fileName = inputPath.substring(inputPath.lastIndexOf("/")+1);
File nowFile = new File(outputPath+fileName);
//转换
FileUtils.copyInputStreamToFile(inputStream, nowFile);
Mp3File mp3 = new Mp3File(nowFile);
byte[] buffer = mp3.getCustomTag();
fos.write(buffer);
mp3.removeCustomTag();
fos.close();
while ((length = inputStream.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
inputStream.close();
}
fos.close();
return outputPath;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment