blob: a9e043f1bfdfdd20e479f6f1a96885e028d68e65 (
plain) (
blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
package NET.worlds.scape;
import NET.worlds.network.Cache;
import NET.worlds.network.CacheFile;
import NET.worlds.network.URL;
class ASFThread extends Thread {
private URL url;
private ASFSoundPlayer player;
private static ASFThread asfThread;
private static boolean paused;
ASFThread(URL url, ASFSoundPlayer player) {
this.url = url;
this.player = player;
setASF(this);
}
@Override
public void run() {
CacheFile cf = Cache.getFile(this.url);
cf.waitUntilLoaded();
if (cf.error()) {
this.player.running = 3;
releaseASF(this);
} else if (!paused) {
String localName = cf.getLocalName().replace('/', '\\');
if (!ASFSoundPlayer.nativePlay(localName)) {
this.player.running = 3;
}
releaseASF(this);
}
}
static synchronized void pauseASF() {
if (!paused && asfThread != null) {
ASFThread t = asfThread;
stopASF();
paused = true;
new ASFThread(t.url, t.player);
}
paused = true;
}
static synchronized void resumeASF() {
if (paused) {
ASFThread t = asfThread;
paused = false;
if (t != null) {
new ASFThread(t.url, t.player);
}
}
}
static synchronized void releaseASF(ASFThread t) {
if (asfThread == t) {
asfThread = null;
}
}
static synchronized void setASF(ASFThread t) {
if (asfThread == null || !asfThread.url.equals(t.url)) {
asfThread = t;
asfThread.setDaemon(true);
asfThread.start();
}
}
static synchronized void stopASF() {
if (asfThread != null) {
asfThread = null;
if (!paused) {
ASFSoundPlayer.nativePlay("");
}
}
}
static boolean isActive() {
return asfThread != null;
}
}
|