예제 #1
0
  /**
   * Indicates whether an audio file of the type specified can be written from the audio input
   * stream indicated.
   *
   * @param fileType file type for which write capabilities are queried
   * @param stream for which file writing support is queried
   * @return <code>true</code> if the file type is supported for this audio input stream, otherwise
   *     <code>false</code>
   */
  public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) {

    AudioFileFormat.Type types[] = getAudioFileTypes(stream);

    for (int i = 0; i < types.length; i++) {
      if (fileType.equals(types[i])) {
        return true;
      }
    }
    return false;
  }
예제 #2
0
  /**
   * List the available audio file format types, as a multi-line string. Each line consists of the
   * name of an Audio file format type, followed by a suffix "_FILE" if the format can be produced
   * as a file, and "_STREAM" if the format can be streamed.
   *
   * @return a multi-line string, or an empty string if no audio file types are available.
   */
  public static String getAudioFileFormatTypes() {
    StringBuilder output = new StringBuilder();
    AudioFileFormat.Type[] audioTypes = AudioSystem.getAudioFileTypes();
    for (int t = 0; t < audioTypes.length; t++) {
      AudioFileFormat.Type audioType = audioTypes[t];
      String typeName = audioType.toString();
      boolean isSupported = true;
      if (typeName.equals("MP3")) isSupported = canCreateMP3();
      else if (typeName.equals("Vorbis")) isSupported = canCreateOgg();
      audioType = MaryAudioUtils.getAudioFileFormatType(typeName);
      if (audioType == null) {
        isSupported = false;
      }

      if (isSupported && AudioSystem.isFileTypeSupported(audioType)) {
        output.append(typeName).append("_FILE\n");

        if (typeName.equals("MP3") || typeName.equals("Vorbis"))
          output.append(typeName).append("_STREAM\n");
      }
    }
    return output.toString();
  }