当前位置: 首页>>代码示例>>Java>>正文


Java MidiFileReader.getMidiFileFormat方法代码示例

本文整理汇总了Java中javax.sound.midi.spi.MidiFileReader.getMidiFileFormat方法的典型用法代码示例。如果您正苦于以下问题:Java MidiFileReader.getMidiFileFormat方法的具体用法?Java MidiFileReader.getMidiFileFormat怎么用?Java MidiFileReader.getMidiFileFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sound.midi.spi.MidiFileReader的用法示例。


在下文中一共展示了MidiFileReader.getMidiFileFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMidiFileFormat

import javax.sound.midi.spi.MidiFileReader; //导入方法依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:MidiSystem.java

示例2: getMidiFileFormat

import javax.sound.midi.spi.MidiFileReader; //导入方法依赖的package包/类
/**
 * 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
 * {@code InvalidMidiDataException} even for valid files if no compatible
 * file reader is installed. It will also fail with an
 * {@code 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} 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
 * @throws NullPointerException if {@code url} is {@code null}
 * @see #getMidiFileFormat(InputStream)
 * @see #getMidiFileFormat(File)
 */
public static MidiFileFormat getMidiFileFormat(final URL url)
        throws InvalidMidiDataException, IOException {
    Objects.requireNonNull(url);

    List<MidiFileReader> providers = getMidiFileReaders();
    MidiFileFormat format = null;

    for(int i = 0; i < providers.size(); i++) {
        MidiFileReader reader = 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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:MidiSystem.java

示例3: getMidiFileFormat

import javax.sound.midi.spi.MidiFileReader; //导入方法依赖的package包/类
/**
 * Read a MidiFileFormat object from the given file.
 *
 * @param file the file from which to read the MidiFileFormat
 * @return the MidiFileFormat object
 * @throws InvalidMidiDataException if we were unable to read the MidiFileFormat
 * @throws IOException if an I/O error happened while reading
 */
public static MidiFileFormat getMidiFileFormat(File file)
  throws InvalidMidiDataException, IOException
{
  Iterator<MidiFileReader> readers =
    ServiceFactory.lookupProviders(MidiFileReader.class);
  while (readers.hasNext())
  {
    MidiFileReader sr = readers.next();
    MidiFileFormat sb = sr.getMidiFileFormat(file);
    if (sb != null)
      return sb;
  }
  throw new InvalidMidiDataException("Can't read MidiFileFormat from file "
                                     + file);
}
 
开发者ID:cfriedt,项目名称:classpath,代码行数:24,代码来源:MidiSystem.java

示例4: getMidiFileFormat

import javax.sound.midi.spi.MidiFileReader; //导入方法依赖的package包/类
/**
 * Read a MidiFileFormat object from the given stream.
 *
 * @param stream the stream from which to read the MidiFileFormat
 * @return the MidiFileFormat object
 * @throws InvalidMidiDataException if we were unable to read the MidiFileFormat
 * @throws IOException if an I/O error happened while reading
 */
public static MidiFileFormat getMidiFileFormat(InputStream stream)
  throws InvalidMidiDataException, IOException
{
  Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
  while (readers.hasNext())
  {
    MidiFileReader sr = (MidiFileReader) readers.next();
    MidiFileFormat sb = sr.getMidiFileFormat(stream);
    if (sb != null)
      return sb;
  }
  throw new InvalidMidiDataException("Can't read MidiFileFormat from stream");
}
 
开发者ID:vilie,项目名称:javify,代码行数:22,代码来源:MidiSystem.java

示例5: getMidiFileFormat

import javax.sound.midi.spi.MidiFileReader; //导入方法依赖的package包/类
/**
 * Read a MidiFileFormat object from the given stream.
 * 
 * @param stream the stream from which to read the MidiFileFormat
 * @return the MidiFileFormat object
 * @throws InvalidMidiDataException if we were unable to read the MidiFileFormat
 * @throws IOException if an I/O error happened while reading
 */
public static MidiFileFormat getMidiFileFormat(InputStream stream)
  throws InvalidMidiDataException, IOException
{
  Iterator readers = ServiceFactory.lookupProviders(MidiFileReader.class);
  while (readers.hasNext())
  {
    MidiFileReader sr = (MidiFileReader) readers.next();
    MidiFileFormat sb = sr.getMidiFileFormat(stream);
    if (sb != null)
      return sb;
  }
  throw new InvalidMidiDataException("Can't read MidiFileFormat from stream");
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:22,代码来源:MidiSystem.java


注:本文中的javax.sound.midi.spi.MidiFileReader.getMidiFileFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。