Need help whit JavaFx installation for Video presentation in game

True that, or grab the already build jar from bintray and just include it.

1 Like

Edit : My bad, the jar do work, i think am just not using the right class.

So… what next? I saw an exemple by abies

But it don’t seem to work at all :/. I can’t creat the class media and mediaPlayer don’t want to be imported. For the texture il guess its a texture il apply the surface i want to video on?

I don’t know if it would help you, since I’m using eclipse and Java 1.7, but I put jfxrt.jar (JavaFX) into my classpath.

1 Like

i am also using eclipse and work whit java 1.7, but i don’t seem to be able to doawload the javaFX jar anywhere.

But i also see everywhere that javaFx need to be install on the computer. Does that mean it will need to be package whit my installer if i want people to be able to use it in game?

see the full source of abies fragment in the test directory of JME-JFX

JME-JFX require java8. under eclipse you may need to add/enable the javafx Library, because it can be hide iirc.

1 Like

I’m afraid but in that classes I mentioned before, there is some code that needs Java 8. That code can be replaced, but probably you’ll need to add those files into your project instead of using precompiled jar.

JavaFX is included into JRE/JDK from 1.7.0 update 45 (or something like that). Check if you have jfxrt.jar somewhere inside your installation.

Thanks! Il have to check that tomorow or i won’t sleep the whole night but il give you feedback when its done!

if you want to try javafx for java 7 + maven/gradle take look at http://stackoverflow.com/questions/1927470/javafx-with-maven. Maybe the Movie part of JME-JFX doesn’t require javafx 8 -but there are lot changes javafx (7) and 8

You where right, its inside java itself, now i only have on problem left : what is that

PlatformImpl.startup(() → { });

i do underthant that startup need a runnable argument but what is () → { } suppose to mean?

It’s a lambda, java 8 new feature.

the hacky solutin is “new JfxPanel()” instead, that starts up the platform as well.

1 Like

And it work! Marvellous! All is left is to make sure it take the whole screen no matter the size and then some integration, but i can do that on my own :wink:

Thanks again :smiley: I’ll soon post the results and try to put every anwser at the begening of the topic if anyone was in need to do the same x).

Okay everything is working great in the testing class but as soon as i get it out of there, i get a green screen. Am applying the texture on a Label build in tonegod, and as i said it work when every part of the code are in the same area. The green screen also play the music. Il get back after a few test

Okay found it. It was actully the
@Override
public void simpleUpdate(float tpf) {
super.simpleUpdate(tpf);
lab.movieMaterial.update(tpf);
}

But i kinda wonder, won,t that slow in any way my whole program having this command looping all the time? I could probably put it in a AbstractControl to avoid that? o well any way il have to test that later, il come back whit a complet class

Did you see I've made a MovieAppState so you don't have to ?

Nan, i did not saw it, but then again I kinda prefers my solution : simply build an extends label whit an AbstractControl inside and i have full control. I can then creat multiple label and they simpl act like normal labels.

I think everything is pretty much done, i just have one question left : how can i make it loop? Is theire any method for that? Cause after searching a bit in MediaPlayer i could not find any setLooping(true) or something like that.

        Media media = new Media(fpath); // javafx.scene.media.Media
        _mp = new MediaPlayer(media); //javafx.scene.media.MediaPlayer
        _mp.setVolume((float)Config.getInstance().getVolumeSfx() / 10f);
        _tex.setFXMediaPlayer(_mp);
        _mp.setOnEndOfMedia(some Runnable); // <------- HERE

This is how I did it.

try (not tested)

mediaPlayer.setCycleCount(javafx.scene.media.MediaPlayer.INDEFINITE)
1 Like

Yep, it work! My class is pretty much finish now :smiley: Its could probably get better but it work fine! Thanks everyone x)

Okay well maybie i got one last question after all. How do i properly refers where my video is inside of my jar? Everything was working fine until i try to make a runnable jar out of the program.

I did try some combinaison, but so far nothing work :

 final Media media = new Media(new File(videoPath).toURI().toASCIIString()) ;

ClassLoader classLoader = getClass().getClassLoader(); 
final Media media = new Media(classLoader.getResource(videoPath).getFile()) ;

they all work fine befaure the exportation, but not after :confused:

classLoader.getResource(videoPath).getFile()

return a File if the resources are in a local “directory” folder (the case when you develop). But on packaging the resources are in an archive (.jar).
I suggestion you to first extract the video from the jar into the local file system, then to read with media the extracted file. IIRC (the question and the answer should be available somewhere in the forum, I guess in the topic I linked previously or in the big javaFX).

1 Like

You where right, the anwser was just under my nose x)
This work
Media media = new Media(Thread.currentThread().getContextClassLoader().getResource(movie).toString());