rodrwan

Reproduccion-de-sonido-java

Apr 12th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.io.File;
  2. import javax.sound.sampled.AudioSystem;
  3. import javax.sound.sampled.Clip;
  4. public class Main {
  5.   public static void main(String[] args) {
  6.     try {
  7.       Clip sonido = AudioSystem.getClip();
  8.       File a = new File("c:\\sonidos\\sonido1.wav");
  9.       sonido.open(AudioSystem.getAudioInputStream(a);
  10.       sonido.start();
  11.       System.out.println("Reproduciendo 10s. de sonido...");
  12.       Thread.sleep(1000); // 1000 milisegundos (10 segundos)
  13.       sonido.close();
  14.     }
  15.     catch (Exception tipoerror) {
  16.       System.out.println("" + tipoerror);
  17.     }
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment