The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.sound.midi  [7 examples] > Properties  [4 examples]

e718. Determining the File Format of a Midi Audio File

    try {
        // From file
        MidiFileFormat fformat = MidiSystem.getMidiFileFormat(new File("midifile"));
    
        // From URL
        fformat = MidiSystem.getMidiFileFormat(new URL("http://hostname/midifile"));
    
        // Get file format
        switch (fformat.getType()) {
          case 0:
            // mid
            break;
          case 1:
            // rmf
            break;
        }
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    } catch (InvalidMidiDataException e) {
        // File format is not supported.
    }

 Related Examples
e719. Determining the Duration of a Midi Audio File
e720. Determining the Position of a Midi Sequencer
e721. Setting the Volume of Playing Midi Audio

See also: Events    Playing   


© 2002 Addison-Wesley.