English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Two things:
1. I would like to loop a midi file in the background.
2. I need to play .WAV file on JDialog Box.
If you can help me, I'd be very apperciative.

2007-03-12 02:15:06 · 2 answers · asked by treysonabbe 1 in Computers & Internet Programming & Design

2 answers

The .wav file is easy. Just load it using the AudioClip and Applet classes, as shown below. Then play it once or loop it until you meet some criteria (time lapse, task complete, dialog disposed, etc.).

AudioClip ac = Applet.newAudioClip(myWavFileURL);
ac.play();
while(play){
ac.loop();
}

Note that you do NOT need to create an Applet to get an AudioClip implementation, just use the static newAudioClip() method.

For midi, it may be a little more complicated. You need to get your (sampled?) clip. See the guidance at this Sun reference:
http://java.sun.com/j2se/1.5.0/docs/guide/sound/programmer_guide/contents.html

2007-03-13 02:43:06 · answer #1 · answered by vincentgl 5 · 0 0

Take a read here:
http://www.jsresources.org/faq_midi.html

2007-03-12 15:00:00 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers