Upravil jsem metodu choose_song()
public void choose_song() {
number = -1;
new javafx.embed.swing.JFXPanel();
JFileChooser file_chooser = new JFileChooser("C:\\");
file_chooser.setFileFilter(new javax.swing.filechooser.FileNameExtensionFilter("Music", "mp3", "wav", "flac"));
file_chooser.setMultiSelectionEnabled(true);
file_chooser.setControlButtonsAreShown(false);
file_chooser.setCurrentDirectory(new File("C:\\"));
file_chooser.showOpenDialog(null);
LIST_FILES.addAll(java.util.Arrays.asList(file_chooser.getSelectedFiles()));
int count = LIST_FILES.size();
Decoder decoder = new Decoder();
String new_file_path;
for (int i = 0; i < count; i++) {
try {
if (LIST_FILES.get(i).getName().endsWith("flac")) {
new_file_path = LIST_FILES.get(i).getAbsolutePath().replace("flac","wav");
decoder.decode(LIST_FILES.get(i).getAbsolutePath(), new_file_path);
LIST_FILES.set(i, new File(new_file_path));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if (LIST_FILES.size() > 0) {
java.util.Collections.reverse(LIST_FILES);
play();
}
}
Jenže vždycky to vyhodí chybu java.io.IOException: STREAM_DECODER_UNPARSEABLE_STREAM...
Poněvadž soubor wav se sice vytvoří, ale nejde přehrát a má velikost pár KB. (původní soubor má pár desítek MB)
PS. Soubor Decoder.java jsem nijak neměnil, pouze jsem smazal metodu main().