コード例 #1
0
  // Set the buttons displayed in the panel
  // textFilePath - The path to the sound effect definition file
  // Returns 0 (an error occurred and a new project was opened), 1 (an error occurred), 2 (the
  // project opened normally)
  public int loadFile(String textFilePath) {
    clearBoard();

    // Get the sounds contained in the given project file
    ArrayList<SoundInfo> readSounds = soundManager.readFile(textFilePath);

    // Add buttons to the interface for each sound in the file
    for (int s = 0; s < readSounds.size(); s++) {
      SoundInfo curr = readSounds.get(s);
      if (checkValidKey(curr.getKeyName())) {
        addSound(readSounds.get(s));
      } else {
        soundManager.deleteSound(curr.getKeyCode());
      }
    }

    // Report if an error occurred while opening the project
    // Allow the user to close the project without proceeding
    if (soundManager.getProjectModified()) {
      int choice =
          JOptionPane.showConfirmDialog(
              frame,
              "One or more errors were encountered while reading the project file. "
                  + "The file may be missing, not well-formatted, or not a Cue Masher project file. Do you want to proceed?",
              "Keep Project Open?",
              JOptionPane.YES_NO_OPTION);
      if (choice == JOptionPane.NO_OPTION) {
        openNewProject();
        return 0;
      }
      return 1;
    }
    return 2;
  }
コード例 #2
0
ファイル: Sound.java プロジェクト: najunhee/propose-lib
 public void stop(int raw_id) {
   SoundInfo info = soundMap.get(raw_id);
   if (info.isComplete) {
     if (info.getStreamId() != null) {
       soundPool.stop(info.getStreamId());
       info.setStreamId(null);
     }
   }
 }
コード例 #3
0
ファイル: Sound.java プロジェクト: najunhee/propose-lib
  public void play(int raw_id, boolean loop) {
    int intLoop = 0;
    if (loop) {
      intLoop = -1;
    }
    SoundInfo sInfo = soundMap.get(raw_id);
    try {
      int streamId = soundPool.play(sInfo.getSoundId(), 1.0f, 1.0f, 10, intLoop, 1);
      sInfo.setStreamId(streamId);
    } catch (Exception e) {

    }
  }
コード例 #4
0
  // Update a sound in the displayed buttons, sound list, and sound file
  // soundClip - An object storing information about the added or updated sound
  public void updateSound(SoundInfo soundClip) {

    // Add the sound to the project
    SoundInfo newSound = soundManager.addSound(soundClip);

    if (newSound != null) {
      // Add a new button to the GUI
      addSound(newSound);
    }

    if (soundManager.getProjectModified()) {

      if (newSound == null) {
        // An existing sound was updated
        // Update the button label and tooltip
        for (int s = 0; s < soundList.size(); s++) {
          BoardButton button = soundList.get(s);
          if (button.getKeyCode() == soundClip.getKeyCode()) {
            button.updateButtonText();
            break;
          }
        }
      }

      // Update the GUI
      frame.setProjectModified();
      refreshSoundBoard();
    }
  }
コード例 #5
0
ファイル: Sound.java プロジェクト: najunhee/propose-lib
 @Override
 public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
   if (loadSoundMap.containsKey(sampleId)) {
     SoundInfo info = soundMap.get(loadSoundMap.get(sampleId));
     info.setSoundId(sampleId);
     if (status == 0) {
       info.setComplete(true);
     } else {
       info.setComplete(false);
     }
     loadSoundMap.remove(sampleId);
   }
   if (loadSoundMap.size() == 0) {
     completeListener.onAllComplete();
   }
 }