Removed flash player component and JavactiveX lib.

This commit is contained in:
Jindra Petřík
2025-05-08 23:30:22 +02:00
parent a1e28f8e88
commit fd679eaf9a
8 changed files with 2 additions and 528 deletions

View File

@@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Configuration removed annotation.
* Configuration directory annotation.
*
* @author JPEXS
*/

View File

@@ -346,7 +346,7 @@
<compilation-unit>
<package-root>test</package-root>
<unit-tests/>
<classpath mode="compile">lib/LZMA.jar;lib/jna-3.5.1.jar;lib/jpproxy.jar;lib/jsyntaxpane-0.9.5.jar;src;testlib/emma.jar;testlib/emma_ant.jar;testlib/junit-4.8.2.jar;testlib/testng-6.8.jar;lib/ffdec_lib.jar;lib/JavactiveX.jar</classpath>
<classpath mode="compile">lib/LZMA.jar;lib/jna-3.5.1.jar;lib/jpproxy.jar;lib/jsyntaxpane-0.9.5.jar;src;testlib/emma.jar;testlib/emma_ant.jar;testlib/junit-4.8.2.jar;testlib/testng-6.8.jar;lib/ffdec_lib.jar;testlib/JavactiveX.jar</classpath>
<built-to>build/test</built-to>
<source-level>1.8</source-level>
</compilation-unit>

View File

@@ -17,7 +17,6 @@
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.helpers.Helper;
import java.awt.BorderLayout;
import java.awt.Container;

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.treeitems.OpenableList;
import com.jpexs.helpers.Helper;
import java.awt.BorderLayout;

View File

@@ -53,12 +53,10 @@ import com.jpexs.decompiler.flash.exporters.FrameExporter;
import com.jpexs.decompiler.flash.exporters.ImageExporter;
import com.jpexs.decompiler.flash.exporters.MorphShapeExporter;
import com.jpexs.decompiler.flash.exporters.MovieExporter;
import com.jpexs.decompiler.flash.exporters.PreviewExporter;
import com.jpexs.decompiler.flash.exporters.ShapeExporter;
import com.jpexs.decompiler.flash.exporters.SoundExporter;
import com.jpexs.decompiler.flash.exporters.SymbolClassExporter;
import com.jpexs.decompiler.flash.exporters.TextExporter;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.modes.BinaryDataExportMode;
import com.jpexs.decompiler.flash.exporters.modes.ButtonExportMode;
import com.jpexs.decompiler.flash.exporters.modes.Font4ExportMode;
@@ -108,7 +106,6 @@ import com.jpexs.decompiler.flash.gui.dumpview.DumpViewPanel;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.gui.helpers.CollectionChangedAction;
import com.jpexs.decompiler.flash.gui.helpers.ObservableList;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.gui.soleditor.Cookie;
import com.jpexs.decompiler.flash.gui.taglistview.TagListTree;
import com.jpexs.decompiler.flash.gui.taglistview.TagListTreeModel;
@@ -146,21 +143,16 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag;
import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag;
import com.jpexs.decompiler.flash.tags.DefineBitsTag;
import com.jpexs.decompiler.flash.tags.DefineFont4Tag;
import com.jpexs.decompiler.flash.tags.DefineMorphShape2Tag;
import com.jpexs.decompiler.flash.tags.DefineShape2Tag;
import com.jpexs.decompiler.flash.tags.DefineShape4Tag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import com.jpexs.decompiler.flash.tags.DoInitActionTag;
import com.jpexs.decompiler.flash.tags.EndTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.JPEGTablesTag;
import com.jpexs.decompiler.flash.tags.MetadataTag;
import com.jpexs.decompiler.flash.tags.PlaceObject3Tag;
import com.jpexs.decompiler.flash.tags.PlaceObjectTag;
import com.jpexs.decompiler.flash.tags.ProductInfoTag;
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
import com.jpexs.decompiler.flash.tags.Tag;
@@ -186,13 +178,9 @@ import com.jpexs.decompiler.flash.tags.base.SymbolClassTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextImportErrorHandler;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.base.UnsupportedSamplingRateException;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalImage2;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalStreamSound;
import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
import com.jpexs.decompiler.flash.tags.gfx.enums.IdType;
import com.jpexs.decompiler.flash.tags.text.TextParseException;
import com.jpexs.decompiler.flash.timeline.AS3Package;
import com.jpexs.decompiler.flash.timeline.DepthState;
import com.jpexs.decompiler.flash.timeline.Frame;
import com.jpexs.decompiler.flash.timeline.Scene;
import com.jpexs.decompiler.flash.timeline.SceneFrame;
@@ -206,16 +194,7 @@ import com.jpexs.decompiler.flash.treeitems.Openable;
import com.jpexs.decompiler.flash.treeitems.OpenableList;
import com.jpexs.decompiler.flash.treeitems.TreeItem;
import com.jpexs.decompiler.flash.types.BUTTONRECORD;
import com.jpexs.decompiler.flash.types.FILLSTYLE;
import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY;
import com.jpexs.decompiler.flash.types.LINESTYLEARRAY;
import com.jpexs.decompiler.flash.types.MATRIX;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
import com.jpexs.decompiler.flash.xfl.FLAVersion;
import com.jpexs.decompiler.graph.DottedChain;

