javax.sound.sampled.spi.AudioFileReader Java Examples

The following examples show how to use javax.sound.sampled.spi.AudioFileReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JDK13Services.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example #2
Source File: JDK13Services.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example #3
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #4
Source File: AudioSystem.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified URL.  The URL must
 * point to valid audio file data.
 * @param url the URL from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an input/output exception occurs
 */
public static AudioFileFormat getAudioFileFormat(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #5
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains an audio input stream from 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 operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @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 static AudioInputStream getAudioInputStream(InputStream stream)
    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( stream ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
Example #6
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @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 AudioFileFormat getAudioFileFormat(File file)
    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( file ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #7
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified URL.  The URL must
 * point to valid audio file data.
 * @param url the URL from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an input/output exception occurs
 */
public static AudioFileFormat getAudioFileFormat(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #8
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains an audio input 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 static AudioInputStream getAudioInputStream(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
Example #9
Source File: JDK13Services.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example #10
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #11
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified URL.  The URL must
 * point to valid audio file data.
 * @param url the URL from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an input/output exception occurs
 */
public static AudioFileFormat getAudioFileFormat(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #12
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @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 AudioFileFormat getAudioFileFormat(File file)
    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( file ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #13
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains an audio input stream from 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 operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @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 static AudioInputStream getAudioInputStream(InputStream stream)
    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( stream ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
Example #14
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains an audio input 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 static AudioInputStream getAudioInputStream(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
Example #15
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #16
Source File: AudioSystem.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #17
Source File: JDK13Services.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example #18
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #19
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains an audio input 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 static AudioInputStream getAudioInputStream(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
Example #20
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains an audio input stream from 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 operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @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 static AudioInputStream getAudioInputStream(InputStream stream)
    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( stream ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
Example #21
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @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 AudioFileFormat getAudioFileFormat(File file)
    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( file ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #22
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified URL.  The URL must
 * point to valid audio file data.
 * @param url the URL from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an input/output exception occurs
 */
public static AudioFileFormat getAudioFileFormat(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #23
Source File: AudioSystem.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #24
Source File: JDK13Services.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a List containing installed instances of the providers for the
 * requested service. The returned List is immutable.
 *
 * @param serviceClass The type of providers requested. This should be one
 *                     of AudioFileReader.class, AudioFileWriter.class,
 *                     FormatConversionProvider.class, MixerProvider.class,
 *                     MidiDeviceProvider.class, MidiFileReader.class,
 *                     MidiFileWriter.class or SoundbankReader.class.
 *
 * @return A List of providers of the requested type. This List is
 *         immutable.
 */
public static List<?> getProviders(final Class<?> serviceClass) {
    final List<?> providers;
    if (!MixerProvider.class.equals(serviceClass)
            && !FormatConversionProvider.class.equals(serviceClass)
            && !AudioFileReader.class.equals(serviceClass)
            && !AudioFileWriter.class.equals(serviceClass)
            && !MidiDeviceProvider.class.equals(serviceClass)
            && !SoundbankReader.class.equals(serviceClass)
            && !MidiFileWriter.class.equals(serviceClass)
            && !MidiFileReader.class.equals(serviceClass)) {
        providers = new ArrayList<>(0);
    } else {
        providers = JSSecurityManager.getProviders(serviceClass);
    }
    return Collections.unmodifiableList(providers);
}
 
Example #25
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example #26
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtains an audio input 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 static AudioInputStream getAudioInputStream(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input URL");
    } else {
        return audioStream;
    }
}
 
Example #27
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtains an audio input stream from 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 operation, this method may fail
 * with an <code>IOException</code>.
 * @param stream the input stream from which the <code>AudioInputStream</code> should be
 * constructed
 * @return an <code>AudioInputStream</code> object based on the audio file data contained
 * in the input stream.
 * @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 static AudioInputStream getAudioInputStream(InputStream stream)
    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( stream ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( audioStream==null ) {
        throw new UnsupportedAudioFileException("could not get audio input stream from input stream");
    } else {
        return audioStream;
    }
}
 
Example #28
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified <code>File</code>.  The <code>File</code> must
 * point to valid audio file data.
 * @param file the <code>File</code> from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @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 AudioFileFormat getAudioFileFormat(File file)
    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( file ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #29
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Obtains the audio file format of the specified URL.  The URL must
 * point to valid audio file data.
 * @param url the URL from which file format information should be
 * extracted
 * @return an <code>AudioFileFormat</code> object describing the audio file format
 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
 * file data recognized by the system
 * @throws IOException if an input/output exception occurs
 */
public static AudioFileFormat getAudioFileFormat(URL url)
    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( url ); // throws IOException
            break;
        } catch (UnsupportedAudioFileException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new UnsupportedAudioFileException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example #30
Source File: AudioSystem.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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;
    }
}