Subscribe

RSS Feed (xml)

Powered By

Place Your Ads Here

Play Mp3 Files In java



First of all You have to download Java Media Framework API to perform this example you can download it at Sun Microsystem website .
JMF
There after import the following packages in java desktop application
 mediaplayer
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
Take a Instance level variable player
and on jbutton click action performed
try
{
MediaLocator ml=new MediaLocator(file:///+”c:/ram.mp3”);
player=Manager.createPlayer(ml);
player.realize();
player.start();
}
catch(Exception esf)
{
System.out.println(""+esf);
}
for stopping it just access the instance level variable player and call its stop()
function.

You can download the full source code here

Source Code

1 comments:

Anonymous said...

great post i like this post
its really userfull for thanks mate