/**
* Obtains the audio file format of the provided input stream. The stream must
* point to valid audio file data. The implementation of this method may require
* multiple parsers to examine the stream to determine 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 these operations, this method may fail
* with an <code>IOException</code>.
* @param stream the input stream from which file format information should be
* extracted
* @return an <code>AudioFileFormat</code> object describing the stream's audio file format
* @throws UnsupportedAudioFileException if the stream does not point to valid audio
* file data recognized by the system
* @throws IOException if an input/output exception occurs
* @see InputStream#markSupported
* @see InputStream#mark
*/
public static AudioFileFormat getAudioFileFormat(InputStream stream)
throws UnsupportedAudioFileException, IOException {
List providers = getAudioFileReaders();
AudioFileFormat format = null;
for(int i = 0; i < providers.size(); i++ ) {
AudioFileReader reader = (AudioFileReader) providers.get(i);
try {
format = reader.getAudioFileFormat( stream ); // throws IOException
break;
} catch (UnsupportedAudioFileException e) {
continue;
}
}
if( format==null ) {
throw new UnsupportedAudioFileException("file is not a supported file type");
} else {
return format;
}
}
AudioSystem.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:OpenJSharp
作者:
评论列表
文章目录