diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ec1c2ea..79017f110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. - Flash viewer - linear colorspace radial gradient - Folder preview of frames with time increasing - Flash viewer - Do not play StartSoundTag all over again on single frame +- Flash viewer - StartSoundTag loops ### Changed - [#1661] Slow rendering warning is optional with default to not display diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java index 8f1895931..386b21041 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.timeline; import com.jpexs.decompiler.flash.SWF; @@ -24,6 +25,7 @@ import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.treeitems.TreeItem; import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.RGBA; +import com.jpexs.decompiler.flash.types.SOUNDINFO; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -47,6 +49,8 @@ public class Frame implements TreeItem, Exportable { public List soundClasses = new ArrayList<>(); + public List soundInfos = new ArrayList<>(); + public List actions = new ArrayList<>(); public List actionContainers = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 32c8ab04f..264a8b9b2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -54,6 +54,7 @@ import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.decompiler.flash.types.SOUNDINFO; import com.jpexs.decompiler.flash.types.filters.BlendComposite; import com.jpexs.decompiler.flash.types.filters.FILTER; import com.jpexs.helpers.Helper; @@ -289,9 +290,13 @@ public class Timeline { } else if (t instanceof StartSoundTag) { newFrameNeeded = true; frame.sounds.add(((StartSoundTag) t).soundId); + frame.soundClasses.add(null); + frame.soundInfos.add(((StartSoundTag) t).soundInfo); } else if (t instanceof StartSound2Tag) { newFrameNeeded = true; + frame.sounds.add(-1); frame.soundClasses.add(((StartSound2Tag) t).soundClassName); + frame.soundInfos.add(((StartSoundTag) t).soundInfo); } else if (t instanceof SetBackgroundColorTag) { newFrameNeeded = true; frame.backgroundColor = ((SetBackgroundColorTag) t).backgroundColor; @@ -1178,10 +1183,11 @@ public class Timeline { FrameExporter.framesToHtmlCanvas(result, unitDivisor, this, frames, 0, null, 0, displayRect, null, null); } - public void getSounds(int frame, int time, ButtonTag mouseOverButton, int mouseButton, List sounds, List soundClasses) { + public void getSounds(int frame, int time, ButtonTag mouseOverButton, int mouseButton, List sounds, List soundClasses, List soundInfos) { Frame fr = getFrame(frame); sounds.addAll(fr.sounds); soundClasses.addAll(fr.soundClasses); + soundInfos.addAll(fr.soundInfos); for (int d = maxDepth; d >= 0; d--) { DepthState ds = fr.layers.get(d); if (ds != null) { @@ -1202,7 +1208,7 @@ public class Timeline { } } } - ((Timelined) c).getTimeline().getSounds(dframe, time, mouseOverButton, mouseButton, sounds, soundClasses); + ((Timelined) c).getTimeline().getSounds(dframe, time, mouseOverButton, mouseButton, sounds, soundClasses, soundInfos); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 915b6aad8..ea106881d 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -1928,21 +1928,30 @@ public final class ImagePanel extends JPanel implements MediaDisplay { if (!shownAgain) { List sounds = new ArrayList<>(); List soundClasses = new ArrayList<>(); - timeline.getSounds(frame, time, renderContext.mouseOverButton, mouseButton, sounds, soundClasses); + List soundInfos = new ArrayList<>(); + timeline.getSounds(frame, time, renderContext.mouseOverButton, mouseButton, sounds, soundClasses, soundInfos); for (int cid : swf.getCharacters().keySet()) { CharacterTag c = swf.getCharacter(cid); - for (String cls : soundClasses) { + for (int k = 0; k < soundClasses.size(); k++) { + String cls = soundClasses.get(k); + if (cls == null) { + continue; + } if (cls.equals(c.getClassName())) { - sounds.add(cid); + sounds.set(k, cid); } } } - for (int sndId : sounds) { + for (int s = 0; s < sounds.size(); s++) { + int sndId = sounds.get(s); + if (sndId == -1) { + continue; + } CharacterTag c = swf.getCharacter(sndId); if (c instanceof SoundTag) { SoundTag st = (SoundTag) c; - playSound(st, null, thisTimer); + playSound(st, soundInfos.get(s), thisTimer); } } executeFrame(frame);