Java Code Examples for javax.sound.midi.spi.MidiFileReader

The following examples show how to use javax.sound.midi.spi.MidiFileReader. These examples are extracted from open source projects. 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 Project: openjdk-8-source   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 3
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 4
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 5
Source Project: jdk1.8-source-analysis   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified <code>File</code>.
 * The <code>File</code> must point to valid MIDI file data
 * for a file type recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param file the <code>File</code> from which the <code>Sequence</code>
 * should be constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the File
 * @throws InvalidMidiDataException if the File does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static Sequence getSequence(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from file");
    } else {
        return sequence;
    }
}
 
Example 6
/**
 * 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 7
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 8
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 9
Source Project: jdk8u_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 10
Source Project: dragonwell8_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 11
Source Project: openjdk-8-source   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified <code>File</code>.
 * The <code>File</code> must point to valid MIDI file data
 * for a file type recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param file the <code>File</code> from which the <code>Sequence</code>
 * should be constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the File
 * @throws InvalidMidiDataException if the File does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static Sequence getSequence(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from file");
    } else {
        return sequence;
    }
}
 
Example 12
Source Project: hottub   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 13
Source Project: TencentKona-8   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 14
Source Project: TencentKona-8   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 15
Source Project: Java8CN   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 16
Source Project: jdk8u_jdk   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 17
Source Project: jdk8u60   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 18
Source Project: Java8CN   Source File: MidiSystem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 19
Source Project: openjdk-8   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 20
Source Project: jdk8u60   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified <code>File</code>.
 * The <code>File</code> must point to valid MIDI file data
 * for a file type recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param file the <code>File</code> from which the <code>Sequence</code>
 * should be constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the File
 * @throws InvalidMidiDataException if the File does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static Sequence getSequence(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from file");
    } else {
        return sequence;
    }
}
 
Example 21
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: MIT License 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the data in the specified URL.  The URL
 * must point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param url the URL from which file format information should be
 * extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("url is not a supported file type");
    } else {
        return format;
    }
}
 
Example 22
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: MIT License 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 23
Source Project: JDKSourceCode1.8   Source File: MidiSystem.java    License: MIT License 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified <code>File</code>.
 * The <code>File</code> must point to valid MIDI file data
 * for a file type recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param file the <code>File</code> from which the <code>Sequence</code>
 * should be constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the File
 * @throws InvalidMidiDataException if the File does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs
 */
public static Sequence getSequence(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from file");
    } else {
        return sequence;
    }
}
 
Example 24
Source Project: openjdk-jdk8u   Source File: JDK13Services.java    License: 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 Project: jdk8u_jdk   Source File: JDK13Services.java    License: 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 26
Source Project: openjdk-jdk8u   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}
 
Example 27
Source Project: openjdk-jdk8u   Source File: MidiSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Obtains a MIDI sequence from the specified URL.  The URL must
 * point to valid MIDI file data for a file type recognized
 * by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while constructing the <code>Sequence</code>
 * object from the file data.
 *
 * @param url the URL from which the <code>Sequence</code> should be
 * constructed
 * @return a <code>Sequence</code> object based on the MIDI file data
 * pointed to by the URL
 * @throws InvalidMidiDataException if the URL does not point to valid MIDI
 * file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the URL
 */
public static Sequence getSequence(URL url)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    Sequence sequence = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            sequence = reader.getSequence( url ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( sequence==null ) {
        throw new InvalidMidiDataException("could not get sequence from URL");
    } else {
        return sequence;
    }
}
 
Example 28
Source Project: hottub   Source File: JDK13Services.java    License: 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 29
/**
 * 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 30
/**
 * Obtains the MIDI file format of the specified <code>File</code>.  The
 * <code>File</code> must point to valid MIDI file data for a file type
 * recognized by the system.
 * <p>
 * This operation can only succeed for files of a type which can be parsed
 * by an installed file reader.  It may fail with an InvalidMidiDataException
 * even for valid files if no compatible file reader is installed.  It
 * will also fail with an InvalidMidiDataException if a compatible file reader
 * is installed, but encounters errors while determining the file format.
 *
 * @param file the <code>File</code> from which file format information
 * should be extracted
 * @return a <code>MidiFileFormat</code> object describing the MIDI file
 * format
 * @throws InvalidMidiDataException if the <code>File</code> does not point
 *  to valid MIDI file data recognized by the system
 * @throws IOException if an I/O exception occurs while accessing the file
 *
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(URL)
 */
public static MidiFileFormat getMidiFileFormat(File file)
    throws InvalidMidiDataException, IOException {

    List providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = (MidiFileReader) providers.get(i);
        try {
            format = reader.getMidiFileFormat( file ); // throws IOException
            break;
        } catch (InvalidMidiDataException e) {
            continue;
        }
    }

    if( format==null ) {
        throw new InvalidMidiDataException("file is not a supported file type");
    } else {
        return format;
    }
}