Search in sources :

Example 1 with TAudioFileFormat

use of org.tritonus.share.sampled.file.TAudioFileFormat in project Minim by ddf.

the class JSMinim method getID3Tags.

@SuppressWarnings("unchecked")
private Map<String, Object> getID3Tags(String filename) {
    debug("Getting the properties.");
    Map<String, Object> props = new HashMap<String, Object>();
    try {
        MpegAudioFileReader reader = new MpegAudioFileReader(this);
        InputStream stream = (InputStream) createInput.invoke(fileLoader, filename);
        if (stream != null) {
            AudioFileFormat baseFileFormat = reader.getAudioFileFormat(stream, stream.available());
            stream.close();
            if (baseFileFormat instanceof TAudioFileFormat) {
                TAudioFileFormat fileFormat = (TAudioFileFormat) baseFileFormat;
                props = (Map<String, Object>) fileFormat.properties();
                if (props.size() == 0) {
                    error("No file properties available for " + filename + ".");
                } else {
                    debug("File properties: " + props.toString());
                }
            }
        }
    } catch (UnsupportedAudioFileException e) {
        error("Couldn't get the file format for " + filename + ": " + e.getMessage());
    } catch (IOException e) {
        error("Couldn't access " + filename + ": " + e.getMessage());
    } catch (Exception e) {
        error("Error invoking createInput on the file loader object: " + e.getMessage());
    }
    return props;
}
Also used : TAudioFileFormat(org.tritonus.share.sampled.file.TAudioFileFormat) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) HashMap(java.util.HashMap) BufferedInputStream(java.io.BufferedInputStream) AudioInputStream(javax.sound.sampled.AudioInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) AudioFileFormat(javax.sound.sampled.AudioFileFormat) TAudioFileFormat(org.tritonus.share.sampled.file.TAudioFileFormat) LineUnavailableException(javax.sound.sampled.LineUnavailableException) MalformedURLException(java.net.MalformedURLException) UnsupportedAudioFileException(javax.sound.sampled.UnsupportedAudioFileException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 AudioFileFormat (javax.sound.sampled.AudioFileFormat)1 AudioInputStream (javax.sound.sampled.AudioInputStream)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)1 TAudioFileFormat (org.tritonus.share.sampled.file.TAudioFileFormat)1