I am working on MediaPlayer using JavaFX to finish javaFX course. I am trying to set file total duration to the slider max property. Then I want to add Listener to the currentTimeProperty so the slider is tracking the timeline. I wrote a code that works perfectly fine: It works when I call it once the video is already playing.