# JavaFX MediaPlayer Preview

**URL:** <https://discourse.processing.org/t/javafx-mediaplayer-preview/41344>\
**Category:** Gallery\
**Created:** [March 18, 2023, 7:03pm UTC](https://discourse.processing.org/t/javafx-mediaplayer-preview/41344 "2023-03-18T19:03:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [March 18, 2023, 7:03pm UTC](https://discourse.processing.org/t/javafx-mediaplayer-preview/41344/1 "2023-03-18T19:03:19Z")

</div>

The screenshot below is a preview of a JavaFX MediaPlayer created in Processing4 after adding the javafx.media module to line 1086 of JavaBuild.java and recompiling the editor. The source code and output are shown below:

**Source code:**

```auto
import java.io.File;
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;

void setup() {
  size(1, 1, FX2D);
  Stage stage = new Stage();
  // ****Replace this with your file path**** //
  String path = "/Users/xxxxxx/Movies/birds.mp4";
  Media media = new Media(new File(path).toURI().toString());
  MediaPlayer mediaPlayer = new MediaPlayer(media);
  MediaView mediaView = new MediaView(mediaPlayer);
  mediaPlayer.setAutoPlay(true);
  mediaView.setLayoutX(10);
  mediaView.setLayoutY(10);
  Group root = new Group();
  root.getChildren().add(mediaView);
  Scene scene = new Scene(root, 500, 400);
  stage.setScene(scene);
  stage.setTitle("Playing video");
  stage.show();
}

void draw(){
}

```

**Output:**

 ![media](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/8/98a778e9d45a41453b51cb668ccad6df7b6a6b11.jpeg)
