Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;

import javax.sound.midi.MidiSystem;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;

public class Main {
    public static void main(String[] argv) throws Exception {
        // From file
        Sequence sequence = MidiSystem.getSequence(new File("midiaudiofile"));

        // From URL
        // sequence = MidiSystem.getSequence(new
        // URL("http://hostname/midiaudiofile"));

        // Create a sequencer for the sequence
        Sequencer sequencer = MidiSystem.getSequencer();
        sequencer.open();
        sequencer.setSequence(sequence);

        // Start playing
        sequencer.start();
    }
}