mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-09 13:28:07 +00:00
#1323 Audio playback fails
This commit is contained in:
@@ -49,6 +49,7 @@ All notable changes to this project will be documented in this file.
|
||||
- #1303 garbled text when exporting frame with text
|
||||
- #1314 user interface: button order
|
||||
- Internal viewer shows red image when bitmap fill is not available (see issue #1320)
|
||||
- #1323 Audio playback fails
|
||||
|
||||
## [9.0.0] - 2016-08-12
|
||||
### Added
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -94,7 +94,6 @@ public class SoundTagPlayer implements MediaDisplay {
|
||||
this.loopCount = loops;
|
||||
clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class));
|
||||
clip.addLineListener(new LineListener() {
|
||||
|
||||
@Override
|
||||
public void update(LineEvent event) {
|
||||
if (event.getType() == LineEvent.Type.STOP) {
|
||||
@@ -123,7 +122,6 @@ public class SoundTagPlayer implements MediaDisplay {
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -141,7 +139,6 @@ public class SoundTagPlayer implements MediaDisplay {
|
||||
openSound(tag);
|
||||
} else {
|
||||
new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -155,7 +152,6 @@ public class SoundTagPlayer implements MediaDisplay {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
@@ -166,14 +162,13 @@ public class SoundTagPlayer implements MediaDisplay {
|
||||
if (wavData == null) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
List<ByteArrayRange> soundData = tag.getRawSoundData();
|
||||
List<SWFInputStream> siss = new ArrayList<>();
|
||||
for (ByteArrayRange data : soundData) {
|
||||
SWFInputStream sis = new SWFInputStream(swf, data.getArray(), 0, data.getPos() + data.getLength());
|
||||
sis.seek(data.getPos());
|
||||
siss.add(sis);
|
||||
baos.write(data.getArray(), data.getPos(), data.getLength());
|
||||
}
|
||||
|
||||
tag.getSoundFormat().createWav(siss, baos);
|
||||
SWFInputStream sis = new SWFInputStream(swf, baos.toByteArray());
|
||||
baos = new ByteArrayOutputStream();
|
||||
tag.getSoundFormat().createWav(sis, baos);
|
||||
wavData = baos.toByteArray();
|
||||
swf.putToCache(tag, wavData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user