/**
* Testing the MP3 Player.
*/
public static void main(String args[]) {
BaseAudioRenderer mp3 = new JavaLayerMp3Renderer();
String music1 = "file:///d:/golden t studios/trash/sound/MUSIC1.MP3";
String music2 = "file:///d:/golden t studios/trash/sound/music2.mp3";
if (args != null) {
if (args.length >= 1) {
music1 = music2 = args[0];
}
if (args.length >= 2) {
music1 = args[1];
}
}
// test first song
try {
mp3.play(new URL(music1));
}
catch (Exception e) {
e.printStackTrace();
}
// hear some music
int update = 0;
while (mp3.getStatus() == BaseAudioRenderer.PLAYING) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}
System.out.println(update++);
if (update > 4) {
mp3.stop();
}
}
// first song stopped
System.out.println("end-song");
// test second song
try {
mp3.play(new URL(music2));
}
catch (Exception e) {
e.printStackTrace();
}
// wait until complete
while (mp3.getStatus() == BaseAudioRenderer.PLAYING) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}