Fixed thumbnailing issue...

This commit is contained in:
abaddon 2017-02-18 01:47:34 -06:00
parent 3a2e2b1cdd
commit 43bbfcc70d
11 changed files with 76 additions and 36 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
#!/bin/bash
function main() {
notify-send -u critical "You need to install ffmpegthumbnailer to have FXWinWrap work properly..."
xterm -e sudo apt install ffmpegthumbnailer
}
main;

View File

@ -0,0 +1,8 @@
#!/bin/bash
function main() {
notify-send -u critical "You need to install ffmpegthumbnailer to have FXWinWrap work properly..."
xterm -e sudo apt install ffmpegthumbnailer
}
main;

View File

@ -15,16 +15,15 @@ import java.io.*;
public class Controller { public class Controller {
private DirectoryChooser folderChooser = new DirectoryChooser(); // Selects a dir private DirectoryChooser folderChooser = new DirectoryChooser(); // Selects a dir
private FileChooser fileChooser = new FileChooser(); // Selects a file private FileChooser fileChooser = new FileChooser(); // Selects a file
private FileWriter fileWriter; // Writes to files private FileWriter fileWriter; // Writes to files
private File directory, sveFileLoc; // Path to file or dir private File directory, sveFileLoc; // Path to file or dir
private Image pth = new Image("."); // Path to image private Image pth = new Image("."); // Path to image
private ImageView imgView = new ImageView(pth); // Image view area private ImageView imgView = new ImageView(pth); // Image view area
private Process pb; // Process runner private Process pb; // Process runner
private String tmpPath, resolution, xScreenVal, output, private String tmpPath, resolution, xScreenVal, output,
startScrpt = System.getProperty("user.dir") + "/resources/bin/StartXWW.sh", // Gets shell that starts stuff local startScrpt = System.getProperty("user.dir") + "/resources/bin/StartXWW.sh", // Gets shell that starts stuff local
ffmpg = System.getProperty("user.dir") + "/resources/bin/ffmpegthumbnailer", // Gets ffmpeg local
textAreaPth = ""; textAreaPth = "";
private int applyType = 1; private int applyType = 1;
private Stage fileChooserStage; private Stage fileChooserStage;
@ -35,10 +34,10 @@ public class Controller {
@FXML private CheckBox lftScrn, rghtScrn, useXSvrn; // Check boxes @FXML private CheckBox lftScrn, rghtScrn, useXSvrn; // Check boxes
@FXML private ChoiceBox<?> listLftRes, listRgthRes, listSaveLoc; // Choice box fields @FXML private ChoiceBox<?> listLftRes, listRgthRes, listSaveLoc; // Choice box fields
@FXML private Button applyBttn, closeBttn, fileBttn, clear, // Buttons @FXML private Button applyBttn, closeBttn, fileBttn, clear, // Buttons
killBttn, restartBttn, saveBttn; killBttn, restartBttn, saveBttn;
// This method is called by the FXMLLoader when initialization is complete // This method is called by the FXMLLoader when initialization is complete
@FXML void initialize() { @FXML void initialize() throws Exception {
assert clear != null : "fx:id=\"clear\" was not injected: check your FXML file 'Window.fxml'."; assert clear != null : "fx:id=\"clear\" was not injected: check your FXML file 'Window.fxml'.";
assert closeBttn != null : "fx:id=\"closeBttn\" was not injected: check your FXML file 'Window.fxml'."; assert closeBttn != null : "fx:id=\"closeBttn\" was not injected: check your FXML file 'Window.fxml'.";
assert dirLbl != null : "fx:id=\"dirLbl\" was not injected: check your FXML file 'Window.fxml'."; assert dirLbl != null : "fx:id=\"dirLbl\" was not injected: check your FXML file 'Window.fxml'.";
@ -53,6 +52,8 @@ public class Controller {
assert tilePane != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'Window.fxml'."; assert tilePane != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'Window.fxml'.";
assert useXSvrn != null : "fx:id=\"useXSvrn\" was not injected: check your FXML file 'Window.fxml'."; assert useXSvrn != null : "fx:id=\"useXSvrn\" was not injected: check your FXML file 'Window.fxml'.";
// Initialize your logic here: all @FXML variables will have been injected // Initialize your logic here: all @FXML variables will have been injected
ffmpegChker();
} }
// Handler for TextArea[fx:id="dirPathField"] onKeyReleased // Handler for TextArea[fx:id="dirPathField"] onKeyReleased
@ -67,6 +68,7 @@ public class Controller {
System.out.println("Not calling newDir..."); System.out.println("Not calling newDir...");
} }
// Scan selected dir
public void newDir() { public void newDir() {
Stage stage = new Stage(); Stage stage = new Stage();
if (textAreaPth != "") if (textAreaPth != "")
@ -84,52 +86,53 @@ public class Controller {
fileList[i].getName().contains(".mpg") || fileList[i].getName().contains(".wmv") || fileList[i].getName().contains(".mpg") || fileList[i].getName().contains(".wmv") ||
fileList[i].getName().contains(".mkv") || fileList[i].getName().contains(".flv") || fileList[i].getName().contains(".mkv") || fileList[i].getName().contains(".flv") ||
fileList[i].getName().contains(".webm") || fileList[i].getName().contains(".avi")) { fileList[i].getName().contains(".webm") || fileList[i].getName().contains(".avi")) {
String movieImg = ffmpg + " -w -t='00:30:00' -c png -i " + fileList[i] + String movieImg = "ffmpegthumbnailer -w -t='00:30:00' -c png -i " + fileList[i] +
" -s 800 -o /tmp/image.png", " -s 300 -o /tmp/image.png",
vExec = "mplayer " + fileList[i]; vExec = "mplayer " + fileList[i];
try { try {
pb = Runtime.getRuntime().exec(movieImg); pb = Runtime.getRuntime().exec(movieImg);
pb.waitFor(); pb.waitFor();
System.out.println(movieImg);
} catch(Throwable imgIOErr) { } catch(Throwable imgIOErr) {
System.out.println(imgIOErr); System.out.println(imgIOErr);
} }
imgView = new ImageView("file:///tmp/image.png"); imgView = new ImageView("file:///tmp/image.png");
imgView.setFitWidth(300); // Need these here to get grid properly. imgView.setFitWidth(300); // Need these here to get grid properly.
imgView.setFitHeight(200); imgView.setFitHeight(200);
tilePane.getChildren().add(imgView); tilePane.getChildren().add(imgView);
imgView.setOnMouseClicked(mouse -> { imgView.setOnMouseClicked(mouse -> {
if (mouse.getClickCount() == 2 && !mouse.isConsumed()) { if (mouse.getClickCount() == 2 && !mouse.isConsumed()) {
mouse.consume(); mouse.consume();
try { try {
pb = Runtime.getRuntime().exec(vExec); pb = Runtime.getRuntime().exec(vExec);
} catch(IOException vidIOErr) { } catch(IOException vidIOErr) {
throw new UncheckedIOException(vidIOErr); throw new UncheckedIOException(vidIOErr);
} }
} }
filePathField.setText(path); filePathField.setText(path);
}); });
} else if(fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")|| } else if(fileList[i].getName().contains(".png") || fileList[i].getName().contains(".jpg")||
fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) { fileList[i].getName().contains(".gif") || fileList[i].getName().contains(".jpeg")) {
imgView = new ImageView("file://" + fileList[i]); imgView = new ImageView("file://" + fileList[i]);
String title = "" + fileList[i]; String title = "" + fileList[i];
imgView.setFitWidth(300); // Need these here to get grid properly. imgView.setFitWidth(300); // Need these here to get grid properly.
imgView.setFitHeight(200); imgView.setFitHeight(200);
tilePane.getChildren().add(imgView); tilePane.getChildren().add(imgView);
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]); final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
// image click actions // image click actions
imgView.setOnMouseClicked(mouse -> { imgView.setOnMouseClicked(mouse -> {
if (mouse.getClickCount() == 2 && !mouse.isConsumed()) { if (mouse.getClickCount() == 2 && !mouse.isConsumed()) {
mouse.consume(); mouse.consume();
displayImg(imgViewPoped, title); displayImg(imgViewPoped, title);
} }
filePathField.setText(path); filePathField.setText(path);
}); });
} else { } else {
System.out.println("Not a video or image file."); System.out.println("Not a video or image file.");
} }
} }
} }
// Open image in new window
public void displayImg(ImageView imgViewPoped, String title) { public void displayImg(ImageView imgViewPoped, String title) {
Stage popOut = new Stage(); Stage popOut = new Stage();
Pane pane = new Pane(); Pane pane = new Pane();
@ -207,12 +210,25 @@ public class Controller {
applyType = 2; applyType = 2;
//VIDEO //VIDEO
} else { } else {
output = "xwinwrap -ov -g " + resolution + " -st -sp -b -nf -s -ni -- mplayer -wid WID -nosound -loop 0 " + filePathField.getText(); output = "xwinwrap -ov -g " + resolution + " -st -sp -b -nf -s -ni -- mplayer -wid WID -really-quiet -nosound -loop 0 " + filePathField.getText();
fileWriter.write(output); fileWriter.write(output);
applyType = 1; applyType = 1;
} }
fileWriter.close(); fileWriter.close();
} }
void ffmpegChker() throws Exception {
File ffmpgLoc = new File("/usr/bin/ffmpegthumbnailer");
boolean exists = ffmpgLoc.exists();
System.out.println("" + exists);
if (exists) {
System.out.println("Ffmpeg is present....");
} else {
String installer = System.getProperty("user.dir") + "/resources/bin/InstallFFMPEGTHUMB.sh";
pb = Runtime.getRuntime().exec(installer);
pb.waitFor();
}
}
// Run changes // Run changes
@FXML void applySttngs(ActionEvent event) throws Exception { @FXML void applySttngs(ActionEvent event) throws Exception {
pb = Runtime.getRuntime().exec("killall xwinwrap &"); pb = Runtime.getRuntime().exec("killall xwinwrap &");

View File

@ -0,0 +1,8 @@
#!/bin/bash
function main() {
notify-send -u critical "You need to install ffmpegthumbnailer to have FXWinWrap work properly..."
xterm -e sudo apt install ffmpegthumbnailer
}
main;