views:

41

answers:

3

as title How can i play a sound file repeatedly in java v1.4?

A: 

Tutorial

org.life.java
A: 

If you just want to play the wav file then 'org.life.java''s answer is correct. For other format types you can use JMF( http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html ).

Note: JMF is obsolete now... But it will work with jdk 1.4

Favonius
A: 
import java.net.URL;
import javax.sound.sampled.*;

public class LoopSound {

  public static void main(String[] args) throws Exception {
    URL url = new URL(
      "http://pscode.org/media/leftright.wav");
    Clip clip = AudioSystem.getClip();
    AudioInputStream ais = AudioSystem.
      getAudioInputStream( url );
    clip.open(ais);
    clip.loop(0);
    javax.swing.JOptionPane.
      showMessageDialog(null, "Close to exit!");
  }
} 
Andrew Thompson