I have a MediaPlayer
object which plays a video. When the video is finished playing, I want the program to hide the MediaView
and display different Jav
Can't find any official documents that mention this but I'm pretty sure the media file is played on a separate thread under the hood by JavaFX so that it doesn't block the UI thread. This is why you need to use MediaPlayer.setOnEndOfMedia:
view.setMediaPlayer(player);
player.setOnEndOfMedia(() -> {
view.setVisible(false);
});
player.play();