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
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();
{
MediaLocator ml=new MediaLocator(file:///+”c:/ram.mp3”);
player=Manager.createPlayer(ml);
player.realize();
player.start();
}
catch(Exception esf)
{
System.out.println(""+esf);
}
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:
great post i like this post
its really userfull for thanks mate
Post a Comment