Need help whit JavaFx installation for Video presentation in game

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());