-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Hi,
I want to use javafx.scene.media.MediaPlayer to play video/audio in the processing applet. To play audio it works without problem and hacks, but to play videos I need to hack processing. I struggled to find a clean solution but no result...
I need to get the StackPane created by PSurfaceFX, but this element is not exposed. So I modified /core/src/processing/javafx/PSurfaceFX.java (https://github.com/jej/processing/commit/6a72a99e355ef7c93b1f9778f03c0c6660116ff7)
public class PSurfaceFX implements PSurface {
static StackPane stackPane; // was a local field in start()
.../...
public StackPane getStackPane() {
return stackPane;
}
.../...
}
So now I can play videos or draw any(fx)thing in a FX2D applet with:
public void playVideo() {
PSurfaceFX surface = (PSurfaceFX) getSurface();
Media media = new Media("file:///pathtofile.flv");
MediaPlayer player = new MediaPlayer(media);
MediaView mediaView = new MediaView(player);
surface.getStackPane().getChildren().add(mediaView);
player.play();
}
Do you know a better solution to do that without processing modification?
If not, do you think this solution is fine?
J.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels