From: Not Zed Date: Tue, 7 Dec 2021 23:13:12 +0000 (+1030) Subject: Show open requester if no file argument given. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=69aca695eb4acec2b2cd537d8c8336cbbbaf49f0;p=jjmpeg Show open requester if no file argument given. Use threadFactory to create thread rather than to-be-deprecated new Thread() --- diff --git a/src/notzed.jjmpeg.demo/classes/au/notzed/jjmpeg/demo/video/VideoPlay.java b/src/notzed.jjmpeg.demo/classes/au/notzed/jjmpeg/demo/video/VideoPlay.java index 112c761..026f536 100644 --- a/src/notzed.jjmpeg.demo/classes/au/notzed/jjmpeg/demo/video/VideoPlay.java +++ b/src/notzed.jjmpeg.demo/classes/au/notzed/jjmpeg/demo/video/VideoPlay.java @@ -21,6 +21,7 @@ package au.notzed.jjmpeg.demo.video; import au.notzed.jjmpeg.AVIOException; import au.notzed.jjmpeg.fx.FXPixelReader; import au.notzed.jjmpeg.io.JJMediaReader; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import static java.lang.Double.min; @@ -30,6 +31,7 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; import javafx.application.Application; import javafx.application.Platform; import javafx.beans.InvalidationListener; @@ -51,6 +53,7 @@ import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.scene.transform.Scale; import javafx.scene.transform.Translate; +import javafx.stage.FileChooser; import javafx.stage.Screen; import javafx.stage.Stage; @@ -69,13 +72,22 @@ public class VideoPlay extends Application { List args = getParameters().getUnnamed(); if (args.size() != 1) { - Alert a = new Alert(Alert.AlertType.ERROR, "Must supply one file.", ButtonType.CLOSE); - a.showAndWait(); - return; + FileChooser fc = new FileChooser(); + File selected; + + fc.setTitle("Select Video"); + selected = fc.showOpenDialog(null); + + if (selected == null) + return; + + args = List.of(selected.getAbsolutePath()); } - new Thread(() -> { - reader(args.get(0)); + String path = args.get(0); + + Executors.defaultThreadFactory().newThread(() -> { + reader(path); }).start(); }