コード例 #1
0
  /**
   * Pauses and plays the current thread
   *
   * @param evt a java action event
   */
  private void jbtnPlayPauseActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jbtnPlayPauseActionPerformed

    if (!ppPressed) {
      ppPressed = true;
      jbtnPlayPause.setText("Play");
    } else {
      jbtnPlayPause.setText("Pause");
      ppPressed = false;

      int value = jbrProgress.getValue();
      int jpbIncrement;

      switch (nSequenceToPlay) {
        case 1:
          jpbIncrement = Math.round(1.0f * jbrProgress.getMaximum() / vecStoredSequence.size());
          value = Math.round(1.0f * value / jpbIncrement);
          PlaySequence thread = new PlaySequence(this, vecStoredSequence, value);
          thread.start();
          break;
        case 2:
          jpbIncrement = Math.round(1.0f * jbrProgress.getMaximum() / vecAllNumbersSequence.size());
          value = Math.round(1.0f * value / jpbIncrement);
          PlaySequence threadB = new PlaySequence(this, vecAllNumbersSequence, value);
          threadB.start();
          break;
      }
    }
  } // GEN-LAST:event_jbtnPlayPauseActionPerformed
コード例 #2
0
  /**
   * This method is called when the Play Stored Sequence button is pressed. It passes the vector of
   * stored WAV file names to the PlaySequence class which plays them in sequence.
   *
   * @param evt a standard Java action event for a JButton
   */
  private void jbtnPlayStoredActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jbtnPlayStoredActionPerformed
    jbrProgress.setValue(0);
    nSequenceToPlay = 1; // 1 = vecStoredSequence

    PlaySequence thread = new PlaySequence(this, vecStoredSequence);

    thread.start();
  } // GEN-LAST:event_jbtnPlayStoredActionPerformed
コード例 #3
0
 /**
  * This method is called when the Play 0 to 9 Test button is pressed to play all the WAV files for
  * testing purposes.
  *
  * @param evt a standard Java action event for a JButton
  */
 private void jbtnPlayAllActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jbtnPlayAllActionPerformed
   // create a local vector and add all the WAV files to that data structure
   // Vector<String> vecSequence = new Vector<String>() ;
   vecAllNumbersSequence.clear();
   for (int k = 0; k < strFiles.length; k++) {
     vecAllNumbersSequence.add(strFilesHome + strFiles[k] + ".wav ");
   }
   // play the created sequence of WAV files
   jbrProgress.setValue(0);
   nSequenceToPlay = 2; // 2 = vecAllNumbersSequence
   PlaySequence thread = new PlaySequence(this, vecAllNumbersSequence);
   thread.start();
 } // GEN-LAST:event_jbtnPlayAllActionPerformed