Click to See Complete Forum and Search --> : how to play a *.midi files in loop??? urgent!!!


OOZON
March 2nd, 2000, 07:07 PM
In less than 5H i have to give back to my teacher a java application game that i juste have finished but.....i have to play a files.midi in loop and i don't know the easiest way to proceed.....( i'm a beginner so please.....i need detailed feedback.....thnaks.)

Diamond
March 3rd, 2000, 07:44 PM
Try this way:


import java.applet.*;
import java.net.*;

public class MidiLoop extends Applet
{
// use your MIDI file name here:
protected final String SOUND_FILE_NAME = "littlecz.mid";

// applet entry point
public void init()
{
// ... any operators
try
{
// compose URL path to your midi file
URL url = new URL(getCodeBase(), SOUND_FILE_NAME);
// get audio clip reference
AudioClip audioClip = this.getAudioClip(url);
// play clip in infinite loop
audioClip.loop();
}
catch(MalformedURLException ex)
{
System.out.println("can't load sound file");
}

// ...
}
}