mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-15 14:09:44 +00:00
exporting MP3
This commit is contained in:
@@ -555,7 +555,7 @@ public class Main {
|
||||
exfile.exportMovies(outDir.getAbsolutePath());
|
||||
exportOK = true;
|
||||
} else if (exportFormat.equals("sound")) {
|
||||
exfile.exportSounds(outDir.getAbsolutePath());
|
||||
exfile.exportSounds(outDir.getAbsolutePath(), true);
|
||||
exportOK = true;
|
||||
} else {
|
||||
exportOK = false;
|
||||
|
||||
@@ -485,11 +485,11 @@ public class SWF {
|
||||
exportMovies(outdir, tags);
|
||||
}
|
||||
|
||||
public void exportSounds(String outdir) throws IOException {
|
||||
exportSounds(outdir, tags);
|
||||
public void exportSounds(String outdir, boolean mp3) throws IOException {
|
||||
exportSounds(outdir, tags, mp3);
|
||||
}
|
||||
|
||||
public void exportSounds(String outdir, List<Tag> tags) throws IOException {
|
||||
public void exportSounds(String outdir, List<Tag> tags, boolean mp3) throws IOException {
|
||||
if (!(new File(outdir)).exists()) {
|
||||
(new File(outdir)).mkdirs();
|
||||
}
|
||||
@@ -501,25 +501,44 @@ public class SWF {
|
||||
if (t instanceof DefineSoundTag) {
|
||||
id = ((DefineSoundTag) t).soundId;
|
||||
}
|
||||
fos = new FileOutputStream(outdir + File.separator + id + ".flv");
|
||||
FLVOutputStream flv = new FLVOutputStream(fos);
|
||||
flv.writeHeader(true, false);
|
||||
if (mp3) {
|
||||
}
|
||||
|
||||
if (t instanceof DefineSoundTag) {
|
||||
DefineSoundTag st = (DefineSoundTag) t;
|
||||
flv.writeTag(new FLVTAG(0, new AUDIODATA(st.soundFormat, st.soundRate, st.soundSize, st.soundType, st.soundData)));
|
||||
if ((st.soundFormat == 2) && mp3) {
|
||||
fos = new FileOutputStream(outdir + File.separator + id + ".mp3");
|
||||
fos.write(st.soundData);
|
||||
} else {
|
||||
fos = new FileOutputStream(outdir + File.separator + id + ".flv");
|
||||
FLVOutputStream flv = new FLVOutputStream(fos);
|
||||
flv.writeHeader(true, false);
|
||||
flv.writeTag(new FLVTAG(0, new AUDIODATA(st.soundFormat, st.soundRate, st.soundSize, st.soundType, st.soundData)));
|
||||
}
|
||||
}
|
||||
if (t instanceof SoundStreamHeadTypeTag) {
|
||||
SoundStreamHeadTypeTag shead = (SoundStreamHeadTypeTag) t;
|
||||
List<SoundStreamBlockTag> blocks = new ArrayList<SoundStreamBlockTag>();
|
||||
List<Object> objs = new ArrayList<Object>(this.tags);
|
||||
populateSoundStreamBlocks(objs, t, blocks);
|
||||
int ms = (int) (1000.0f / ((float) frameRate));
|
||||
for (int b = 0; b < blocks.size(); b++) {
|
||||
byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION);
|
||||
if (shead.getSoundFormat() == 2) { //MP3
|
||||
data = Arrays.copyOfRange(data, 4, data.length);
|
||||
if ((shead.getSoundFormat() == 2) && mp3) {
|
||||
fos = new FileOutputStream(outdir + File.separator + id + ".mp3");
|
||||
for (int b = 0; b < blocks.size(); b++) {
|
||||
fos.write(blocks.get(b).getData(SWF.DEFAULT_VERSION));
|
||||
}
|
||||
} else {
|
||||
fos = new FileOutputStream(outdir + File.separator + id + ".flv");
|
||||
FLVOutputStream flv = new FLVOutputStream(fos);
|
||||
flv.writeHeader(true, false);
|
||||
|
||||
int ms = (int) (1000.0f / ((float) frameRate));
|
||||
for (int b = 0; b < blocks.size(); b++) {
|
||||
byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION);
|
||||
if (shead.getSoundFormat() == 2) { //MP3
|
||||
data = Arrays.copyOfRange(data, 4, data.length);
|
||||
}
|
||||
flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(shead.getSoundFormat(), shead.getSoundRate(), shead.getSoundSize(), shead.getSoundType(), data)));
|
||||
}
|
||||
flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(shead.getSoundFormat(), shead.getSoundRate(), shead.getSoundSize(), shead.getSoundType(), data)));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ExportDialog extends JDialog {
|
||||
{"SVG"},
|
||||
{"PNG/JPEG"},
|
||||
{"FLV (No audio)"},
|
||||
{"FLV (Audio only)"},
|
||||
{"MP3/FLV","FLV (Audio only)"},
|
||||
{"AS", "PCODE"}
|
||||
};
|
||||
String optionNames[] = {
|
||||
|
||||
@@ -1074,7 +1074,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
}
|
||||
|
||||
if (e.getActionCommand().startsWith("EXPORT")) {
|
||||
ExportDialog export = new ExportDialog();
|
||||
final ExportDialog export = new ExportDialog();
|
||||
export.setVisible(true);
|
||||
if (!export.cancelled) {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
@@ -1087,7 +1087,8 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
Main.startWork("Exporting...");
|
||||
final String selFile = chooser.getSelectedFile().getAbsolutePath();
|
||||
Configuration.setConfig("lastExportDir", chooser.getSelectedFile().getParentFile().getAbsolutePath());
|
||||
final boolean isPcode = export.getOption(ExportDialog.OPTION_ACTIONSCRIPT) == 1;
|
||||
final boolean isPcode = export.getOption(ExportDialog.OPTION_ACTIONSCRIPT) == 1;
|
||||
final boolean isMp3 = export.getOption(ExportDialog.OPTION_SOUNDS) == 0;
|
||||
final boolean onlySel = e.getActionCommand().endsWith("SEL");
|
||||
(new Thread() {
|
||||
@Override
|
||||
@@ -1137,7 +1138,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
SWF.exportImages(selFile + File.separator + "images", images, jtt);
|
||||
SWF.exportShapes(selFile + File.separator + "shapes", shapes);
|
||||
swf.exportMovies(selFile + File.separator + "movies", movies);
|
||||
swf.exportSounds(selFile + File.separator + "sounds", sounds);
|
||||
swf.exportSounds(selFile + File.separator + "sounds", sounds, isMp3);
|
||||
if (abcPanel != null) {
|
||||
for (int i = 0; i < tlsList.size(); i++) {
|
||||
TreeLeafScript tls = tlsList.get(i);
|
||||
@@ -1158,7 +1159,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi
|
||||
swf.exportImages(selFile + File.separator + "images");
|
||||
swf.exportShapes(selFile + File.separator + "shapes");
|
||||
swf.exportMovies(selFile + File.separator + "movies");
|
||||
swf.exportSounds(selFile + File.separator + "sounds");
|
||||
swf.exportSounds(selFile + File.separator + "sounds", isMp3);
|
||||
swf.exportActionScript(selFile, isPcode);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
Reference in New Issue
Block a user