import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; import javafx.scene.media.MediaView; import javafx.stage.Stage; import javafx.scene.layout.*; import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.beans.property.*; import javafx.beans.binding.*; import javafx.scene.paint.Color; import javafx.util.Duration; // public class, public constructor as per JavaFX requirements public sclass VideoPlayer extends Application { static S arg; // path of file to play File file; static MediaPlayer theMediaPlayer; public void start(Stage stage) ctex { file = new File(arg); // Create and set the Scene. // Numbers are window size (content is not scaled) double w = 540, h = 209; new BorderPane root; Scene scene = new Scene(root, w, h, Color.BLACK); stage.setScene(scene); // Name and display the Stage. stage.setTitle(file.getName() + " - JavaX Video Player"); stage.show(); // Create the media source. Media media = new Media(file.toURI().toURL().toString()); // Create the player and set to play automatically. MediaPlayer mediaPlayer = new MediaPlayer(media); theMediaPlayer = mediaPlayer; mediaPlayer.setAutoPlay(true); // Create the media view. MediaView mediaView = new MediaView(mediaPlayer); // Resize Hack DoubleProperty mvw = mediaView.fitWidthProperty(); DoubleProperty mvh = mediaView.fitHeightProperty(); mvw.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width")); mvh.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height")); mediaView.setPreserveRatio(true); root.setCenter(mediaView); } public void stop() { print("Application stopped."); } }