Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I create a thread to run media player in?

Status
Not open for further replies.

jbste

Programmer
Nov 9, 2003
1
GB
Hi
I am having problems with media player. When there are other processes running in the background or foreground the jmf media player starts skipping and sounds terrible. Here is my code:

private void createPlayer()
{
if(file == null)
{
System.out.println("file has null content");
return;
}
removeOldPlayer();//remove earlier players
try
{
//create a new player
player = Manager.createPlayer(file.toURL());
player.addControllerListener(this);//add listener to my player
player.start();
}

catch(Exception e)
{
System.err.println("Error creating player, possible missing file");
}

The code works fine an plays the audio file with no problem, its only when my computer is doing other things that the player goes to pot. Should I be running the player in a thread? If so how do I do that, I have no experience with threads. Please help.

Thanks
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top