title: javafx video player timeSlider
body: <p>How to make slider to move as video plays?</p>
  
  <p>Initialization :</p>
  
  <pre><code>BorderPane border = new BorderPane();
  HBox bar = new HBox(10);
  //Button play = new Button("Play");
  //Button pause = new Button("Pause");
  </code></pre>
  
  <p>Media:</p>
  
  <pre><code>    Media media = new Media(Paths.get("C://video.mp4").toUri().toString());
      MediaPlayer player = new MediaPlayer(media);
      MediaView mediaView = new MediaView(player);
  </code></pre>
  
  <p>Positioning :</p>
  
  <pre><code>    bar.getChildren().addAll(play,pause,timeSlider);
      bar.setAlignment(Pos.CENTER);
      border.setCenter(mediaView);
      border.setBottom(bar);
  </code></pre>
  
  <p>Any suggestions how to make my slider move as video plays? </p>
  
  <p>Edit:</p>
  
  <p>Found answer :</p>
  
  <pre><code>player.currentTimeProperty().addListener((obs, oldTime, newTime) -&gt; {
          if (!timeSlider.isValueChanging()) {
              timeSlider.setValue(newTime.toSeconds());
          }
      });
  </code></pre>