diff --git a/app/path.properties b/app/path.properties
index 7bf1685b..854320fd 100644
--- a/app/path.properties
+++ b/app/path.properties
@@ -1,5 +1,5 @@
-ffmpeg=external/x64/windows/ffmpeg.exe
-ffprobe=external/x64/windows/ffprobe.exe
-mp4art=external/x64/windows/mp4art.exe
-mp4info=external/x64/windows/mp4info.exe
+ffmpeg=external/x64/mac/ffmpeg
+ffprobe=external/x64/mac/ffprobe
+mp4art=external/x64/mac/mp4art
+mp4info=external/x64/mac/mp4info
platform=steam
\ No newline at end of file
diff --git a/idea.txt b/build/idea.txt
similarity index 68%
rename from idea.txt
rename to build/idea.txt
index 6597ba73..c7ea291f 100644
--- a/idea.txt
+++ b/build/idea.txt
@@ -1,2 +1,7 @@
VM Options=--module-path "C:\Users\Yermak\Programs\JavaFX\javafx-sdk-15.0.1\lib" --add-modules javafx.controls,javafx.fxml,javafx.media,javafx.base,javafx.swing,javafx.graphics
Enviromnent var=FFMPEG=external/x64/windows
+
+
+https://www.reddit.com/r/gamedev/comments/di61ms/have_a_mac_game_on_steam_heres_a_guide_to_signing/
+
+
diff --git a/build/mac/package.sh b/build/mac/package.sh
new file mode 100755
index 00000000..d3693b7f
--- /dev/null
+++ b/build/mac/package.sh
@@ -0,0 +1,35 @@
+JAVA_HOME=/Users/Yarick_Yermak/Library/Java/JavaVirtualMachines/temurin-17/Contents/Home
+JAVA_HOME=$1
+JAVAFX_JMODS=jmods/mac
+#APP_VERSION=5.6.3
+
+rm -rf target/release
+mkdir target/release
+
+rm -rf target/fx-jre
+$JAVA_HOME/bin/jlink --module-path $JAVA_HOME/jmods:$JAVAFX_JMODS \
+--add-modules java.base,java.sql,javafx.controls,javafx.fxml,javafx.media,javafx.base,javafx.swing,javafx.graphics --output target/fx-jre
+
+rm -rf target/image
+$JAVA_HOME/bin/jpackage --app-version $APP_VERSION --icon AudioBookConverter.icns \
+--type app-image \
+--input target/package/audiobookconverter-$APP_VERSION-mac-installer/audiobookconverter-$APP_VERSION/app \
+--main-jar lib/audiobookconverter-$APP_VERSION.jar \
+--runtime-image target/fx-jre \
+--java-options "--add-exports java.desktop/com.apple.eio=ALL-UNNAMED" \
+--dest target/release \
+--vendor "Recoupler Limited" \
+--app-version $APP_VERSION \
+--mac-package-identifier com.recoupler.audiobookconverter \
+--mac-package-name AudiobookConverter \
+--mac-signing-key-user-name "Developer ID Application: Recoupler Limited" \
+--mac-sign
+
+
+#$JAVA_HOME/bin/jpackage --app-version $(APP_VERSION) --icon AudioBookConverter.icns \
+#--type dmg \
+#--input target/package/audiobookconverter-$(APP_VERSION)-mac-installer/audiobookconverter-$(APP_VERSION)/app \
+#--main-jar lib/audiobookconverter-$(APP_VERSION).jar --runtime-image target/fx-jre --java-options '--enable-preview'
+#mkdir target/release
+
+
diff --git a/external/x64/mac/ffmpeg b/external/x64/mac/ffmpeg
new file mode 100755
index 00000000..56145317
Binary files /dev/null and b/external/x64/mac/ffmpeg differ
diff --git a/external/x64/mac/ffprobe b/external/x64/mac/ffprobe
new file mode 100755
index 00000000..293a30d8
Binary files /dev/null and b/external/x64/mac/ffprobe differ
diff --git a/external/x64/mac/mp4art b/external/x64/mac/mp4art
new file mode 100755
index 00000000..3f935146
Binary files /dev/null and b/external/x64/mac/mp4art differ
diff --git a/external/x64/mac/mp4info b/external/x64/mac/mp4info
new file mode 100755
index 00000000..c82f13e9
Binary files /dev/null and b/external/x64/mac/mp4info differ
diff --git a/external/x64/mac/path.properties b/external/x64/mac/path.properties
new file mode 100644
index 00000000..8ef20db3
--- /dev/null
+++ b/external/x64/mac/path.properties
@@ -0,0 +1,5 @@
+ffmpeg=Contents/app/external/ffmpeg
+ffprobe=Contents/app/external/ffprobe
+mp4art=Contents/app/external/mp4art
+mp4info=Contents/app/external/mp4info
+platform=steam
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 64179c51..d03769ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,9 +7,8 @@
uk.yermak
audiobookconverter
-
+
+
#{APP_VERSION}#
@@ -128,6 +127,23 @@
4.3.1
+
+
+ com.apple
+ AppleJavaExtensions
+ 1.4
+
+
+
+
+
org.testng
testng
@@ -144,7 +160,7 @@
javafx-maven-plugin
0.0.4
- ConverterApplication
+ AudioBookConverter
${java.home}\bin\java
@@ -181,7 +197,7 @@
true
- uk.yermak.audiobookconverter.fx.ConverterApplication
+ uk.yermak.audiobookconverter.AudiobookConverter
diff --git a/src/main/deploy/assembly/mac-installer.xml b/src/main/deploy/assembly/mac-installer.xml
index 43aa7894..a3847ceb 100644
--- a/src/main/deploy/assembly/mac-installer.xml
+++ b/src/main/deploy/assembly/mac-installer.xml
@@ -15,6 +15,22 @@
app
+
+ external/x64/mac
+ app/external/
+
+ *
+
+
+
+ external/x64/mac
+ app
+
+ path.properties
+
+
+
+
diff --git a/src/main/java/uk/yermak/audiobookconverter/AppProperties.java b/src/main/java/uk/yermak/audiobookconverter/AppProperties.java
index 6e484a2a..726c780e 100644
--- a/src/main/java/uk/yermak/audiobookconverter/AppProperties.java
+++ b/src/main/java/uk/yermak/audiobookconverter/AppProperties.java
@@ -21,7 +21,7 @@ public class AppProperties {
loadAppProperties();
}
- private static synchronized Properties loadAppProperties() {
+ static synchronized Properties loadAppProperties() {
if (PROP_FILE.exists()) {
try (FileInputStream in = new FileInputStream(PROP_FILE)) {
applicationProps.load(in);
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/ConverterApplication.java b/src/main/java/uk/yermak/audiobookconverter/AudiobookConverter.java
similarity index 83%
rename from src/main/java/uk/yermak/audiobookconverter/fx/ConverterApplication.java
rename to src/main/java/uk/yermak/audiobookconverter/AudiobookConverter.java
index dad6fa37..56942c4e 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/ConverterApplication.java
+++ b/src/main/java/uk/yermak/audiobookconverter/AudiobookConverter.java
@@ -1,7 +1,8 @@
-package uk.yermak.audiobookconverter.fx;/**
+package uk.yermak.audiobookconverter;/**
* Created by Yermak on 06-Jan-18.
*/
+import com.apple.eio.FileManager;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
@@ -18,6 +19,8 @@
import uk.yermak.audiobookconverter.AppProperties;
import uk.yermak.audiobookconverter.Utils;
import uk.yermak.audiobookconverter.Version;
+import uk.yermak.audiobookconverter.fx.ConversionContext;
+import uk.yermak.audiobookconverter.fx.JfxEnv;
import java.io.File;
import java.io.IOException;
@@ -28,7 +31,7 @@
import java.util.Scanner;
import java.util.concurrent.Executors;
-public class ConverterApplication extends Application {
+public class AudiobookConverter extends Application {
private static JfxEnv env;
//TODO clean-up
@@ -42,9 +45,10 @@ public static void initAppHome() {
if (appdata != null) {
appDir = new File(appdata, Version.getVersionString());
} else {
- appDir = new File(System.getProperty("user.home"), Version.getVersionString());
+ File file = new File(".abc", Version.getVersionString());
+ appDir = new File(System.getProperty("user.home"), file.getPath());
}
- if (appDir.exists() || appDir.mkdir()) {
+ if (appDir.exists() || appDir.mkdirs()) {
System.setProperty("APP_HOME", appDir.getAbsolutePath());
} else {
System.setProperty("APP_HOME", System.getProperty("user.home"));
@@ -78,7 +82,7 @@ public void start(Stage stage) {
logger.info("Initialising application");
try {
- URL resource = ConverterApplication.class.getResource("/uk/yermak/audiobookconverter/fx/fxml_converter.fxml");
+ URL resource = AudiobookConverter.class.getResource("/uk/yermak/audiobookconverter/fx/fxml_converter.fxml");
root = FXMLLoader.load(resource);
Scene scene = new Scene(root);
@@ -93,7 +97,7 @@ public void start(Stage stage) {
stage.setOnCloseRequest(event -> {
logger.info("Closing application");
- ConverterApplication.getContext().stopConversions();
+ AudiobookConverter.getContext().stopConversions();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
@@ -136,7 +140,7 @@ static class VersionChecker implements Runnable {
@Override
public void run() {
try {
- String platform = Utils.loadAppProperties().getProperty("platform");
+ String platform = Environment.current.loadAppProperties().getProperty("platform");
if (platform == null) platform = "version";
if ("steam".equals(platform)) return;
String version = readStringFromURL("https://raw.githubusercontent.com/yermak/AudioBookConverter/version/" + platform + ".txt");
@@ -145,10 +149,12 @@ public void run() {
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("New Version Available!");
+ String path = FileManager.getPathToApplicationBundle();
+// alert.setContentText("path:"+ path);
alert.setContentText("Would you like to download new version?");
Optional result = alert.showAndWait();
if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
- ConverterApplication.getEnv().showDocument("https://store.steampowered.com/app/1529240/AudioBookConverter/");
+ AudiobookConverter.getEnv().showDocument("https://store.steampowered.com/app/1529240/AudioBookConverter/");
}
});
}
diff --git a/src/main/java/uk/yermak/audiobookconverter/ConversionGroup.java b/src/main/java/uk/yermak/audiobookconverter/ConversionGroup.java
index fdd55a87..a762cb44 100644
--- a/src/main/java/uk/yermak/audiobookconverter/ConversionGroup.java
+++ b/src/main/java/uk/yermak/audiobookconverter/ConversionGroup.java
@@ -6,7 +6,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.yermak.audiobookconverter.fx.ConversionProgress;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
import uk.yermak.audiobookconverter.fx.ProgressComponent;
import java.io.File;
@@ -43,7 +42,7 @@ public ConversionProgress start(Convertable convertable, String outputDestinatio
jobs.add(conversionJob);
Executors.newSingleThreadExecutor().execute(conversionProgress);
- ConverterApplication.getContext().addJob(conversionJob);
+ AudiobookConverter.getContext().addJob(conversionJob);
return conversionProgress;
}
diff --git a/src/main/java/uk/yermak/audiobookconverter/ConversionJob.java b/src/main/java/uk/yermak/audiobookconverter/ConversionJob.java
index f282df5f..87187370 100644
--- a/src/main/java/uk/yermak/audiobookconverter/ConversionJob.java
+++ b/src/main/java/uk/yermak/audiobookconverter/ConversionJob.java
@@ -6,7 +6,6 @@
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
import java.io.File;
import java.io.PrintWriter;
@@ -43,7 +42,7 @@ public ConversionJob(ConversionGroup conversionGroup, Convertable convertable, M
addStatusChangeListener((observable, oldValue, newValue) -> {
if (FINISHED.equals(newValue)) {
- Platform.runLater(() -> ConverterApplication.showNotification(outputDestination));
+ Platform.runLater(() -> AudiobookConverter.showNotification(outputDestination));
}
});
diff --git a/src/main/java/uk/yermak/audiobookconverter/DurationVerifier.java b/src/main/java/uk/yermak/audiobookconverter/DurationVerifier.java
index da1d4153..f088a186 100644
--- a/src/main/java/uk/yermak/audiobookconverter/DurationVerifier.java
+++ b/src/main/java/uk/yermak/audiobookconverter/DurationVerifier.java
@@ -4,13 +4,11 @@
import net.bramp.ffmpeg.FFprobe;
import net.bramp.ffmpeg.probe.FFmpegProbeResult;
import net.bramp.ffmpeg.probe.FFmpegStream;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.Charset;
@@ -47,7 +45,7 @@ static long parseDuration(String info) {
public static void mp4v2UpdateDuration(MediaInfo mediaInfo, String outputFileName) throws IOException {
Process process = null;
try {
- ProcessBuilder infoProcessBuilder = new ProcessBuilder(Utils.MP4INFO, outputFileName);
+ ProcessBuilder infoProcessBuilder = new ProcessBuilder(Environment.MP4INFO, outputFileName);
process = infoProcessBuilder.start();
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamCopier.copy(process.getInputStream(), out);
@@ -69,7 +67,7 @@ public static void mp4v2UpdateDuration(MediaInfo mediaInfo, String outputFileNam
public static void ffMpegUpdateDuration(MediaInfo mediaInfo, String outputFileName) throws IOException {
final Set AUDIO_CODECS = ImmutableSet.of("mp3", "aac", "wmav2", "flac", "alac", "vorbis", "opus");
- FFprobe ffprobe = new FFprobe(Utils.FFPROBE);
+ FFprobe ffprobe = new FFprobe(Environment.FFPROBE);
FFmpegProbeResult probe = ffprobe.probe(outputFileName);
List streams = probe.getStreams();
for (FFmpegStream stream : streams) {
diff --git a/src/main/java/uk/yermak/audiobookconverter/Environment.java b/src/main/java/uk/yermak/audiobookconverter/Environment.java
new file mode 100644
index 00000000..3cf2dcd3
--- /dev/null
+++ b/src/main/java/uk/yermak/audiobookconverter/Environment.java
@@ -0,0 +1,116 @@
+package uk.yermak.audiobookconverter;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.Properties;
+
+public enum Environment {
+ DEV {
+ },
+
+ MAC {
+ protected String getAppPath() {
+ return com.apple.eio.FileManager.getPathToApplicationBundle() + "/";
+ }
+
+ @Override
+ protected File getConfigFilePath(File file) {
+ return new File(getAppPath(), "Contents/app/path.properties");
+ }
+ },
+
+ LINUX {
+ @Override
+ protected File getConfigFilePath(File file) {
+ return new File("../lib/app/path.properties");
+
+ }
+ },
+
+ WINDOWS {
+ };
+ static Environment current;
+ private static Properties properties = new Properties();
+
+ static {
+ if (LINUX.isLinux()) current = LINUX;
+ if (MAC.isMac()) current = MAC;
+ if (WINDOWS.isWindows()) current = WINDOWS;
+ if (DEV.isDebug()) current = DEV;
+ properties = current.loadAppProperties();
+ }
+
+ final static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+
+
+ public static final String FFPROBE = current.getPath("ffprobe");
+ public static final String MP4INFO = current.getPath("mp4info").replaceAll(" ", "\\ ");
+ public static final String MP4ART = current.getPath("mp4art").replaceAll(" ", "\\ ");
+ public final static String FFMPEG = current.getPath("ffmpeg").replaceAll(" ", "\\ ");
+
+
+
+ private boolean isDebug() {
+ String debug = System.getenv("DEBUG");
+ return (StringUtils.isNotEmpty(debug)) && Boolean.parseBoolean(debug);
+ }
+
+ public boolean isWindows() {
+ return System.getProperty("os.name").contains("Windows");
+ }
+
+ public boolean isLinux() {
+ return System.getProperty("os.name").contains("Linux");
+ }
+
+ public boolean isMac() {
+ return System.getProperty("os.name").contains("Mac OS X");
+ }
+
+
+ String getPath(String command) {
+ return getAppPath() + properties.getProperty(command);
+ }
+
+ protected String getAppPath() {
+ return "";
+ }
+
+ protected File getConfigFilePath(File file) {
+ return new File("app/path.properties");
+ }
+
+ synchronized Properties loadAppProperties() {
+ if (properties.isEmpty()) {
+ File file = null;
+ file = getConfigFilePath(file);
+
+ if (file.exists()) {
+ try (FileInputStream in = new FileInputStream(file)) {
+ properties.load(in);
+ } catch (IOException e) {
+ logger.error("Error during loading properties", e);
+ }
+ } else {
+ logger.error("Path properties is not found at: ", file.getPath());
+ }
+ }
+ return properties;
+ }
+
+
+ public static File getInitialDirecotory(String sourceFolder) {
+ if (sourceFolder == null) {
+ return new File(System.getProperty("user.home"));
+ }
+ File file = new File(sourceFolder);
+ return file.exists() ? file : getInitialDirecotory(file.getParent());
+ }
+}
diff --git a/src/main/java/uk/yermak/audiobookconverter/FFMediaLoader.java b/src/main/java/uk/yermak/audiobookconverter/FFMediaLoader.java
index 713d809c..b63be59c 100644
--- a/src/main/java/uk/yermak/audiobookconverter/FFMediaLoader.java
+++ b/src/main/java/uk/yermak/audiobookconverter/FFMediaLoader.java
@@ -13,7 +13,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.yermak.audiobookconverter.fx.ConversionContext;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
import java.io.File;
import java.io.IOException;
@@ -43,7 +42,7 @@ public FFMediaLoader(List files, ConversionGroup conversionGroup) {
public List loadMediaInfo() {
logger.info("Loading media info");
try {
- FFprobe ffprobe = new FFprobe(Utils.FFPROBE);
+ FFprobe ffprobe = new FFprobe(Environment.FFPROBE);
List media = new ArrayList<>();
for (String fileName : fileNames) {
Future futureLoad = mediaExecutor.submit(new MediaInfoCallable(ffprobe, fileName, conversionGroup));
@@ -223,7 +222,7 @@ static void searchForPosters(List media) {
List pictures = new ArrayList<>();
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
for (File d : searchDirs) {
pictures.addAll(findPictures(d));
}
diff --git a/src/main/java/uk/yermak/audiobookconverter/FFMpegConcatenator.java b/src/main/java/uk/yermak/audiobookconverter/FFMpegConcatenator.java
index 35921cac..0444d8aa 100644
--- a/src/main/java/uk/yermak/audiobookconverter/FFMpegConcatenator.java
+++ b/src/main/java/uk/yermak/audiobookconverter/FFMpegConcatenator.java
@@ -69,7 +69,10 @@ public void concat() throws IOException, InterruptedException {
logger.debug("Starting concat with options {}", String.join(" ", concatOptions));
//falling back to Runtime.exec() due to JDK specific way of interpreting quoted arguments in ProcessBuilder https://bugs.openjdk.java.net/browse/JDK-8131908
- process = Runtime.getRuntime().exec( String.join(" ", concatOptions));
+// process = Runtime.getRuntime().exec( String.join(" ", concatOptions));
+
+ ProcessBuilder pb = new ProcessBuilder (concatOptions);
+ process = pb.start();
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamCopier.copy(process.getInputStream(), out);
diff --git a/src/main/java/uk/yermak/audiobookconverter/FFMpegOptimizer.java b/src/main/java/uk/yermak/audiobookconverter/FFMpegOptimizer.java
index 61c150b4..41321f03 100644
--- a/src/main/java/uk/yermak/audiobookconverter/FFMpegOptimizer.java
+++ b/src/main/java/uk/yermak/audiobookconverter/FFMpegOptimizer.java
@@ -61,7 +61,7 @@ private void optimize() throws IOException, InterruptedException {
try {
String[] optimize = {
- Utils.FFMPEG,
+ Environment.FFMPEG,
"-i", tempFile,
"-map", "0:v",
"-map", "0:a",
@@ -73,7 +73,11 @@ private void optimize() throws IOException, InterruptedException {
logger.debug("Starting optimisation with options {}", String.join(" ", optimize));
//falling back to Runtime.exec() due to JDK specific way of interpreting quoted arguments in ProcessBuilder https://bugs.openjdk.java.net/browse/JDK-8131908
- process = Runtime.getRuntime().exec( String.join(" ", optimize));
+
+ ProcessBuilder pb = new ProcessBuilder (optimize);
+ process = pb.start();
+
+// process = Runtime.getRuntime().exec( String.join(" ", optimize));
ByteArrayOutputStream out = new ByteArrayOutputStream();
StreamCopier.copy(process.getInputStream(), out);
diff --git a/src/main/java/uk/yermak/audiobookconverter/FFmpegArtWorkExtractor.java b/src/main/java/uk/yermak/audiobookconverter/FFmpegArtWorkExtractor.java
index e7ecb3e6..4e1dff6e 100644
--- a/src/main/java/uk/yermak/audiobookconverter/FFmpegArtWorkExtractor.java
+++ b/src/main/java/uk/yermak/audiobookconverter/FFmpegArtWorkExtractor.java
@@ -1,7 +1,6 @@
package uk.yermak.audiobookconverter;
import javafx.application.Platform;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -30,7 +29,7 @@ public ArtWork call() throws Exception {
throw new InterruptedException("ArtWork loading was interrupted");
String poster = Utils.getTmp(mediaInfo.hashCode(), stream, format);
//TODO consider replacing with m4art extract for m4b files
- ProcessBuilder pictureProcessBuilder = new ProcessBuilder(Utils.FFMPEG,
+ ProcessBuilder pictureProcessBuilder = new ProcessBuilder(Environment.FFMPEG,
"-i", mediaInfo.getFileName(),
"-map", "0:" + stream,
"-y",
@@ -54,7 +53,7 @@ public ArtWork call() throws Exception {
ArtWorkBean artWorkBean = new ArtWorkBean(poster);
Platform.runLater(() -> {
if (!conversionGroup.isOver() && !conversionGroup.isStarted() && !conversionGroup.isDetached()) {
- ConverterApplication.getContext().addPosterIfMissingWithDelay(artWorkBean);
+ AudiobookConverter.getContext().addPosterIfMissingWithDelay(artWorkBean);
}
});
return artWorkBean;
diff --git a/src/main/java/uk/yermak/audiobookconverter/Format.java b/src/main/java/uk/yermak/audiobookconverter/Format.java
index 57e73257..ae531cfc 100644
--- a/src/main/java/uk/yermak/audiobookconverter/Format.java
+++ b/src/main/java/uk/yermak/audiobookconverter/Format.java
@@ -1,7 +1,5 @@
package uk.yermak.audiobookconverter;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -34,7 +32,7 @@ public boolean ffmpegCompatible() {
@Override
public List getReencodingOptions(MediaInfo mediaInfo, String progressUri, String outputFileName, OutputParameters outputParameters) {
List options = new ArrayList<>();
- options.add(Utils.FFMPEG);
+ options.add(Environment.FFMPEG);
if (mediaInfo.getOffset() != -1) {
options.add("-ss");
options.add(toFFMpegTime(mediaInfo.getOffset()));
@@ -105,7 +103,7 @@ public Integer defaultVbrQuality() {
@Override
public List getConcatOptions(String fileListFileName, MetadataBuilder metadataBuilder, String progressUri, String outputFileName) {
List options = new ArrayList<>();
- options.add(Utils.FFMPEG);
+ options.add(Environment.FFMPEG);
options.add("-protocol_whitelist");
options.add("file,pipe,concat");
options.add("-f");
@@ -180,7 +178,7 @@ public Boolean defaultCBR() {
@Override
public List getConcatOptions(String fileListFileName, MetadataBuilder metadataBuilder, String progressUri, String outputFileName) {
List options = new ArrayList<>();
- options.add(Utils.FFMPEG);
+ options.add(Environment.FFMPEG);
options.add("-protocol_whitelist");
options.add("file,pipe,concat");
options.add("-f");
@@ -209,7 +207,7 @@ public List getConcatOptions(String fileListFileName, MetadataBuilder me
@Override
public List getReencodingOptions(MediaInfo mediaInfo, String progressUri, String outputFileName, OutputParameters outputParameters) {
List options = new ArrayList<>();
- options.add(Utils.FFMPEG);
+ options.add(Environment.FFMPEG);
if (mediaInfo.getOffset() != -1) {
options.add("-ss");
options.add(toFFMpegTime(mediaInfo.getOffset()));
@@ -331,7 +329,7 @@ public static Format instance(String extension) {
public List getReencodingOptions(MediaInfo mediaInfo, String progressUri, String outputFileName, OutputParameters outputParameters) {
List options = new ArrayList<>();
- options.add(Utils.FFMPEG);
+ options.add(Environment.FFMPEG);
if (mediaInfo.getOffset() != -1) {
options.add("-ss");
options.add(toFFMpegTime(mediaInfo.getOffset()));
@@ -376,7 +374,7 @@ public List getReencodingOptions(MediaInfo mediaInfo, String progressUri
public List getTranscodingOptions(MediaInfo mediaInfo, String progressUri, String outputFileName) {
List options = new ArrayList<>();
- options.add(Utils.FFMPEG);
+ options.add(Environment.FFMPEG);
if (mediaInfo.getOffset() != -1) {
options.add("-ss");
options.add(toFFMpegTime(mediaInfo.getOffset()));
@@ -403,7 +401,7 @@ public List getTranscodingOptions(MediaInfo mediaInfo, String progressUr
}
public List getConcatOptions(String fileListFileName, MetadataBuilder metadataBuilder, String progressUri, String outputFileName) {
- String[] strings = {Utils.FFMPEG,
+ String[] strings = {Environment.FFMPEG,
"-protocol_whitelist", "file,pipe,concat",
"-vn",
"-f", "concat",
diff --git a/src/main/java/uk/yermak/audiobookconverter/MediaInfoProxy.java b/src/main/java/uk/yermak/audiobookconverter/MediaInfoProxy.java
index 4c8d2f53..b60e00d1 100644
--- a/src/main/java/uk/yermak/audiobookconverter/MediaInfoProxy.java
+++ b/src/main/java/uk/yermak/audiobookconverter/MediaInfoProxy.java
@@ -1,7 +1,5 @@
package uk.yermak.audiobookconverter;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
-
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Future;
@@ -42,7 +40,7 @@ public String getDetails() {
}
public long getDuration() {
- return (long) (this.getMediaInfo().getDuration() / ConverterApplication.getContext().getOutputParameters().getSpeed());
+ return (long) (this.getMediaInfo().getDuration() / AudiobookConverter.getContext().getOutputParameters().getSpeed());
}
@Override
diff --git a/src/main/java/uk/yermak/audiobookconverter/MediaTrackAdaptor.java b/src/main/java/uk/yermak/audiobookconverter/MediaTrackAdaptor.java
index e4a35637..a12d77af 100644
--- a/src/main/java/uk/yermak/audiobookconverter/MediaTrackAdaptor.java
+++ b/src/main/java/uk/yermak/audiobookconverter/MediaTrackAdaptor.java
@@ -1,7 +1,5 @@
package uk.yermak.audiobookconverter;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
-
import java.util.List;
import java.util.Objects;
@@ -50,7 +48,7 @@ public int getBitrate() {
@Override
public long getDuration() {
- return (long) (duration / ConverterApplication.getContext().getOutputParameters().getSpeed());
+ return (long) (duration / AudiobookConverter.getContext().getOutputParameters().getSpeed());
}
@Override
diff --git a/src/main/java/uk/yermak/audiobookconverter/Mp4v2ArtBuilder.java b/src/main/java/uk/yermak/audiobookconverter/Mp4v2ArtBuilder.java
index c65bb5eb..6d1b0f57 100644
--- a/src/main/java/uk/yermak/audiobookconverter/Mp4v2ArtBuilder.java
+++ b/src/main/java/uk/yermak/audiobookconverter/Mp4v2ArtBuilder.java
@@ -36,7 +36,7 @@ public void coverArt(String outputFileName) throws IOException, InterruptedExcep
public void updateSinglePoster(ArtWork poster, int index, String outputFileName) throws IOException, InterruptedException {
Process process = null;
try {
- ProcessBuilder artProcessBuilder = new ProcessBuilder(Utils.MP4ART,
+ ProcessBuilder artProcessBuilder = new ProcessBuilder(Environment.MP4ART,
"--art-index", String.valueOf(index),
"--add", poster.getFileName(),
outputFileName);
diff --git a/src/main/java/uk/yermak/audiobookconverter/Utils.java b/src/main/java/uk/yermak/audiobookconverter/Utils.java
index e863df06..e64e7a5a 100644
--- a/src/main/java/uk/yermak/audiobookconverter/Utils.java
+++ b/src/main/java/uk/yermak/audiobookconverter/Utils.java
@@ -9,14 +9,12 @@
import org.stringtemplate.v4.*;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.text.DecimalFormat;
import java.time.Duration;
import java.util.Locale;
import java.util.Map;
-import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
@@ -25,7 +23,6 @@
*/
public class Utils {
final static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private static final Properties PATH = new Properties();
public static String getTmp(long jobId, long fileId, String extension) {
return new File(System.getProperty("java.io.tmpdir"), "~" + Version.getVersionString() + "_" + jobId + "_" + fileId + "." + extension).getAbsolutePath();
@@ -119,14 +116,6 @@ public static long checksumCRC32(File file) {
}
}
- public static File getInitialDirecotory(String sourceFolder) {
- if (sourceFolder == null) {
- return new File(System.getProperty("user.home"));
- }
- File file = new File(sourceFolder);
- return file.exists() ? file : getInitialDirecotory(file.getParent());
- }
-
public static String formatTime(double millis) {
return formatTime((long) millis);
}
@@ -193,46 +182,6 @@ public static String renderPart(Part part, Map> c
}
- public static boolean isWindows() {
- return System.getProperty("os.name").contains("Windows");
- }
-
- public static boolean isLinux() {
- return System.getProperty("os.name").contains("Linux");
- }
-
- public final static String FFMPEG = getPath("ffmpeg");
-
- public static final String MP4ART = getPath("mp4art");
-
- public static final String MP4INFO = getPath("mp4info");
-
- public static final String FFPROBE = getPath("ffprobe");
-
- private static String getPath(String binary) {
- String property = loadAppProperties().getProperty(binary);
- if (property != null) {
- return property;
- }
- return binary + (isWindows() ? ".exe" : "");
-
- }
-
- public static synchronized Properties loadAppProperties() {
- if (PATH.isEmpty()) {
- File file = new File((isLinux()) ? "../lib/app/path.properties" : "app/path.properties");
-
- if (file.exists()) {
- try (FileInputStream in = new FileInputStream(file)) {
- PATH.load(in);
- } catch (IOException e) {
- logger.error("Error during loading properties", e);
- }
- }
- }
- return PATH;
- }
-
private static class DurationRender implements AttributeRenderer {
diff --git a/src/main/java/uk/yermak/audiobookconverter/Version.java b/src/main/java/uk/yermak/audiobookconverter/Version.java
index 9590ff54..4095cc9f 100644
--- a/src/main/java/uk/yermak/audiobookconverter/Version.java
+++ b/src/main/java/uk/yermak/audiobookconverter/Version.java
@@ -3,7 +3,7 @@
public class Version {
public static String getVersionString() {
- return "AudioBookConverter-#{APP_VERSION}#";
+ return "AudioBookConverter-5.6.3";
}
}
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/ArtWorkController.java b/src/main/java/uk/yermak/audiobookconverter/fx/ArtWorkController.java
index 0bfc85a8..fa6afde7 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/ArtWorkController.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/ArtWorkController.java
@@ -35,7 +35,7 @@ public class ArtWorkController {
@FXML
private void initialize() {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
imageList.setCellFactory(param -> new ArtWorkListCell());
imageList.setItems(context.getPosters());
context.addContextDetachListener(observable -> context.getPosters().clear());
@@ -45,14 +45,14 @@ private void initialize() {
private void addImage(ActionEvent actionEvent) {
FileChooser fileChooser = new FileChooser();
String sourceFolder = AppProperties.getProperty("source.folder");
- fileChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));
+ fileChooser.setInitialDirectory(Environment.getInitialDirecotory(sourceFolder));
fileChooser.setTitle("Select JPG or PNG file");
fileChooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("jpg", "*.jpg", "*.jpeg", "*.jfif"),
new FileChooser.ExtensionFilter("png", "*.png"),
new FileChooser.ExtensionFilter("bmp", "*.bmp"));
- File file = fileChooser.showOpenDialog(ConverterApplication.getEnv().getWindow());
+ File file = fileChooser.showOpenDialog(AudiobookConverter.getEnv().getWindow());
logger.debug("Opened dialog for art image in folder: {}", sourceFolder);
if (file != null) {
imageList.getItems().add(new ArtWorkBean(Utils.tempCopy(file.getAbsolutePath())));
@@ -64,7 +64,7 @@ private void addImage(ActionEvent actionEvent) {
private void removeImage(ActionEvent actionEvent) {
int toRemove = imageList.getSelectionModel().getSelectedIndex();
if (toRemove == -1) return;
- ConverterApplication.getContext().removePoster(toRemove);
+ AudiobookConverter.getContext().removePoster(toRemove);
// imageList.getItems().remove(toRemove);
logger.info("Removed art work #{}", toRemove);
}
@@ -75,7 +75,7 @@ private void left(ActionEvent actionEvent) {
if (selectedIndices.size() == 1) {
Integer selected = selectedIndices.get(0);
if (selected > 0) {
- ConverterApplication.getContext().movePosterUp(selected);
+ AudiobookConverter.getContext().movePosterUp(selected);
imageList.getSelectionModel().clearAndSelect(selected - 1);
logger.debug("Image {} moved left", selected);
}
@@ -90,7 +90,7 @@ private void right(ActionEvent actionEvent) {
ObservableList items = imageList.getItems();
Integer selected = selectedIndices.get(0);
if (selected < items.size() - 1) {
- ConverterApplication.getContext().movePosterUp(selected + 1);
+ AudiobookConverter.getContext().movePosterUp(selected + 1);
imageList.getSelectionModel().clearAndSelect(selected + 1);
logger.debug("Image {} moved right", selected);
}
@@ -105,12 +105,12 @@ public void pasteImage(ActionEvent actionEvent) {
if (transferable.isDataFlavorSupported(DataFlavor.imageFlavor)) {
java.awt.Image image = (java.awt.Image) transferable.getTransferData(DataFlavor.imageFlavor);
Image fimage = awtImageToFX(image);
- ConverterApplication.getContext().addPosterIfMissingWithDelay(new ArtWorkImage(fimage));
+ AudiobookConverter.getContext().addPosterIfMissingWithDelay(new ArtWorkImage(fimage));
} else if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
java.util.List artFiles = (java.util.List) transferable.getTransferData(DataFlavor.javaFileListFlavor);
artFiles.stream().filter(s -> ArrayUtils.contains(ArtWork.IMAGE_EXTENSIONS, FilenameUtils.getExtension(s))).forEach(f -> {
- ConverterApplication.getContext().addPosterIfMissingWithDelay(new ArtWorkBean(Utils.tempCopy(f)));
+ AudiobookConverter.getContext().addPosterIfMissingWithDelay(new ArtWorkBean(Utils.tempCopy(f)));
});
}
}
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/BookInfoController.java b/src/main/java/uk/yermak/audiobookconverter/fx/BookInfoController.java
index b994a27b..64e81d42 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/BookInfoController.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/BookInfoController.java
@@ -1,8 +1,6 @@
package uk.yermak.audiobookconverter.fx;
import javafx.application.Platform;
-import javafx.beans.InvalidationListener;
-import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
@@ -14,6 +12,7 @@
import javafx.scene.control.TextField;
import org.apache.commons.lang3.StringUtils;
import uk.yermak.audiobookconverter.AudioBookInfo;
+import uk.yermak.audiobookconverter.AudiobookConverter;
import uk.yermak.audiobookconverter.MediaInfo;
import uk.yermak.audiobookconverter.fx.util.TextFieldValidator;
@@ -45,10 +44,10 @@ public class BookInfoController {
private void initialize() {
MenuItem menuItem = new MenuItem("Remove");
- genre.setItems(ConverterApplication.getContext().loadGenres());
+ genre.setItems(AudiobookConverter.getContext().loadGenres());
menuItem.setOnAction(event -> {
genre.getItems().remove(genre.getSelectionModel().getSelectedIndex());
- ConverterApplication.getContext().saveGenres();
+ AudiobookConverter.getContext().saveGenres();
});
ContextMenu contextMenu = new ContextMenu(menuItem);
@@ -59,7 +58,7 @@ private void initialize() {
genre.hide();
});
- ObservableList media = ConverterApplication.getContext().getMedia();
+ ObservableList media = AudiobookConverter.getContext().getMedia();
// media.addListener((InvalidationListener) observable -> updateTags(media, media.isEmpty()));
media.addListener((ListChangeListener super MediaInfo>) change -> updateTags(media, media.isEmpty()));
@@ -70,27 +69,27 @@ private void initialize() {
bookNo.setTextFormatter(new TextFieldValidator(TextFieldValidator.ValidationModus.MAX_INTEGERS, 3).getFormatter());
year.setTextFormatter(new TextFieldValidator(TextFieldValidator.ValidationModus.MAX_INTEGERS, 4).getFormatter());
- title.textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().title().set(title.getText()));
+ title.textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().title().set(title.getText()));
- writer.textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().writer().set(writer.getText()));
- narrator.textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().narrator().set(narrator.getText()));
+ writer.textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().writer().set(writer.getText()));
+ narrator.textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().narrator().set(narrator.getText()));
- genre.valueProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().genre().set(genre.getValue()));
- genre.getEditor().textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().genre().set(genre.getEditor().getText()));
+ genre.valueProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().genre().set(genre.getValue()));
+ genre.getEditor().textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().genre().set(genre.getEditor().getText()));
- series.textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().series().set(series.getText()));
+ series.textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().series().set(series.getText()));
bookNo.textProperty().addListener(o -> {
if (StringUtils.isNotBlank(bookNo.getText()))
- ConverterApplication.getContext().getBookInfo().bookNumber().set(bookNo.getText());
+ AudiobookConverter.getContext().getBookInfo().bookNumber().set(bookNo.getText());
});
- year.textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().year().set(year.getText()));
- comment.textProperty().addListener(o -> ConverterApplication.getContext().getBookInfo().comment().set(comment.getText()));
+ year.textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().year().set(year.getText()));
+ comment.textProperty().addListener(o -> AudiobookConverter.getContext().getBookInfo().comment().set(comment.getText()));
- ConverterApplication.getContext().addContextDetachListener(observable -> Platform.runLater(() -> clearTags()));
+ AudiobookConverter.getContext().addContextDetachListener(observable -> Platform.runLater(() -> clearTags()));
}
private void updateTags(ObservableList media, boolean clear) {
- if (ConverterApplication.getContext().getBook() == null) {
+ if (AudiobookConverter.getContext().getBook() == null) {
if (clear) {
clearTags();
} else {
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/BookStructureComponent.java b/src/main/java/uk/yermak/audiobookconverter/fx/BookStructureComponent.java
index cb31c809..19e31fba 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/BookStructureComponent.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/BookStructureComponent.java
@@ -115,7 +115,7 @@ void moveChapterUp(ActionEvent event) {
}
void updateBookStructure() {
- Book book = ConverterApplication.getContext().getBook();
+ Book book = AudiobookConverter.getContext().getBook();
getRoot().getChildren().clear();
book.getParts().forEach(p -> {
TreeItem partItem = new TreeItem<>(p);
@@ -128,7 +128,7 @@ void updateBookStructure() {
});
getRoot().getChildren().forEach(t -> t.setExpanded(true));
refresh();
- ConverterApplication.getContext().getOutputParameters().updateAuto(book.getMedia());
+ AudiobookConverter.getContext().getOutputParameters().updateAuto(book.getMedia());
}
void moveChapterDown(ActionEvent event) {
@@ -172,7 +172,7 @@ private void subTracks(ActionEvent actionEvent) {
Organisable organisable = selectedCells.get(0).getTreeItem().getValue();
if (organisable instanceof MediaInfo) {
- SubTracksDialog dialog = new SubTracksDialog(ConverterApplication.getEnv().getWindow());
+ SubTracksDialog dialog = new SubTracksDialog(AudiobookConverter.getEnv().getWindow());
Optional> result = dialog.showAndWait();
result.ifPresent(r -> {
@@ -184,7 +184,7 @@ private void subTracks(ActionEvent actionEvent) {
}
private void extractSubtracks(MediaInfo mediaInfo, Boolean wrapWithChapters, long interval) {
- double speed = ConverterApplication.getContext().getOutputParameters().getSpeed();
+ double speed = AudiobookConverter.getContext().getOutputParameters().getSpeed();
long duration = mediaInfo.getDuration();
if (speed != 1.0) {
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/DialogHelper.java b/src/main/java/uk/yermak/audiobookconverter/fx/DialogHelper.java
index 4dc46a2a..697b66d7 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/DialogHelper.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/DialogHelper.java
@@ -9,9 +9,7 @@
import org.apache.commons.io.IOCase;
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
-import uk.yermak.audiobookconverter.AppProperties;
-import uk.yermak.audiobookconverter.AudioBookInfo;
-import uk.yermak.audiobookconverter.Utils;
+import uk.yermak.audiobookconverter.*;
import uk.yermak.audiobookconverter.fx.util.Comparators;
import java.io.File;
@@ -31,15 +29,15 @@ public class DialogHelper {
static String selectOutputFile(AudioBookInfo audioBookInfo) {
- JfxEnv env = ConverterApplication.getEnv();
+ JfxEnv env = AudiobookConverter.getEnv();
final FileChooser fileChooser = new FileChooser();
String outputFolder = AppProperties.getProperty("output.folder");
- fileChooser.setInitialDirectory(Utils.getInitialDirecotory(outputFolder));
+ fileChooser.setInitialDirectory(Environment.getInitialDirecotory(outputFolder));
fileChooser.setInitialFileName(Utils.getOuputFilenameSuggestion(audioBookInfo));
fileChooser.setTitle("Save AudioBook");
fileChooser.getExtensionFilters().addAll(
- new FileChooser.ExtensionFilter(ConverterApplication.getContext().getOutputParameters().getFormat().toString(), "*." + ConverterApplication.getContext().getOutputParameters().getFormat().toString())
+ new FileChooser.ExtensionFilter(AudiobookConverter.getContext().getOutputParameters().getFormat().toString(), "*." + AudiobookConverter.getContext().getOutputParameters().getFormat().toString())
);
File file = fileChooser.showSaveDialog(env.getWindow());
if (file == null) return null;
@@ -49,10 +47,10 @@ static String selectOutputFile(AudioBookInfo audioBookInfo) {
}
public static List selectFilesDialog() {
- Window window = ConverterApplication.getEnv().getWindow();
+ Window window = AudiobookConverter.getEnv().getWindow();
final FileChooser fileChooser = new FileChooser();
String sourceFolder = AppProperties.getProperty("source.folder");
- fileChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));
+ fileChooser.setInitialDirectory(Environment.getInitialDirecotory(sourceFolder));
StringJoiner filetypes = new StringJoiner("/");
Arrays.stream(FILE_EXTENSIONS).map(String::toUpperCase).forEach(filetypes::add);
@@ -74,10 +72,10 @@ public static List selectFilesDialog() {
}
public static List selectFolderDialog() {
- Window window = ConverterApplication.getEnv().getWindow();
+ Window window = AudiobookConverter.getEnv().getWindow();
DirectoryChooser directoryChooser = new DirectoryChooser();
String sourceFolder = AppProperties.getProperty("source.folder");
- directoryChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));
+ directoryChooser.setInitialDirectory(Environment.getInitialDirecotory(sourceFolder));
StringJoiner filetypes = new StringJoiner("/");
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/FileListComponent.java b/src/main/java/uk/yermak/audiobookconverter/fx/FileListComponent.java
index 19fa0978..35669eff 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/FileListComponent.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/FileListComponent.java
@@ -4,6 +4,7 @@
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.*;
+import uk.yermak.audiobookconverter.AudiobookConverter;
import uk.yermak.audiobookconverter.MediaInfo;
import uk.yermak.audiobookconverter.fx.util.ContextMenuBuilder;
import uk.yermak.audiobookconverter.fx.util.ContextMenuListCell;
@@ -17,12 +18,12 @@ public FileListComponent() {
setCellFactory(ContextMenuListCell.forListView(filesContextMenuBuilder()));
getSelectionModel().getSelectedItems().addListener((ListChangeListener) c -> {
- ConverterApplication.getContext().getSelectedMedia().clear();
- ConverterApplication.getContext().getSelectedMedia().addAll(c.getList());
+ AudiobookConverter.getContext().getSelectedMedia().clear();
+ AudiobookConverter.getContext().getSelectedMedia().addAll(c.getList());
});
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList media = context.getMedia();
setItems(media);
getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
@@ -101,7 +102,7 @@ void removeFiles(ActionEvent event) {
}
public void reselect() {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList selectedMedia = context.getSelectedMedia();
ObservableList media = context.getMedia();
List change = new ArrayList<>(selectedMedia);
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/FilesController.java b/src/main/java/uk/yermak/audiobookconverter/fx/FilesController.java
index 257cf230..7b37f77f 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/FilesController.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/FilesController.java
@@ -95,7 +95,7 @@ public void initialize() {
initFileOpenMenu();
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList selectedMedia = context.getSelectedMedia();
selectedMedia.addListener((InvalidationListener) observable -> {
@@ -109,7 +109,7 @@ public void initialize() {
bookStructure.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
bookStructure.getSelectionModel().getSelectedItems().addListener((ListChangeListener>) c -> {
- List list = ConverterApplication.getContext().getSelectedMedia();
+ List list = AudiobookConverter.getContext().getSelectedMedia();
list.clear();
List newList = c.getList().stream().flatMap(item -> item.getValue().getMedia().stream()).collect(Collectors.toList());
list.addAll(newList);
@@ -189,19 +189,19 @@ public void selectFolder() {
private void processFiles(List fileNames) {
FFMediaLoader mediaLoader = createMediaLoader(fileNames);
- ConverterApplication.getContext().setMediaLoader(mediaLoader);
+ AudiobookConverter.getContext().setMediaLoader(mediaLoader);
List addedMedia = mediaLoader.loadMediaInfo();
if (chaptersMode.get()) {
- ConverterApplication.getContext().constructBook(addedMedia);
+ AudiobookConverter.getContext().constructBook(addedMedia);
bookStructure.updateBookStructure();
} else {
- ConverterApplication.getContext().addNewMedia(addedMedia);
+ AudiobookConverter.getContext().addNewMedia(addedMedia);
}
}
private FFMediaLoader createMediaLoader(List fileNames) {
- return new FFMediaLoader(fileNames, ConverterApplication.getContext().getConversionGroup());
+ return new FFMediaLoader(fileNames, AudiobookConverter.getContext().getConversionGroup());
}
public void selectFiles() {
@@ -228,8 +228,8 @@ public void remove(ActionEvent event) {
public void clear(ActionEvent event) {
fileList.getItems().clear();
- ConverterApplication.getContext().getConversionGroup().cancel();
- ConverterApplication.getContext().detach();
+ AudiobookConverter.getContext().getConversionGroup().cancel();
+ AudiobookConverter.getContext().detach();
bookStructure.setRoot(null);
filesChapters.getTabs().remove(filesTab);
filesChapters.getTabs().remove(chaptersTab);
@@ -261,10 +261,10 @@ public void editChapter(ActionEvent event){
public void start(ActionEvent actionEvent) {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
if (context.getBook() == null && fileList.getItems().isEmpty()) return;
- String outputDestination = DialogHelper.selectOutputFile(ConverterApplication.getContext().getBookInfo());
+ String outputDestination = DialogHelper.selectOutputFile(AudiobookConverter.getContext().getBookInfo());
if (outputDestination == null) {
return;
@@ -273,7 +273,7 @@ public void start(ActionEvent actionEvent) {
// ObservableList mediaInfos = FXCollections.observableArrayList(fileList.getItems());
- ConversionGroup conversionGroup = ConverterApplication.getContext().detach();
+ ConversionGroup conversionGroup = AudiobookConverter.getContext().detach();
/* TODO!!!!
conversionGroup.setOutputParameters(new OutputParameters(context.getOutputParameters()));
@@ -318,11 +318,11 @@ public void importChapters(ActionEvent actionEvent) {
ObservableList mediaInfos = FXCollections.observableArrayList(fileList.getItems());
- Book book = new Book(ConverterApplication.getContext().getBookInfo());
+ Book book = new Book(AudiobookConverter.getContext().getBookInfo());
TreeItem bookItem = new TreeItem<>(book);
bookStructure.setRoot(bookItem);
- ConverterApplication.getContext().setBook(book);
+ AudiobookConverter.getContext().setBook(book);
bookStructure.updateBookStructure();
@@ -364,7 +364,7 @@ public void split(ActionEvent event) {
@FXML
public void pause(ActionEvent actionEvent) {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
if (context.isPaused()) {
context.resumeConversions();
pauseButton.setText("Pause all");
@@ -375,42 +375,42 @@ public void pause(ActionEvent actionEvent) {
}
public void stop(ActionEvent actionEvent) {
- ConverterApplication.getContext().stopConversions();
+ AudiobookConverter.getContext().stopConversions();
}
@FXML
protected void openLink(ActionEvent event) {
Hyperlink source = (Hyperlink) event.getSource();
- ConverterApplication.getEnv().showDocument(source.getUserData().toString());
+ AudiobookConverter.getEnv().showDocument(source.getUserData().toString());
}
public void openWebSite(ActionEvent actionEvent) {
- ConverterApplication.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter");
+ AudiobookConverter.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter");
}
public void openAboutPage(ActionEvent actionEvent) {
- ConverterApplication.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter/about");
+ AudiobookConverter.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter/about");
}
public void openFAQ(ActionEvent actionEvent) {
- ConverterApplication.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter/faq");
+ AudiobookConverter.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter/faq");
}
public void openDiscussions(ActionEvent actionEvent) {
- ConverterApplication.getEnv().showDocument("https://github.com/yermak/AudioBookConverter/discussions");
+ AudiobookConverter.getEnv().showDocument("https://github.com/yermak/AudioBookConverter/discussions");
}
public void openDonate() {
- ConverterApplication.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter/donate");
+ AudiobookConverter.getEnv().showDocument("https://www.recoupler.com/products/audiobookconverter/donate");
}
public void checkVersion(ActionEvent actionEvent) {
- ConverterApplication.checkNewVersion();
+ AudiobookConverter.checkNewVersion();
}
public void exit(ActionEvent actionEvent) {
logger.info("Closing application");
- ConverterApplication.getContext().stopConversions();
+ AudiobookConverter.getContext().stopConversions();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/MediaPlayerController.java b/src/main/java/uk/yermak/audiobookconverter/fx/MediaPlayerController.java
index ee343e05..38c9ef70 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/MediaPlayerController.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/MediaPlayerController.java
@@ -12,6 +12,7 @@
import javafx.util.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import uk.yermak.audiobookconverter.AudiobookConverter;
import uk.yermak.audiobookconverter.MediaInfo;
import uk.yermak.audiobookconverter.Utils;
@@ -59,7 +60,7 @@ private void disablePlayer(boolean disable) {
}
public void play(ActionEvent event) {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
List selectedMedia = context.getSelectedMedia();
if (selectedMedia.size() == 1) {
@@ -99,7 +100,7 @@ private void toggleMediaPlayer() {
private void playMedias(MediaInfo selected) {
playingTrack = selected;
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList media = context.getMedia();
if (media.indexOf(selected) > media.size() - 1) return;
@@ -149,7 +150,7 @@ private void playMedias(MediaInfo selected) {
}
private MediaInfo findNext(MediaInfo selected) {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList media = context.getMedia();
int i = media.indexOf(selected);
diff --git a/src/main/java/uk/yermak/audiobookconverter/fx/OutputController.java b/src/main/java/uk/yermak/audiobookconverter/fx/OutputController.java
index 1d2c6fbe..d635ef31 100644
--- a/src/main/java/uk/yermak/audiobookconverter/fx/OutputController.java
+++ b/src/main/java/uk/yermak/audiobookconverter/fx/OutputController.java
@@ -7,7 +7,6 @@
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
-import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Slider;
@@ -28,10 +27,12 @@ public class OutputController {
public static final String DISABLED = "Disabled";
public static final String FORCE = "Always";
+
@FXML
public ComboBox outputFormatBox;
@FXML
public ComboBox presetBox;
+
public ComboBox force;
@FXML
@@ -62,7 +63,7 @@ public void cbr(ActionEvent actionEvent) {
bitRate.setDisable(false);
vbrQuality.setDisable(true);
refreshBitrates();
- ConverterApplication.getContext().getOutputParameters().setCbr(true);
+ AudiobookConverter.getContext().getOutputParameters().setCbr(true);
}
@@ -70,7 +71,7 @@ public void vbr(ActionEvent actionEvent) {
bitRate.setDisable(true);
vbrQuality.setDisable(false);
refreshVbrQuality();
- ConverterApplication.getContext().getOutputParameters().setCbr(false);
+ AudiobookConverter.getContext().getOutputParameters().setCbr(false);
}
@FXML
@@ -79,28 +80,28 @@ private void initialize() {
splitFileBox.getSelectionModel().select(0);
splitFileBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
switch (newValue) {
- case "parts" -> ConverterApplication.getContext().getOutputParameters().setSplitChapters(false);
- case "chapters" -> ConverterApplication.getContext().getOutputParameters().setSplitChapters(true);
+ case "parts" -> AudiobookConverter.getContext().getOutputParameters().setSplitChapters(false);
+ case "chapters" -> AudiobookConverter.getContext().getOutputParameters().setSplitChapters(true);
}
});
speedBox.valueProperty().addListener((observableValue, oldValue, newValue) -> {
if (newValue == null) return;
- ConverterApplication.getContext().setSpeed(Double.valueOf(newValue));
+ AudiobookConverter.getContext().setSpeed(Double.valueOf(newValue));
});
force.getSelectionModel().select(0);
force.valueProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue extends String> observableValue, String oldValue, String newValue) {
if (newValue == null) return;
- ConverterApplication.getContext().getOutputParameters().setForce(FORCE.equals(newValue));
+ AudiobookConverter.getContext().getOutputParameters().setForce(FORCE.equals(newValue));
}
});
outputFormatBox.getItems().addAll(Format.values());
outputFormatBox.getSelectionModel().select(0);
outputFormatBox.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
- ConverterApplication.getContext().getOutputParameters().setupFormat(newValue);
+ AudiobookConverter.getContext().getOutputParameters().setupFormat(newValue);
refreshFrequencies();
refreshBitrates();
refreshChannels();
@@ -121,14 +122,14 @@ public void changed(ObservableValue extends String> observableValue, String ol
if (!presetBox.getItems().contains(newValue)) {
presetBox.getItems().add(newValue);
Preset preset = Preset.copy(newValue, Preset.instance(oldValue));
- ConverterApplication.getContext().setOutputParameters(preset);
+ AudiobookConverter.getContext().setOutputParameters(preset);
} else {
Preset preset = Preset.instance(newValue);
- ConverterApplication.getContext().setOutputParameters(preset);
+ AudiobookConverter.getContext().setOutputParameters(preset);
}
});
- ConverterApplication.getContext().addOutputParametersChangeListener((observableValue, oldParams, newParams) -> {
+ AudiobookConverter.getContext().addOutputParametersChangeListener((observableValue, oldParams, newParams) -> {
outputFormatBox.setValue(newParams.getFormat());
if (!oldParams.getFormat().equals(newParams.getFormat())) {
refreshFrequencies();
@@ -148,7 +149,7 @@ public void changed(ObservableValue extends String> observableValue, String ol
refreshCBR();
refreshSpeeds();
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList media = context.getMedia();
@@ -191,14 +192,14 @@ public void changed(ObservableValue extends String> observableValue, String ol
});
media.addListener((InvalidationListener) observable -> updateParameters(media));
- ConverterApplication.getContext().addBookChangeListener((observableValue, oldBook, newBook) -> {
+ AudiobookConverter.getContext().addBookChangeListener((observableValue, oldBook, newBook) -> {
if (newBook != null) {
newBook.addListener(observable -> updateParameters(newBook.getMedia()));
}
});
- ConverterApplication.getContext().addOutputParametersChangeListener((observableValue, oldParams, newParams) -> {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ AudiobookConverter.getContext().addOutputParametersChangeListener((observableValue, oldParams, newParams) -> {
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
bitRate.setValue(String.valueOf(findNearestMatch(newParams.getBitRate(), format.bitrates(), format.defaultBitrate())));
frequency.setValue(String.valueOf(findNearestMatch(newParams.getFrequency(), format.frequencies(), format.defaultFrequency())));
channels.setValue(String.valueOf(findNearestMatch(newParams.getChannels(), format.channels(), format.defaultChannel())));
@@ -208,7 +209,7 @@ public void changed(ObservableValue extends String> observableValue, String ol
}
private void refreshCBR() {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
if (format.defaultCBR()) {
cbr.fire();
} else {
@@ -217,41 +218,41 @@ private void refreshCBR() {
}
private void refreshVbrQuality() {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
vbrQuality.setValue(format.defaultVbrQuality());
}
private void refreshCutoffs() {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
cutoff.getItems().clear();
cutoff.getItems().add(DISABLED);
- cutoff.getItems().addAll(ConverterApplication.getContext().getOutputParameters().getFormat().cutoffs().stream().map(String::valueOf).collect(Collectors.toList()));
+ cutoff.getItems().addAll(AudiobookConverter.getContext().getOutputParameters().getFormat().cutoffs().stream().map(String::valueOf).collect(Collectors.toList()));
cutoff.getSelectionModel().select(String.valueOf(format.defaultCutoff()));
}
private void refreshChannels() {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
channels.getItems().clear();
- channels.getItems().addAll(ConverterApplication.getContext().getOutputParameters().getFormat().channels().stream().map(String::valueOf).collect(Collectors.toList()));
+ channels.getItems().addAll(AudiobookConverter.getContext().getOutputParameters().getFormat().channels().stream().map(String::valueOf).collect(Collectors.toList()));
channels.getSelectionModel().select(String.valueOf(format.defaultChannel()));
}
private void refreshBitrates() {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
bitRate.getItems().clear();
- bitRate.getItems().addAll(ConverterApplication.getContext().getOutputParameters().getFormat().bitrates().stream().map(String::valueOf).collect(Collectors.toList()));
+ bitRate.getItems().addAll(AudiobookConverter.getContext().getOutputParameters().getFormat().bitrates().stream().map(String::valueOf).collect(Collectors.toList()));
bitRate.getSelectionModel().select(String.valueOf(format.defaultBitrate()));
}
private void refreshSpeeds() {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
speedBox.getItems().clear();
- speedBox.getItems().addAll(ConverterApplication.getContext().getOutputParameters().getFormat().speeds().stream().map(String::valueOf).collect(Collectors.toList()));
+ speedBox.getItems().addAll(AudiobookConverter.getContext().getOutputParameters().getFormat().speeds().stream().map(String::valueOf).collect(Collectors.toList()));
speedBox.getSelectionModel().select(String.valueOf(format.defaultSpeed()));
}
private void refreshFrequencies() {
- OutputParameters outputParameters = ConverterApplication.getContext().getOutputParameters();
+ OutputParameters outputParameters = AudiobookConverter.getContext().getOutputParameters();
Format format = outputParameters.getFormat();
frequency.getItems().clear();
frequency.getItems().addAll(outputParameters.getFormat().frequencies().stream().map(String::valueOf).collect(Collectors.toList()));
@@ -259,10 +260,10 @@ private void refreshFrequencies() {
}
private void updateParameters(List media) {
- Book book = ConverterApplication.getContext().getBook();
+ Book book = AudiobookConverter.getContext().getBook();
if (media.isEmpty() && book == null) {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
frequency.setValue(String.valueOf(format.defaultFrequency()));
bitRate.setValue(String.valueOf(format.defaultBitrate()));
channels.setValue(String.valueOf(format.defaultChannel()));
@@ -271,7 +272,7 @@ private void updateParameters(List media) {
}
Executors.newSingleThreadExecutor().submit(() -> {
- OutputParameters params = ConverterApplication.getContext().getOutputParameters();
+ OutputParameters params = AudiobookConverter.getContext().getOutputParameters();
if (book != null) {
params.updateAuto(book.getMedia());
// book.addListener(observable -> updateParameters(book.getMedia()));
@@ -279,7 +280,7 @@ private void updateParameters(List media) {
params.updateAuto(media);
}
Platform.runLater(() -> {
- Format format = ConverterApplication.getContext().getOutputParameters().getFormat();
+ Format format = AudiobookConverter.getContext().getOutputParameters().getFormat();
frequency.setValue(String.valueOf(findNearestMatch(params.getFrequency(), format.frequencies(), format.defaultFrequency())));
bitRate.setValue(String.valueOf(findNearestMatch(params.getBitRate(), format.bitrates(), format.defaultBitrate())));
channels.setValue(String.valueOf(findNearestMatch(params.getChannels(), format.channels(), format.defaultChannel())));
diff --git a/src/test/java/uk/yermak/audiobookconverter/FFMediaLoaderTest.java b/src/test/java/uk/yermak/audiobookconverter/FFMediaLoaderTest.java
index 6300f06b..48d373d8 100644
--- a/src/test/java/uk/yermak/audiobookconverter/FFMediaLoaderTest.java
+++ b/src/test/java/uk/yermak/audiobookconverter/FFMediaLoaderTest.java
@@ -4,7 +4,6 @@
import org.apache.commons.io.IOUtils;
import org.testng.annotations.Test;
import uk.yermak.audiobookconverter.fx.ConversionContext;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
import java.io.IOException;
import java.io.InputStream;
@@ -19,7 +18,7 @@ public class FFMediaLoaderTest {
@org.testng.annotations.Test
public void testAddPosterIfMissing() {
- ConversionContext context = ConverterApplication.getContext();
+ ConversionContext context = AudiobookConverter.getContext();
ObservableList posters = context.getPosters();
ArtWorkBean art1 = new ArtWorkBean("", 1);
diff --git a/src/test/java/uk/yermak/audiobookconverter/MediaInfoBeanTest.java b/src/test/java/uk/yermak/audiobookconverter/MediaInfoBeanTest.java
index b782c821..1ade8049 100644
--- a/src/test/java/uk/yermak/audiobookconverter/MediaInfoBeanTest.java
+++ b/src/test/java/uk/yermak/audiobookconverter/MediaInfoBeanTest.java
@@ -3,7 +3,6 @@
import javafx.collections.FXCollections;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import uk.yermak.audiobookconverter.fx.ConverterApplication;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -12,7 +11,7 @@ public class MediaInfoBeanTest {
@BeforeClass
public void initLog(){
- ConverterApplication.initAppHome();
+ AudiobookConverter.initAppHome();
}
@Test
diff --git a/version.txt b/version.txt
index 6aa86db3..d5cdbf09 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-AudioBookConverter-#{APP_VERSION}#
+AudioBookConverter-5.6.0