Example usage for javafx.scene.media MediaView sceneProperty

List of usage examples for javafx.scene.media MediaView sceneProperty

Introduction

In this page you can find the example usage for javafx.scene.media MediaView sceneProperty.

Prototype

public final ReadOnlyObjectProperty<Scene> sceneProperty() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    String workingDir = System.getProperty("user.dir");
    final File f = new File(workingDir, "../media/omgrobots.flv");

    final Media m = new Media(f.toURI().toString());
    final MediaPlayer mp = new MediaPlayer(m);
    final MediaView mv = new MediaView(mp);

    final DoubleProperty width = mv.fitWidthProperty();
    final DoubleProperty height = mv.fitHeightProperty();

    width.bind(Bindings.selectDouble(mv.sceneProperty(), "width"));
    height.bind(Bindings.selectDouble(mv.sceneProperty(), "height"));

    mv.setPreserveRatio(true);/*from w ww .j  ava 2s. com*/

    StackPane root = new StackPane();
    root.getChildren().add(mv);

    final Scene scene = new Scene(root, 960, 540);
    scene.setFill(Color.BLACK);

    primaryStage.setScene(scene);
    primaryStage.setTitle("Full Screen Video Player");
    primaryStage.setFullScreen(true);
    primaryStage.show();

    mp.play();
}