J
James Harvey
Hi all,
I am working on a graphical demo. I am experimenting with the JLayer
library from JavaZoom (http://www.javazoom.net/projects.html) for
playing MP3s. The playback quality seems very nice.
It seems that the Player.play() method blocks until playback completes,
so I decided to wrap it in a thread:
private class PlayerThread extends Thread
{
private Player player;
public PlayerThread(Player player)
{
this.player = player;
}
public void run()
{
try
{
player.play();
System.out.println("PLAYBACK COMPLETE");
}
catch (JavaLayerException ex)
{
ex.printStackTrace();
}
}
public void stopPlayback()
{
player.close();
}
}
This works, but this thread seems to affect the performance of my main
thread quite badly. Without having looked at the source of JLayer (yet),
I'm guessing that it doesn't play nice by yield()ing.
Can anybody suggest:
1) A way to decrease the performance hit from this thread. Possibly
decode the MP3 to raw audio before the application proper starts?
2) A nice lightweight MP3 or Ogg Vorbis library for Java that runs
nicely in its own thread. All I need is simple load(), play(), stop()
functionality. I have found quite a few but if anybody can point me in
the right direction without having to evaluate them all it would be much
appreciated.
Thank you,
Bruce.
I am working on a graphical demo. I am experimenting with the JLayer
library from JavaZoom (http://www.javazoom.net/projects.html) for
playing MP3s. The playback quality seems very nice.
It seems that the Player.play() method blocks until playback completes,
so I decided to wrap it in a thread:
private class PlayerThread extends Thread
{
private Player player;
public PlayerThread(Player player)
{
this.player = player;
}
public void run()
{
try
{
player.play();
System.out.println("PLAYBACK COMPLETE");
}
catch (JavaLayerException ex)
{
ex.printStackTrace();
}
}
public void stopPlayback()
{
player.close();
}
}
This works, but this thread seems to affect the performance of my main
thread quite badly. Without having looked at the source of JLayer (yet),
I'm guessing that it doesn't play nice by yield()ing.
Can anybody suggest:
1) A way to decrease the performance hit from this thread. Possibly
decode the MP3 to raw audio before the application proper starts?
2) A nice lightweight MP3 or Ogg Vorbis library for Java that runs
nicely in its own thread. All I need is simple load(), play(), stop()
functionality. I have found quite a few but if anybody can point me in
the right direction without having to evaluate them all it would be much
appreciated.
Thank you,
Bruce.