Esempio n. 1
22
 protected void updateValues() {
   if (timeProgress != null && timeSlider != null && volumeSlider != null) {
     Platform.runLater(
         () -> {
           Duration currentTime = mp.getCurrentTime();
           timeProgress.setText(formatTime(currentTime, duration));
           timeSlider.setDisable(duration.isUnknown());
           if (!timeSlider.isDisabled()
               && duration.greaterThan(Duration.ZERO)
               && !timeSlider.isValueChanging()) {
             timeSlider.setValue(mp.getCurrentTime().divide(duration).toMillis() * 100.0);
             progressBar.setProgress(timeSlider.getValue() / 100);
           }
           if (!volumeSlider.isValueChanging()) {
             volumeSlider.setValue(mp.getVolume());
             if (mp.getVolume() == 0.0) {
               volumeButton.setImage(new Image("icon/Volume_button/mute.png"));
             } else {
               volumeButton.setImage(new Image("icon/Volume_button/volume.png"));
             }
           }
         });
   }
 }
Esempio n. 2
0
 void updatePlayProgress() {
   if (player != null && Tray.stage.isShowing()) {
     Duration d = player.getMedia().getDuration();
     Duration t = player.getCurrentTime();
     loadProgressBar.setProgress(t.toMillis() / d.toMillis());
     timeUpdate++;
     if (timeUpdate == 10) {
       timeUpdate = 0;
       Platform.runLater(
           () -> {
             timeLabel.setText(formatTime(d, t));
           });
     }
   }
 }