How to play a video intro for your game

Hi guys,
these days i did some research on github on how to play a video inside a demo with jme. I reworked some code and created a little project to discuss it with you. The project uses JavaFX libraries to play the videos. I would like to know if there is a more efficient way to play a video with jme or if what I have found can be improved.
Let me know what you think.

Here is the code:

2 Likes

You can use VLC: [SOLVED] How can I play a video in jme? - #21 by Pavl_G

2 Likes

Thanks for your reply, I’ll do some tests also with VLC

2 Likes

Nice, I have read before that java Reflection may be an expensive solution, another solution to use jfx player without real jme-jfx context, in case you are using lwjgl2, try the following :
1- build jme context on a Swing/AWT canvas.
2- create a JFrame with a Full screen JComponent or JPanel.
3- using JFXPanel concrete class from javafx.embed.swing.JFXPanel you can manage to create jfx scene & attach a jfx Video Player widget on it & destroy whenever needed.
-then :
Synchronize the add of the JFXPanel & the Jme-swing canvas in order to get a splash screen with sound (jfx vid) before game shows up (Notice that game already starts on jme-canvas in foreground without showing up).

=>Downsides are multiple contexts, you need to handle this via enqueue actions for the right context in a thread safe way.
=>Refer to :
https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/swing-fx-interoperability.htm

1 Like

In theory there is the concept here, but in order to use that, you’d need to implement it, which is a summer full of work:

The only real advantage is not requiring JavaFX and thus hand-rolling the integration, which is hard to do, though.

1 Like