From d8fdd06477a54072689a9489e059e483cba1ea2a Mon Sep 17 00:00:00 2001 From: Honfika Date: Sat, 15 Mar 2014 15:11:01 +0100 Subject: [PATCH] Stop preview panel when swf is closed +code formatting --- trunk/src/com/jpexs/decompiler/flash/SWF.java | 6 +- .../decompiler/flash/abc/ScriptPack.java | 2 +- .../exporters/modes/SoundExportMode.java | 2 +- .../decompiler/flash/gui/ImagePanel.java | 20 ++--- .../jpexs/decompiler/flash/gui/MainPanel.java | 32 +++---- .../decompiler/flash/gui/SoundTagPlayer.java | 8 +- .../jpexs/decompiler/flash/gui/TagTree.java | 84 +++++++++---------- .../flash/gui/treenodes/TagTreeRoot.java | 2 +- .../flash/tags/DefineSpriteTag.java | 4 +- .../decompiler/flash/tags/base/ShapeTag.java | 1 + .../tags/base/SoundStreamHeadTypeTag.java | 1 + .../decompiler/flash/timeline/DepthState.java | 5 -- .../decompiler/flash/timeline/Timeline.java | 14 ++-- trunk/src/com/jpexs/helpers/SoundPlayer.java | 2 +- 14 files changed, 91 insertions(+), 92 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 569844a75..9f5ff2bb8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -2211,7 +2211,7 @@ public final class SWF implements TreeItem, Timelined { image.fillTransparent(); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); - frameToImage(timeline, frame,time, stateUnderCursor, mouseButton, image, m, colorTransform); + frameToImage(timeline, frame, time, stateUnderCursor, mouseButton, image, m, colorTransform); putToCache(key, image); return image; } @@ -2224,7 +2224,7 @@ public final class SWF implements TreeItem, Timelined { image.fillTransparent(); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); - frameToImage(timeline, f,0, stateUnderCursor, mouseButton, image, m, colorTransform); + frameToImage(timeline, f, 0, stateUnderCursor, mouseButton, image, m, colorTransform); ret.add(image); } } @@ -2290,7 +2290,7 @@ public final class SWF implements TreeItem, Timelined { DrawableTag drawable = (DrawableTag) character; SerializableImage img; Matrix drawMatrix = new Matrix(); - int dframe = 0 + (time+layer.time) % drawable.getNumFrames(); + int dframe = 0 + (time + layer.time) % drawable.getNumFrames(); if (character instanceof ButtonTag) { ButtonTag bt = (ButtonTag) character; dframe = ButtonTag.FRAME_UP; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 4ce47afa8..4359a543d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -150,7 +150,7 @@ public class ScriptPack implements TreeElementItem { public void toSource(GraphTextWriter writer, final List abcList, final Trait[] traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException { writer.suspendMeasure(); - int timeout = Configuration.decompilationTimeoutFile.get(); + int timeout = Configuration.decompilationTimeoutFile.get(); try { CancellableWorker.call(new Callable() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java index 72c5930b8..ca36d4f05 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/modes/SoundExportMode.java @@ -24,7 +24,7 @@ public enum SoundExportMode { MP3_WAV_FLV(true, true, true), FLV(false, false, true), MP3_WAV(true, true, false), WAV(false, true, false); - private boolean mp3, wav, flv; + private final boolean mp3, wav, flv; private SoundExportMode(boolean mp3, boolean wav, boolean flv) { this.mp3 = mp3; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index bfaa55b3f..5a92e1d27 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -83,8 +83,8 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis private JLabel debugLabel = new JLabel("-"); private DepthState stateUnderCursor = null; private MouseEvent lastMouseEvent = null; - private List soundPlayers = new ArrayList<>(); - private IconPanel iconPanel; + private final List soundPlayers = new ArrayList<>(); + private final IconPanel iconPanel; private int time = 0; private class IconPanel extends JPanel { @@ -424,7 +424,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis private void nextFrame() { int newframe = frame == timelined.getTimeline().frames.size() - 1 ? 0 : frame + 1; - if(stillFrame){ + if (stillFrame) { newframe = frame; } if (newframe != frame) { @@ -433,15 +433,15 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis } frame = newframe; updatePos(lastMouseEvent); - time = 0; - }else{ + time = 0; + } else { time++; } drawFrame(); } - private static SerializableImage getFrame(SWF swf, int frame,int time, Timelined drawable, DepthState stateUnderCursor, int mouseButton) { - String key = "drawable_" + frame + "_" + drawable.hashCode() + "_" + mouseButton + "_" + (stateUnderCursor == null ? "out" : stateUnderCursor.hashCode())+"_"+time; + private static SerializableImage getFrame(SWF swf, int frame, int time, Timelined drawable, DepthState stateUnderCursor, int mouseButton) { + String key = "drawable_" + frame + "_" + drawable.hashCode() + "_" + mouseButton + "_" + (stateUnderCursor == null ? "out" : stateUnderCursor.hashCode()) + "_" + time; SerializableImage img = SWF.getFromCache(key); if (img == null) { if (drawable instanceof BoundedTag) { @@ -491,8 +491,8 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis Matrix mat = new Matrix(); mat.translateX = swf.displayRect.Xmin; mat.translateY = swf.displayRect.Ymin; - BufferedImage img = getFrame(swf, frame,time, timelined, stateUnderCursor, mouseButton).getBufferedImage(); - List sounds = timelined.getTimeline().getSounds(frame,time, stateUnderCursor, mouseButton); + BufferedImage img = getFrame(swf, frame, time, timelined, stateUnderCursor, mouseButton).getBufferedImage(); + List sounds = timelined.getTimeline().getSounds(frame, time, stateUnderCursor, mouseButton); for (int sndId : sounds) { CharacterTag c = swf.characters.get(sndId); if (c instanceof SoundTag) { @@ -543,7 +543,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis @Override public void play() { pause(); - if (timelined!=null) { + if (timelined != null) { timer = new Timer(); timer.schedule(new TimerTask() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 0ccddecb1..0e9165986 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -284,10 +284,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public TreeNode oldNode; public TreeItem oldTag; private File tempFile; - private PlayerControls imagePlayControls; + private final PlayerControls imagePlayControls; - private JPanel repPanel; - private JPanel repPanel2; + private final JPanel repPanel; + private final JPanel repPanel2; private SoundTagPlayer soundThread = null; @@ -977,8 +977,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void load(SWFList newSwfs, boolean first) { - swfPreviewPanel.stop(); - imagePanel.stop(); + stopImagePanels(); swfs.add(newSwfs); @@ -1109,6 +1108,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec refreshTree(); } + private void stopImagePanels() { + imagePanel.stop(); + previewImagePanel.stop(); + swfPreviewPanel.stop(); + } + public void enableDrop(boolean value) { if (value) { setDropTarget(new DropTarget() { @@ -2170,8 +2175,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } public void refreshTree() { - swfPreviewPanel.stop(); - imagePanel.stop(); + stopImagePanels(); showCard(CARDEMPTYPANEL); View.refreshTree(tagTree, new TagTreeModel(mainFrame, swfs)); setTreeItem(oldTag); @@ -2546,8 +2550,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (flashPanel != null) { flashPanel.specialPlayback = false; } - swfPreviewPanel.stop(); - imagePanel.stop(); + stopImagePanels(); if (soundThread != null) { soundThread.pause(); } @@ -2697,11 +2700,12 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec int totalFrameCount = swf.frameCount; Timelined timelined = swf; if (fn.getParent() instanceof DefineSpriteTag) { - controlTags = ((DefineSpriteTag) fn.getParent()).subTags; - containerId = ((DefineSpriteTag) fn.getParent()).spriteId; - rect = ((DefineSpriteTag) fn.getParent()).getRect(); - totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount; - timelined = ((DefineSpriteTag) fn.getParent()); + DefineSpriteTag parentSprite = (DefineSpriteTag) fn.getParent(); + controlTags = parentSprite.subTags; + containerId = parentSprite.spriteId; + rect = parentSprite.getRect(); + totalFrameCount = parentSprite.frameCount; + timelined = parentSprite; } previewImagePanel.setTimelined(timelined, swf, fn.getFrame() - 1); } else if (((tagObj instanceof SoundTag) && mainMenu.isInternalFlashViewerSelected() && (Arrays.asList("mp3", "wav").contains(((SoundTag) tagObj).getExportFormat())))) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index ce91f32d9..5f8c699c9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -36,12 +36,12 @@ import javax.sound.sampled.UnsupportedAudioFileException; */ public class SoundTagPlayer implements MediaDisplay { - private SoundPlayer player; + private final SoundPlayer player; private Thread thr; private int actualPos = 0; - private SoundTag tag; - private List listeners = new ArrayList<>(); + private final SoundTag tag; + private final List listeners = new ArrayList<>(); public void addListener(PlayerListener l) { listeners.add(l); @@ -61,7 +61,7 @@ public class SoundTagPlayer implements MediaDisplay { private int loops; private boolean paused = true; - private Object myLock = new Object(); + private final Object myLock = new Object(); private final Object playLock = new Object(); public SoundTagPlayer(SoundTag tag, int loops) throws LineUnavailableException, IOException, UnsupportedAudioFileException { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/TagTree.java b/trunk/src/com/jpexs/decompiler/flash/gui/TagTree.java index 42931c3c3..3fb74b41b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/TagTree.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/TagTree.java @@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ScriptPack; -import com.jpexs.decompiler.flash.gui.treenodes.StringNode; import com.jpexs.decompiler.flash.gui.treenodes.TagTreeRoot; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; @@ -99,18 +98,18 @@ public class TagTree extends JTree { if (type == TreeNodeType.FOLDER && expanded) { type = TreeNodeType.FOLDER_OPEN; } - String itemName=type.toString(); - if(type == TreeNodeType.FOLDER || type==TreeNodeType.FOLDER_OPEN){ - if(val instanceof StringItem){ - StringItem si=(StringItem)val; - if(!TagTreeRoot.FOLDER_ROOT.equals(si.getName())){ - itemName="folder"+si.getName(); + String itemName = type.toString(); + if (type == TreeNodeType.FOLDER || type == TreeNodeType.FOLDER_OPEN) { + if (val instanceof StringItem) { + StringItem si = (StringItem) val; + if (!TagTreeRoot.FOLDER_ROOT.equals(si.getName())) { + itemName = "folder" + si.getName(); } } } String tagTypeStr = itemName.toLowerCase().replace("_", ""); setIcon(View.getIcon(tagTypeStr + "16")); - } + } Font font = getFont(); boolean isModified = false; @@ -245,42 +244,41 @@ public class TagTree extends JTree { if (t instanceof Tag) { return TreeNodeType.OTHER_TAG; } - - /*if(t instanceof StringNode){ - StringNode sn=(StringNode)t; - String name = sn.getItem().getName(); - if(name!=null){ - switch(name){ - case TagTreeModel.FOLDER_BINARY_DATA: - break; - case TagTreeModel.FOLDER_BUTTONS: - break; - case TagTreeModel.FOLDER_FONTS: - break; - case TagTreeModel.FOLDER_FRAMES: - break; - case TagTreeModel.FOLDER_IMAGES: - break; - case TagTreeModel.FOLDER_MORPHSHAPES: - break; - case TagTreeModel.FOLDER_MOVIES: - break; - case TagTreeModel.FOLDER_OTHERS: - break; - case TagTreeModel.FOLDER_SCRIPTS: - break; - case TagTreeModel.FOLDER_SHAPES: - break; - case TagTreeModel.FOLDER_SOUNDS: - break; - case TagTreeModel.FOLDER_SPRITES: - break; - case TagTreeModel.FOLDER_TEXTS: - break; - } - } - }*/ + /*if(t instanceof StringNode){ + StringNode sn=(StringNode)t; + String name = sn.getItem().getName(); + if(name!=null){ + switch(name){ + case TagTreeModel.FOLDER_BINARY_DATA: + break; + case TagTreeModel.FOLDER_BUTTONS: + break; + case TagTreeModel.FOLDER_FONTS: + break; + case TagTreeModel.FOLDER_FRAMES: + break; + case TagTreeModel.FOLDER_IMAGES: + break; + case TagTreeModel.FOLDER_MORPHSHAPES: + break; + case TagTreeModel.FOLDER_MOVIES: + break; + case TagTreeModel.FOLDER_OTHERS: + break; + case TagTreeModel.FOLDER_SCRIPTS: + break; + case TagTreeModel.FOLDER_SHAPES: + break; + case TagTreeModel.FOLDER_SOUNDS: + break; + case TagTreeModel.FOLDER_SPRITES: + break; + case TagTreeModel.FOLDER_TEXTS: + break; + } + } + }*/ return TreeNodeType.FOLDER; } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/TagTreeRoot.java b/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/TagTreeRoot.java index ae4a693e2..d884a6af2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/TagTreeRoot.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/treenodes/TagTreeRoot.java @@ -26,7 +26,7 @@ import com.jpexs.decompiler.flash.treenodes.TreeNode; public class TagTreeRoot extends TreeNode { public static final String FOLDER_ROOT = "root"; - + public TagTreeRoot() { super(new StringItem("root", FOLDER_ROOT, null)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 47635985f..6cbb5559c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -269,7 +269,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT @Override public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { - SWF.frameToImage(getTimeline(), frame,time, stateUnderCursor, mouseButton, image, transformation, colorTransform); + SWF.frameToImage(getTimeline(), frame, time, stateUnderCursor, mouseButton, image, transformation, colorTransform); } @Override @@ -284,6 +284,6 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT @Override public Shape getOutline(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation) { - return getTimeline().getOutline(frame,time, ratio, stateUnderCursor, mouseButton, transformation); + return getTimeline().getOutline(frame, time, ratio, stateUnderCursor, mouseButton, transformation); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java index adec029e3..fe063e619 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java @@ -46,6 +46,7 @@ public abstract class ShapeTag extends CharacterTag implements BoundedTag, Drawa return transformation.toTransform().createTransformedShape(getShapes().getOutline()); } + @Override public void toImage(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { BitmapExporter.exportTo(swf, getShapes(), null, image, transformation, colorTransform); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundStreamHeadTypeTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundStreamHeadTypeTag.java index 7b421bdfe..539d8870f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundStreamHeadTypeTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/SoundStreamHeadTypeTag.java @@ -25,6 +25,7 @@ import java.util.List; */ public interface SoundStreamHeadTypeTag extends SoundTag { + @Override public boolean getSoundSize(); public long getSoundSampleCount(); diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java b/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java index 713c3015b..99b0f4eab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java @@ -17,16 +17,11 @@ package com.jpexs.decompiler.flash.timeline; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.exporters.Matrix; -import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.DrawableTag; import com.jpexs.decompiler.flash.types.CLIPACTIONS; import com.jpexs.decompiler.flash.types.ColorTransform; import com.jpexs.decompiler.flash.types.MATRIX; import com.jpexs.decompiler.flash.types.RGBA; import com.jpexs.decompiler.flash.types.filters.FILTER; -import com.jpexs.helpers.SerializableImage; -import java.awt.Point; import java.util.ArrayList; import java.util.List; diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java index f499c9aa4..0143cb607 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -179,7 +179,7 @@ public class Timeline { } - public List getSounds(int frame,int time, DepthState stateUnderCursor, int mouseButton) { + public List getSounds(int frame, int time, DepthState stateUnderCursor, int mouseButton) { List ret = new ArrayList<>(); Frame fr = this.frames.get(frame); ret.addAll(fr.sounds); @@ -188,7 +188,7 @@ public class Timeline { if (ds != null) { CharacterTag c = swf.characters.get(ds.characterId); if (c instanceof Timelined) { - int dframe = (time+ds.time) % ((Timelined) c).getTimeline().frames.size(); + int dframe = (time + ds.time) % ((Timelined) c).getTimeline().frames.size(); if (c instanceof ButtonTag) { ButtonTag bt = (ButtonTag) c; dframe = ButtonTag.FRAME_UP; @@ -200,7 +200,7 @@ public class Timeline { } } } - ret.addAll(((Timelined) c).getTimeline().getSounds(dframe,time+ds.time, stateUnderCursor, mouseButton)); + ret.addAll(((Timelined) c).getTimeline().getSounds(dframe, time + ds.time, stateUnderCursor, mouseButton)); } } } @@ -248,7 +248,7 @@ public class Timeline { } } } - Shape cshape = ((DrawableTag) c).getOutline(dframe, ds.time+time, ds.ratio, stateUnderCursor, mouseButton, m); + Shape cshape = ((DrawableTag) c).getOutline(dframe, ds.time + time, ds.ratio, stateUnderCursor, mouseButton, m); Area addArea = new Area(cshape); if (currentClip != null) { @@ -264,7 +264,7 @@ public class Timeline { outlines.add(addArea); } if (c instanceof Timelined) { - ((Timelined) c).getTimeline().getObjectsOutlines(dframe,time+ds.time,ds.ratio, stateUnderCursor, mouseButton, m, objs, outlines); + ((Timelined) c).getTimeline().getObjectsOutlines(dframe, time + ds.time, ds.ratio, stateUnderCursor, mouseButton, m, objs, outlines); } } } @@ -299,7 +299,7 @@ public class Timeline { int dframe = 0; if (c instanceof Timelined) { - dframe = (time+ds.time) % ((Timelined) c).getTimeline().frames.size(); + dframe = (time + ds.time) % ((Timelined) c).getTimeline().frames.size(); if (c instanceof ButtonTag) { ButtonTag bt = (ButtonTag) c; dframe = ButtonTag.FRAME_UP; @@ -312,7 +312,7 @@ public class Timeline { } } } - Shape cshape = ((DrawableTag) c).getOutline(dframe, time+ds.time,ds.ratio, stateUnderCursor, mouseButton, m); + Shape cshape = ((DrawableTag) c).getOutline(dframe, time + ds.time, ds.ratio, stateUnderCursor, mouseButton, m); Area addArea = new Area(cshape); if (currentClip != null) { diff --git a/trunk/src/com/jpexs/helpers/SoundPlayer.java b/trunk/src/com/jpexs/helpers/SoundPlayer.java index 0d18cf202..d6cb39d94 100644 --- a/trunk/src/com/jpexs/helpers/SoundPlayer.java +++ b/trunk/src/com/jpexs/helpers/SoundPlayer.java @@ -33,7 +33,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; */ public class SoundPlayer { - private Clip clip; + private final Clip clip; public SoundPlayer(InputStream is) throws LineUnavailableException, IOException, UnsupportedAudioFileException { clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class));