-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.java
65 lines (51 loc) · 1.32 KB
/
tester.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
58
59
60
61
62
63
64
65
import java.io.FileInputStream;
import javazoom.jl.player.Player;
import javazoom.jl.player.advanced.*;
public class tester
{
public static void main(String[] args)
{
SoundJLayer soundToPlay = new SoundJLayer("03 - Sleeping With A Friend.mp3");
soundToPlay.play();
}
}
class SoundJLayer extends PlaybackListener implements Runnable
{
private AdvancedPlayer player;
public SoundJLayer(String filePath)
{
}
public void play()
{
try{
FileInputStream fis = new FileInputStream("F:\\Gorillaz\\02 - 5_4.mp3");
Player playMP3 = new Player(fis);
playMP3.play();
}
catch(Exception exc){
exc.printStackTrace();
System.out.println("Failed to play the file.");
}
}
// PlaybackListener members
public void playbackStarted(PlaybackEvent playbackEvent)
{
System.out.println("playbackStarted");
}
public void playbackFinished(PlaybackEvent playbackEvent)
{
System.out.println("playbackEnded");
}
// Runnable members
public void run()
{
try
{
this.player.play();
}
catch (javazoom.jl.decoder.JavaLayerException ex)
{
ex.printStackTrace();
}
}
}