Author: bpoussin Date: 2012-09-06 11:23:15 +0200 (Thu, 06 Sep 2012) New Revision: 537 Url: http://forge.codelutin.com/repositories/revision/sammoa/537 Log: disable de la progress si erreur ou unavailable Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/SoundPlayer.java Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/SoundPlayer.java =================================================================== --- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/SoundPlayer.java 2012-09-06 08:52:38 UTC (rev 536) +++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/SoundPlayer.java 2012-09-06 09:23:15 UTC (rev 537) @@ -49,7 +49,7 @@ */ public class SoundPlayer extends JComponent implements DeviceStateListener, AudioPositionListener { protected AudioReader reader; -// protected boolean playing = false; // whether the sound is currently playing + // le fichier charge acutellement au niveau de l'ui (config du slider protected File currentFile; @@ -79,11 +79,13 @@ stop.setEnabled(false); progress = new JSlider(0, 0, 0); + progress.setMajorTickSpacing(60000); // toutes les 60s + progress.setMinorTickSpacing(10000); // toutes les 10s progress.setPaintTicks(true); progress.setPaintLabels(true); - time = new JLabel("0"); // Shows position as a # - maxTime = new JLabel("/0"); // Shows position as a # + time = new JLabel("0.0"); // Shows position as a # + maxTime = new JLabel("/0.0"); // Shows position as a # // put those controls in a row Box row = Box.createHorizontalBox( ); @@ -159,19 +161,25 @@ case READY: // on vient de charger un fichier, ou arrete la lecture du fichier play.setEnabled(true); stop.setEnabled(false); + progress.setEnabled(true); changeSliderInfo(); break; case RUNNING: // un fichier est en cours de lecture play.setEnabled(false); stop.setEnabled(true); + progress.setEnabled(true); break; case UNAVAILABLE: // aucun fichier charge play.setEnabled(false); stop.setEnabled(false); + progress.setEnabled(false); + changeSliderInfo(); break; case ERROR: // erreur sur le lecture audio (erreur I/O) play.setEnabled(false); stop.setEnabled(false); + progress.setEnabled(false); + changeSliderInfo(); break; } } @@ -187,17 +195,14 @@ int max = (int)audioLength; // si la longueur du morceau change, on change l'info affichee if (progress.getMaximum() != max) { + progress.setValue((int)getAudioReader().getPosition()); progress.setMaximum(max); // Affichage du temps String maxTimeString = (max/1000) + "." + (audioLength % 1000) / 100; maxTime.setText("/" + maxTimeString); timePad = maxTimeString.length(); - time.setText(StringUtils.leftPad("0.0", timePad, '0')); - progress.setMajorTickSpacing(60000); // toutes les 60s - progress.setMinorTickSpacing(10000); // toutes les 10s - // calcul de l'espace entre chaque affichage de l'heure en fonction de la longueur du slider double width = progress.getSize().getWidth(); long step = audioLength * 100 / (long)width; // on minimum tous les 100px