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

修改合并mp3文件规则

parent 415761c3
...@@ -698,8 +698,8 @@ public class MainWindow { ...@@ -698,8 +698,8 @@ public class MainWindow {
} }
audioList.add(people+"kk.mp3"); audioList.add(people+"kk.mp3");
String url = SpliceMp3Util.heBingMp3(audioList); // String url = SpliceMp3Util.heBingMp3(audioList);
// String url = AddMp3Util.mergeMp3s(audioList); String url = AddMp3Util.mergeMp3s(audioList);
if(url != null){ if(url != null){
if(speaker.equals("en")){ if(speaker.equals("en")){
...@@ -849,8 +849,8 @@ public class MainWindow { ...@@ -849,8 +849,8 @@ public class MainWindow {
} }
audioList.add(people+"kk.mp3"); audioList.add(people+"kk.mp3");
String url = SpliceMp3Util.heBingMp3(audioList); // String url = SpliceMp3Util.heBingMp3(audioList);
// String url = AddMp3Util.mergeMp3s(audioList); String url = AddMp3Util.mergeMp3s(audioList);
if(url != null){ if(url != null){
if(english){ if(english){
......
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
public class AddMp3Util { 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/"; String outputPath = "/tmp/";
if(System.getProperty("os.name").startsWith("Windows")){ //windows电脑测试路径 if(System.getProperty("os.name").startsWith("Windows")){ //windows电脑测试路径
outputPath= "F:\\\\"; outputPath= "F:\\\\";
...@@ -28,21 +28,22 @@ public class AddMp3Util { ...@@ -28,21 +28,22 @@ public class AddMp3Util {
file.delete(); file.delete();
} }
FileOutputStream fos = new FileOutputStream(outputPath+"new.mp3"); FileOutputStream fos = new FileOutputStream(outputPath+"new.mp3");
byte[] buffer = new byte[4096];
int length;
for (String inputPath : inputPaths) { for (String inputPath : inputPaths) {
ClassLoader classLoader = AddMp3Util.class.getClassLoader(); ClassLoader classLoader = AddMp3Util.class.getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(inputPath); InputStream inputStream = classLoader.getResourceAsStream(inputPath);
String fileName = inputPath.substring(inputPath.lastIndexOf("/")+1);
File nowFile = new File(outputPath+fileName); while ((length = inputStream.read(buffer)) > 0) {
//转换 fos.write(buffer, 0, length);
FileUtils.copyInputStreamToFile(inputStream, nowFile); }
Mp3File mp3 = new Mp3File(nowFile); inputStream.close();
byte[] buffer = mp3.getCustomTag();
fos.write(buffer);
mp3.removeCustomTag();
fos.close();
} }
fos.close();
return outputPath; 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