blob: 7783544d145e6add2163bb819ce96ca08712bf89 (
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
|
package itunes.client.swing;
import java.io.FileInputStream;
import java.io.InputStream;
import javax.swing.JOptionPane;
import itunes.client.swing.ZPlayer;
public class Player extends Thread {
private javazoom.jl.player.Player p;
private ZPlayer prog;
public Player(ZPlayer prog, String fileName) {
this.prog = prog;
FileInputStream f=null;
try {
f = new FileInputStream(fileName);
} catch (Exception e) {
e.printStackTrace();
}
newPlayer(f);
}
private void newPlayer(InputStream f) {
if (p != null)
this.stopMusic();
try{
p = new javazoom.jl.player.Player(f);
} catch (Exception e) {
e.printStackTrace();
}
}
public Player(ZPlayer prog, InputStream f) {
this.prog = prog;
newPlayer(f);
}
public void run() {
try {
p.play();
} catch (javazoom.jl.decoder.BitstreamException be) {
JOptionPane.showMessageDialog(prog.frame,"Unsupported file format!\n"+be.getLocalizedMessage());
prog.stopPlaying();
}catch (Exception e) {
e.printStackTrace();
prog.stopPlaying();
}
if (p.isComplete()) {
prog.playNext(1);
}
}
public int getPosition() {
return p.getPosition();
}
public void stopMusic() {
p.close();
}
}
|