Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main {
  2.  
  3.     public static void main(String[] args) {
  4.         int x = 1;
  5.         String schrei = "David kanns jetzt";
  6.         while(x <= 20) {
  7.             System.out.println(schrei);
  8.             x = x + 1;
  9.         }
  10.             if (x >= 20) playSound(url);
  11.     }
  12.    
  13.     public static synchronized void playSound (final String url) {
  14.         new Thread(new Runnable() {
  15.  
  16.             public void run() {
  17.                 try {
  18.                     Clip clip = AudioSystem.getClip();
  19.                     AudioInputStream inputStream = AudioSystem.getAudioInputStream(
  20.                             Main.class.getResourceAsStream("C:\\Users\\David\\Desktop" + url));
  21.                     clip.open(inputStream);
  22.                     clip.start();
  23.                 } catch (Exception e) {
  24.                     System.err.println(e.getMessage());
  25.                 }
  26.             }
  27.         }).start();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement