Esempio n. 1
0
 public void play() {
   if (use_short_sound) {
     short_sound.play();
     is_playing = false; // short sound, won't be playing long...
   } else {
     if (use_start_sound) {
       t =
           newTimer(
               start_sound.getLengthAsInt(),
               false,
               new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                   handleTimerPop(e);
                 }
               });
       start_sound.play();
       if (use_mid_sound) {
         t.start();
         is_playing = true;
       }
     } else if (use_mid_sound) {
       mid_sound.setLooped(true);
       mid_sound.play();
     }
   }
 }
Esempio n. 2
0
  public void stop() {
    log.warn("Stopping");
    // make sure the start sound is killed
    if (use_start_sound) {
      start_sound.stop();
    }

    // If the mid sound is used, turn off the looping.
    // this will allow it to naturally die.
    if (use_mid_sound) {
      mid_sound.setLooped(false);
      mid_sound.fadeOut();
    }

    // If the timer is running, stop it.
    if (t != null) {
      t.stop();
    }

    // If we're using the end sound, stop the mid sound
    // and play the end sound.
    if (use_end_sound) {
      if (use_mid_sound) {
        mid_sound.stop();
      }
      end_sound.setLooped(false);
      end_sound.play();
    }
    is_playing = false;
  }
Esempio n. 3
0
 // Catch the timer pop after the start sound is played and trigger the (looped) sustain sound.
 protected void handleTimerPop(ActionEvent e) {
   log.info("Received timer pop after start sound played.");
   // TODO: Need to validate that this is the timer pop
   if (use_mid_sound) {
     mid_sound.setLooped(true);
     mid_sound.play();
   }
   t.stop();
 }
Esempio n. 4
0
 public void loop() {
   if (use_start_sound) {
     start_sound.setLooped(false);
     start_sound.play();
     t =
         newTimer(
             start_sound.getLengthAsInt() - 100,
             false,
             new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                 handleTimerPop(e);
               }
             });
     t.setRepeats(false); // timer pop only once to trigger the sustain sound.
     t.start();
   } else if (use_mid_sound) {
     mid_sound.setLooped(true);
     mid_sound.play();
   }
   is_playing = true;
 }