Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- int x = 1;
- String schrei = "David kanns jetzt";
- while(x <= 20) {
- System.out.println(schrei);
- x = x + 1;
- }
- if (x >= 20) playSound(url);
- }
- public static synchronized void playSound (final String url) {
- new Thread(new Runnable() {
- public void run() {
- try {
- Clip clip = AudioSystem.getClip();
- AudioInputStream inputStream = AudioSystem.getAudioInputStream(
- Main.class.getResourceAsStream("C:\\Users\\David\\Desktop" + url));
- clip.open(inputStream);
- clip.start();
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
- }
- }).start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement