The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.sound.midi  [7 examples] > Playing  [2 examples]

e717. Playing Streaming Midi Audio

Supported audio file formats: mid, rmf
    try {
        Sequencer sequencer = MidiSystem.getSequencer();
        sequencer.open();
    
        // From file
        InputStream is = new BufferedInputStream(
            new FileInputStream(new File("midifile")));
    
        // From URL
        is = new BufferedInputStream(
            new URL("http://hostname/rmffile").openStream());
    
        sequencer.setSequence(is);
    
        // Start playing
        sequencer.start();
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    } catch (MidiUnavailableException e) {
    } catch (InvalidMidiDataException e) {
    }

 Related Examples
e716. Loading and Playing Midi Audio

See also: Events    Properties   


© 2002 Addison-Wesley.