I’m having a lot of trouble making objects appear in front of a video (that’s being played through JavaFX).

Hi! I have this project in which i need to have a huge video (hence why i'm using javafx instead of the actual video lib from processing) playing in the background while a "rect"(anything really, just an example) appear in front of the video. But for some reason i'm unable to do it. Can someone help me?

import java.nio.file.Files; import java.nio.file.StandardCopyOption; import java.time.LocalDateTime; import java.time.ZonedDateTime; import processing.core.PApplet; import ddf.minim.Minim; import ddf.minim.AudioPlayer; import java.io.File; import java.io.IOException; import javafx.beans.binding.Bindings; import javafx.beans.property.DoubleProperty; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.scene.media.Media; import javafx.scene.media.MediaView; import javafx.scene.paint.Color; import javafx.stage.Stage; import java.lang.reflect.*; import processing.javafx.*; import javafx.scene.media.MediaPlayer; final String VIDEO_FILE_NAME = "teste.mp4"; final String DIRECTORY = "C:/Users/Matheus/Desktop"; Stage stage; void setup() { size(1100, 618, FX2D); try { Field field = PSurfaceFX.class.getDeclaredField("stage"); field.setAccessible(true); stage = (Stage)field.get(surface); File f = new File(DIRECTORY, VIDEO_FILE_NAME); Media media = new Media(f.toURI().toURL().toString()); javafx.scene.media.MediaPlayer player = new javafx.scene.media.MediaPlayer(media); MediaView viewer = new MediaView(player); DoubleProperty width = viewer.fitWidthProperty(); DoubleProperty height = viewer.fitHeightProperty(); width.bind(Bindings.selectDouble(viewer.sceneProperty(), "width")); height.bind(Bindings.selectDouble(viewer.sceneProperty(), "height")); viewer.setPreserveRatio(true); StackPane root = new StackPane(); Node processingCanvas = stage.getScene().getRoot().getChildrenUnmodifiable().get(0); root.getChildren().addAll(viewer, processingCanvas); // root.getChildren().addAll(processingCanvas,viewer); Scene scenes = new Scene(root, 1100, 618, Color.TRANSPARENT); stage.setScene(scenes); stage.setTitle("OBSV.CamFeed.6°07'08.3\"S 12°23'51.5\"E"); stage.setFullScreen(false); stage.show(); player.setCycleCount(MediaPlayer.INDEFINITE); player.play(); } catch(Exception e) { e.printStackTrace(); } } void draw() { rect(width/2, height/2, 100, 100); } 
submitted by /u/94matheus
[link] [comments]