Example usage for javafx.scene.media MediaPlayer setAutoPlay

List of usage examples for javafx.scene.media MediaPlayer setAutoPlay

Introduction

In this page you can find the example usage for javafx.scene.media MediaPlayer setAutoPlay.

Prototype

public final void setAutoPlay(boolean value) 

Source Link

Document

Sets the #autoPlayProperty autoPlay property value.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    Scene scene = new Scene(box, 200, 200);
    stage.setScene(scene);/*  ww w .  j av  a2s.  co m*/

    Media media = new Media("video file URI");
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setAutoPlay(true);

    MediaView mediaView = new MediaView(mediaPlayer);
    ((VBox) scene.getRoot()).getChildren().add(mediaView);

    stage.show();
}

From source file:MediaControl.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Embedded Media Player");
    Group root = new Group();
    Scene scene = new Scene(root, 540, 241);

    // create media player
    Media media = new Media((arg1 != null) ? arg1 : MEDIA_URL);
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setAutoPlay(true);

    MediaControl mediaControl = new MediaControl(mediaPlayer);
    scene.setRoot(mediaControl);/*from  w w  w  .  jav a  2 s .c o m*/

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:smarthome.FXMLDocumentController.java

private void initPlayer(String uri) {

    Media media = new Media(uri);
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setAutoPlay(true);
    videoView.setMediaPlayer(mediaPlayer);
    mediaPlayer.play();//  w  ww. ja  v  a  2  s . com
    /* mediaPlayer.setOnReady(new Runnable() {
    @Override
    public void run() {
        // TODO Auto-generated method stub
    }
     });*/
}