Search in sources :

Example 1 with Countdown

use of com.bixly.pastevid.screencap.components.capturebox.Countdown in project screenbird by adamhub.

the class RecorderPanel method startCountdown.

/**
     * Initiates countdown and prepares for screen capture. 
     */
private void startCountdown() {
    final Countdown[] countdown = new Countdown[1];
    countdownSec = 6;
    countdownTimer = new Timer(500, new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            countdownSec--;
            log("Counting: " + countdownSec);
            switch(countdownSec) {
                case 0:
                    countdownTimer.stop();
                    jLabel5.setText("Recording");
                    btnRecordNonRec.setText("Stop");
                    btnRecordRec.setText("Stop");
                    btnPlayPauseBackup.setText("");
                    btnPlayPauseBackup.setIcon(pauseIcon);
                    btnFinalizeBackup.setEnabled(true);
                    // Destroy the countdown window.
                    countdown[0].destroy();
                    try {
                        Thread.sleep(500);
                    } catch (Exception ee) {
                    }
                    startRecordState();
                    break;
                case 1:
                case 2:
                case 3:
                case 4:
                    btnPlayPauseBackup.setText(String.valueOf(countdownSec));
                    countdown[0].destroy();
                    countdown[0] = new Countdown(false, recorder);
                    countdown[0].setCount(countdownSec);
                    countdown[0].setVisible(true);
                    try {
                        SoundUtil.tone(880, 500, 0.15);
                    } catch (LineUnavailableException ee) {
                    }
                    break;
                case 5:
                    btnPlayPauseBackup.setText(String.valueOf(countdownSec));
                    // Hide drop box
                    if (captureBox != null) {
                        captureBox.setDragBoxVisible(false);
                    }
                    countdown[0] = new Countdown(false, recorder);
                    countdown[0].setCount(5);
                    countdown[0].setVisible(true);
                    try {
                        SoundUtil.tone(880, 500, 0.15);
                    } catch (LineUnavailableException ee) {
                    }
                    break;
            }
        }
    });
    countdownTimer.start();
}
Also used : Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) LineUnavailableException(javax.sound.sampled.LineUnavailableException) Countdown(com.bixly.pastevid.screencap.components.capturebox.Countdown) MissingResourceException(java.util.MissingResourceException) FileNotFoundException(java.io.FileNotFoundException) LineUnavailableException(javax.sound.sampled.LineUnavailableException) IOException(java.io.IOException)

Aggregations

Countdown (com.bixly.pastevid.screencap.components.capturebox.Countdown)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MissingResourceException (java.util.MissingResourceException)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1 Timer (javax.swing.Timer)1