mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-14 15:22:01 +00:00
#1323 Audio playback fails
This commit is contained in:
@@ -160,11 +160,13 @@ public class SoundExporter {
|
||||
} else {
|
||||
List<ByteArrayRange> soundData = st.getRawSoundData();
|
||||
SWF swf = ((Tag) st).getSwf();
|
||||
List<SWFInputStream> siss = new ArrayList<>();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
for (ByteArrayRange data : soundData) {
|
||||
siss.add(new SWFInputStream(swf, data.getRangeData()));
|
||||
baos.write(data.getArray(), data.getPos(), data.getLength());
|
||||
}
|
||||
fmt.createWav(siss, fos);
|
||||
|
||||
SWFInputStream sis = new SWFInputStream(swf, baos.toByteArray());
|
||||
fmt.createWav(sis, fos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,12 +228,14 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
|
||||
public List<ByteArrayRange> getRawSoundData() {
|
||||
List<ByteArrayRange> ret = new ArrayList<>();
|
||||
List<SoundStreamBlockTag> blocks = getBlocks();
|
||||
for (SoundStreamBlockTag block : blocks) {
|
||||
ByteArrayRange data = block.streamSoundData;
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
|
||||
ret.add(data.getSubRange(4, data.getLength() - 4));
|
||||
} else {
|
||||
ret.add(data);
|
||||
if (blocks != null) {
|
||||
for (SoundStreamBlockTag block : blocks) {
|
||||
ByteArrayRange data = block.streamSoundData;
|
||||
if (streamSoundCompression == SoundFormat.FORMAT_MP3) {
|
||||
ret.add(data.getSubRange(4, data.getLength() - 4));
|
||||
} else {
|
||||
ret.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.DataLine;
|
||||
@@ -198,12 +197,10 @@ public class SoundFormat {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean createWav(List<SWFInputStream> siss, OutputStream os) {
|
||||
public boolean createWav(SWFInputStream sis, OutputStream os) {
|
||||
ensureFormat();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
for (SWFInputStream sis : siss) {
|
||||
decode(sis, baos);
|
||||
}
|
||||
decode(sis, baos);
|
||||
try {
|
||||
createWavFromPcmData(os, samplingRate, true, stereo, baos.toByteArray());
|
||||
return true;
|
||||
|
||||
@@ -746,6 +746,16 @@ public class Helper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void appendFile(String file, byte[]... data) {
|
||||
try (FileOutputStream fos = new FileOutputStream(file, true)) {
|
||||
for (byte[] d : data) {
|
||||
fos.write(d);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeFile(String file, byte[]... data) {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
for (byte[] d : data) {
|
||||
|
||||
Reference in New Issue
Block a user