Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

mp3 playing

  Asked By: Thelma    Date: Aug 31    Category: Java    Views: 515
  

How can I write java programs to play mp3 files? If any body know please let me know that

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Wilfred Young     Answered On: Aug 31

In many ways but one of them is this:


import javax.media.*;
import java.io.*;

public class PlayMP3Thread
extends Thread
{

private URL url;

public PlayMP3Thread(File mp3)
{
this.url = mp3.toURL();
}

public void run()
{
try
{
MediaLocator ml = new MediaLocator(url);
Player player = Manager.createPlayer(ml);
player.addControllerListener(
new ControllerListener()
{
public void controllerUpdate(ControllerEvent event)
{
if (event instanceof EndOfMediaEvent)
{
player.stop();
player.close();
}
}
}
);
player.realize();
player.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}

}

 
Answer #2    Answered By: William Bouchard     Answered On: Aug 31

Where can I get the javax.media package

 
Answer #3    Answered By: Jean Bell     Answered On: Aug 31

I guess it's in JMF. Download it from:

java.sun.com/.../download.html

 
Didn't find what you were looking for? Find more on mp3 playing Or get search suggestion and latest updates.




Tagged: