AudioSystem.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:OpenJSharp 作者:
/**
 * Obtains an audio input stream from the provided <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> 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 <code>File</code>
 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static AudioInputStream getAudioInputStream(File file)
    throws UnsupportedAudioFileException, IOException {

    List providers = getAudioFileReaders();
    AudioInputStream audioStream = null;

    for(int i = 0; i < providers.size(); i++ ) {
        AudioFileReader reader = (AudioFileReader) providers.get(i);
        try {
            audioStream = reader.getAudioInputStream( file ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input file");
    } else {
        return audioStream;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号