View File

@@ -26,12 +26,9 @@ import com.jpexs.decompiler.flash.exporters.amf.amf0.Amf0Exporter;
import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter;
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.gfx.GfxConvertor;
import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane;
import com.jpexs.decompiler.flash.gui.debugger.DebuggerTools;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.gui.hexview.HexView;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.gui.player.MediaDisplay;
import com.jpexs.decompiler.flash.gui.player.PlayerControls;
import com.jpexs.decompiler.flash.gui.soleditor.Cookie;
@@ -99,13 +96,11 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.io.StringWriter;
@@ -124,7 +119,6 @@ import java.util.logging.Logger;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

View File

@@ -1,497 +0,0 @@
/*
* Copyright (C) 2010-2024 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui.player;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.FlashUnsupportedException;
import com.jpexs.decompiler.flash.gui.Main;
import com.jpexs.helpers.CancellableWorker;
import com.jpexs.javactivex.ActiveX;
import com.jpexs.javactivex.ActiveXEvent;
import com.jpexs.javactivex.ActiveXException;
import com.jpexs.javactivex.example.controls.flash.ShockwaveFlash;
import com.sun.jna.Platform;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Panel;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author JPEXS
*/
public final class FlashPlayerPanel extends Panel implements Closeable, MediaDisplay {
private static final Logger logger = Logger.getLogger(FlashPlayerPanel.class.getName());
private final int setMovieDelay = Configuration.setMovieDelay.get();
private final List<MediaDisplayListener> listeners = new ArrayList<>();
private final ShockwaveFlash flash;
private final Timer timer;
private boolean stopped = true;
private boolean closed = false;
private float frameRate;
private Color bgColor;
@Override
public void clearGuides() {
}
@Override
public boolean canHaveRuler() {
return false;
}
@Override
public boolean canUseSnapping() {
return false;
}
@Override
public boolean loopAvailable() {
return false;
}
@Override
public boolean screenAvailable() {
return true;
}
@Override
public boolean zoomAvailable() {
return true;
}
@Override
public double getZoomToFit() {
//TODO
return 1;
}
@Override
public Zoom getZoom() {
return null;
}
private double zoom = 1.0;
@Override
public synchronized void zoom(Zoom zoom) {
double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value;
int zoomint = (int) Math.round(100 / (zoomDouble / this.zoom));
if (zoomint == 0) {
zoomint = 1;
}
if (zoomint > 32767) {
zoomint = 32767;
}
if (zoomint == 100) {
zoomint = 0;
}
flash.Zoom(0); // hack, but this call is needed otherwise unzoom will fail for larger zoom values
flash.Zoom(zoomint);
}
public synchronized String getVariable(String name) throws IOException {
return flash.GetVariable(name);
}
public synchronized void setVariable(String name, String value) throws IOException {
flash.SetVariable(name, value);
}
public synchronized String call(String callString) throws IOException {
return flash.CallFunction(callString);
}
@Override
public synchronized int getCurrentFrame() {
if (flash == null) {
return 0;
}
try {
return flash.getFrameNum();
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
return 0;
}
@Override
public synchronized int getTotalFrames() {
if (flash == null) {
return 0;
}
try {
if (flash.getReadyState() == 4) {
return flash.getTotalFrames();
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
return 0;
}
@Override
public synchronized void setBackground(Color color) {
try {
flash.setBackgroundColor((color.getRed() << 16) + (color.getGreen() << 8) + color.getBlue());
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
}
public FlashPlayerPanel(Component frame) {
if (!Platform.isWindows()) {
throw new FlashUnsupportedException();
}
try {
Callable<ShockwaveFlash> callable = new Callable<ShockwaveFlash>() {
@Override
public ShockwaveFlash call() throws InterruptedException {
return ActiveX.createObject(ShockwaveFlash.class, FlashPlayerPanel.this);
}
};
// hack: Kernel32.INSTANCE.ConnectNamedPipe never completes in ActiveXControl static constructor
flash = CancellableWorker.call("flashPlayerPanel", callable, 5, TimeUnit.SECONDS);
flash.setAllowScriptAccess("always");
try {
flash.setAllowNetworking("all");
} catch (ActiveXException ex) {
// ignore
}
flash.addOnReadyStateChangeListener((ActiveXEvent axe) -> {
fireMediaDisplayStateChanged();
});
flash.addFlashCallListener((ActiveXEvent axe) -> {
String req = (String) axe.args.get("request");
Matcher m = Pattern.compile("<invoke name=\"([^\"]+)\" returntype=\"xml\"><arguments><string>(.*)</string></arguments></invoke>").matcher(req);
if (m.matches()) {
String funname = m.group(1);
String msg = m.group(2);
if (funname.equals("alert") || funname.equals("console.log")) {
if (Main.debugDialog != null) {
Main.debugDialog.log(funname + ":" + msg);
}
}
}
});
} catch (ActiveXException | TimeoutException | InterruptedException | ExecutionException ex) {
logger.log(Level.WARNING, "Cannot initialize flash panel", ex);
throw new FlashUnsupportedException();
}
timer = new Timer();
timer.schedule(new TimerTask() {
private boolean isPlaying = false;
private int currentFrame = 0;
@Override
public void run() {
if (closed) {
return;
}
try {
ShockwaveFlash flash1 = flash;
boolean changed = false;
if (flash1.getReadyState() >= 3) {
boolean isPlaying = flash1.IsPlaying();
if (this.isPlaying != isPlaying) {
this.isPlaying = isPlaying;
}
int currentFrame = flash1.CurrentFrame();
if (this.currentFrame != currentFrame) {
this.currentFrame = currentFrame;
changed = true;
}
} else {
this.isPlaying = false;
}
if (changed) {
fireMediaDisplayStateChanged();
}
} catch (Exception ex) {
// ignore
cancel();
}
}
}, 100, 100);
}
public synchronized void stopSWF() {
displaySWF("-", null, 1);
stopped = true;
fireMediaDisplayStateChanged();
}
public synchronized boolean isStopped() {
return stopped;
}
@Override
public BufferedImage printScreen() {
Point screenloc = getLocationOnScreen();
try {
return new Robot().createScreenCapture(new Rectangle(screenloc.x, screenloc.y, getWidth(), getHeight()));
} catch (AWTException ex) {
return null;
}
}
private String movieToPlay = null;
private Thread playQueue;
private final Object queueLock = new Object();
public synchronized void displaySWF(final String flashName, final Color bgColor, final float frameRate) {
// Minimum of 1000 ms (setMovieDelay) delay before calling flash.setMovie to avoid illegalAccess errors
if (playQueue == null) {
playQueue = new Thread() {
long lastTime;
@Override
public void run() {
while (true) {
boolean empty;
synchronized (queueLock) {
empty = movieToPlay == null;
if (empty) {
try {
queueLock.wait();
} catch (InterruptedException ex) {
break;
}
}
}
if (!empty) {
flash.setMovie(movieToPlay);
synchronized (queueLock) {
movieToPlay = null;
}
try {
Thread.sleep(setMovieDelay);
} catch (InterruptedException ex) {
break;
}
}
}
}
};
playQueue.start();
}
zoom = 1.0;
this.frameRate = frameRate;
if (bgColor != null) {
setBackground(bgColor);
}
synchronized (queueLock) {
movieToPlay = flashName;
queueLock.notify();
}
//play
stopped = false;
fireMediaDisplayStateChanged();
}
@Override
public synchronized void close() throws IOException {
timer.cancel();
closed = true;
}
@Override
public void pause() {
try {
if (flash.getReadyState() >= 3) {
flash.Stop();
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
}
@Override
public void stop() {
try {
if (flash.getReadyState() >= 3) {
flash.Stop();
flash.Rewind();
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
}
@Override
public void rewind() {
try {
if (flash.getReadyState() >= 3) {
flash.Rewind();
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
}
@Override
public void play() {
try {
if (flash.getReadyState() >= 3) {
flash.Play();
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
}
@Override
public boolean isPlaying() {
try {
if (flash.getReadyState() >= 3) {
return flash.IsPlaying();
} else {
return false;
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
return false;
}
}
@Override
public void setLoop(boolean loop
) {
}
@Override
public void gotoFrame(int frame
) {
if (frame < 0) {
return;
}
if (frame >= getTotalFrames()) {
return;
}
try {
if (flash.getReadyState() >= 3) {
flash.GotoFrame(frame);
}
} catch (ActiveXException | NullPointerException ex) { // Can be "Data not available yet exception"
}
}
@Override
public float getFrameRate() {
return frameRate;
}
@Override
public boolean isLoaded() {
return !isStopped();
}
public void fireMediaDisplayStateChanged() {
for (MediaDisplayListener l : listeners) {
l.mediaDisplayStateChanged(this);
}
}
@Override
public void addEventListener(MediaDisplayListener listener) {
listeners.add(listener);
}
@Override
public void removeEventListener(MediaDisplayListener listener) {
listeners.remove(listener);
}
@Override
public Color getBackgroundColor() {
if (bgColor == null) {
return Color.white;
}
return bgColor;
}
@Override
public void setDisplayed(boolean value) {
}
@Override
public boolean isDisplayed() {
return true;
}
@Override
public void setFrozen(boolean value) {
}
@Override
public boolean alwaysDisplay() {
return true;
}
@Override
public void setMuted(boolean value) {
}
@Override
public boolean isMutable() {
return false;
}
@Override
public void setResample(boolean resample) {
}
}