@Override
  public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);
    long curFrame = CurAudio.getAudioProgress();
    long frameShift = CurAudio.getMaster().millisToFrames(shift);
    long naivePosition = curFrame + frameShift;
    long frameLength = CurAudio.getMaster().durationInFrames();

    long finalPosition = naivePosition;

    if (naivePosition < 0) {
      finalPosition = 0;
    } else if (naivePosition > frameLength) {
      finalPosition = frameLength;
    }

    CurAudio.setAudioProgressWithoutUpdatingActions(
        finalPosition); // not using setAudioProgressAndUpdateActions() because we don't want to
    // slow down start of playback
    CurAudio.getPlayer().queuePlayAt(finalPosition);

    replayer.actionPerformed(
        new ActionEvent(
            MyMenu.getInstance(),
            ActionEvent.ACTION_PERFORMED,
            null,
            System.currentTimeMillis(),
            0));

    MyMenu.updateActions();
  }
 @Override
 public void update() {
   if (CurAudio.audioOpen()) {
     if (CurAudio.getPlayer().getStatus() == PrecisionPlayer.Status.PLAYING) {
       setEnabled(false);
     } else {
       if (CurAudio.getAudioProgress() <= 0) {
         if (dir == Direction.FORWARD) {
           setEnabled(true);
         } else {
           setEnabled(false);
         }
       } else if (CurAudio.getAudioProgress() == CurAudio.getMaster().durationInFrames() - 1) {
         if (dir == Direction.FORWARD) {
           setEnabled(false);
         } else {
           setEnabled(true);
         }
       } else {
         setEnabled(true);
       }
     }
   } else {
     setEnabled(false);
   }
 }
Example #3
0
 /** Zooming is enabled only when audio is open and not playing. */
 @Override
 public void update() {
   if (CurAudio.audioOpen()) {
     if (CurAudio.getPlayer().getStatus() == PrecisionPlayer.Status.PLAYING) {
       setEnabled(false);
     } else {
       setEnabled(true);
     }
   } else {
     setEnabled(false);
   }
 }