use of javax.sound.sampled.AudioFileFormat 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;
}
use of javax.sound.sampled.AudioFileFormat in project jdk8u_jdk by JetBrains.
the class AuFileReader method getAudioFileFormat.
/**
* Obtains the audio file format of the File provided. The File must
* point to valid audio file data.
* @param file the File from which file format information should be
* extracted
* @return an <code>AudioFileFormat</code> object describing the audio file format
* @throws UnsupportedAudioFileException if the File does not point to valid audio
* file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
FileInputStream fis = null;
BufferedInputStream bis = null;
AudioFileFormat fileFormat = null;
AudioFormat format = null;
// throws IOException
fis = new FileInputStream(file);
// part of fix for 4325421
try {
bis = new BufferedInputStream(fis, bisBufferSize);
// throws UnsupportedAudioFileException
fileFormat = getAudioFileFormat(bis);
} finally {
fis.close();
}
return fileFormat;
}
use of javax.sound.sampled.AudioFileFormat in project jdk8u_jdk by JetBrains.
the class AuFileReader method getAudioInputStream.
/**
* Obtains an audio stream from the URL provided. The URL must
* point to valid audio file data.
* @param url the URL for which the <code>AudioInputStream</code> should be
* constructed
* @return an <code>AudioInputStream</code> object based on the audio file data pointed
* to by the URL
* @throws UnsupportedAudioFileException if the URL does not point to valid audio
* file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException {
InputStream urlStream = null;
BufferedInputStream bis = null;
AudioFileFormat fileFormat = null;
// throws IOException
urlStream = url.openStream();
AudioInputStream result = null;
try {
bis = new BufferedInputStream(urlStream, bisBufferSize);
result = getAudioInputStream((InputStream) bis);
} finally {
if (result == null) {
urlStream.close();
}
}
return result;
}
use of javax.sound.sampled.AudioFileFormat in project jdk8u_jdk by JetBrains.
the class AiffFileReader method getAudioFileFormat.
// METHODS TO IMPLEMENT AudioFileReader
/**
* Obtains the audio file format of the input stream provided. The stream must
* point to valid audio file data. In general, audio file providers may
* need to read some data from the stream before determining whether they
* support it. These parsers must
* be able to mark the stream, read enough data to determine whether they
* support the stream, and, if not, reset the stream's read pointer to its original
* position. If the input stream does not support this, this method may fail
* with an IOException.
* @param stream the input stream from which file format information should be
* extracted
* @return an <code>AudioFileFormat</code> object describing the audio file format
* @throws UnsupportedAudioFileException if the stream does not point to valid audio
* file data recognized by the system
* @throws IOException if an I/O exception occurs
* @see InputStream#markSupported
* @see InputStream#mark
*/
public AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException {
// fix for 4489272: AudioSystem.getAudioFileFormat() fails for InputStream, but works for URL
AudioFileFormat aff = getCOMM(stream, true);
// the following is not strictly necessary - but was implemented like that in 1.3.0 - 1.4.1
// so I leave it as it was. May remove this for 1.5.0
stream.reset();
return aff;
}
use of javax.sound.sampled.AudioFileFormat in project jdk8u_jdk by JetBrains.
the class AuFileReader method getAudioInputStream.
/**
* Obtains an audio stream from the File provided. The File must
* point to valid audio file data.
* @param file the File for which the <code>AudioInputStream</code> should be
* constructed
* @return an <code>AudioInputStream</code> object based on the audio file data pointed
* to by the File
* @throws UnsupportedAudioFileException if the File does not point to valid audio
* file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
FileInputStream fis = null;
BufferedInputStream bis = null;
AudioFileFormat fileFormat = null;
// throws IOException
fis = new FileInputStream(file);
AudioInputStream result = null;
// part of fix for 4325421
try {
bis = new BufferedInputStream(fis, bisBufferSize);
result = getAudioInputStream((InputStream) bis);
} finally {
if (result == null) {
fis.close();
}
}
return result;
}
Aggregations