List of usage examples for javafx.util Duration toMillis
public double toMillis()
From source file:AudioPlayer3.java
private String formatDuration(Duration duration) { double millis = duration.toMillis(); int seconds = (int) (millis / 1000) % 60; int minutes = (int) (millis / (1000 * 60)); return String.format("%02d:%02d", minutes, seconds); }
From source file:AudioPlayer3.java
private void updatePositionSlider(Duration currentTime) { if (positionSlider.isValueChanging()) return;/*from w ww . j a va 2s.c o m*/ final MediaPlayer mediaPlayer = songModel.getMediaPlayer(); final Duration total = mediaPlayer.getTotalDuration(); if (total == null || currentTime == null) { positionSlider.setValue(0); } else { positionSlider.setValue(currentTime.toMillis() / total.toMillis()); } }