-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSound.java
57 lines (40 loc) · 875 Bytes
/
Sound.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
public class Sound implements Runnable {
Clip c;
int x1;
Point mymax;
int mp, tim;
AudioInputStream ad;
File f;
public void run() {
c.start();
try {
c.setMicrosecondPosition(300);
Thread.sleep(tim);
c.stop();
c.setMicrosecondPosition(300);
} catch (Exception e) {
System.out.println("Error Here");
}
}
void running(int x, int tim) {
this.tim = tim;
if (x1 != x) {
x1 = x;
f = new File("../public/w" + x1 + ".wav");
try {
ad = AudioSystem.getAudioInputStream(f);
c = AudioSystem.getClip();
c.open(ad);
Thread th = new Thread(this);
th.start();
} catch (Exception e) {
System.out.println("Dissappointment" + e.getMessage());
}
}
run();
}
}