Showing posts with label media. Show all posts
Showing posts with label media. Show all posts

Play Video Using Java

Monday, 10 March 2014



Playing Multimedia Files Using java ,So to do this job we need to download Java Media Framework (JMF)
here is the link

JMF

Note:-JMF does’nt supports all media or video formats ex; .mp4,.flv etc. for more information kindly visit Oracle website Thanks.

I have used a .mpg file in this project

Now Import the following packages

import java.awt.BorderLayout;
import java.awt.Component;
import java.net.URL;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFrame;

Now write down the following code on Jbutton action performed or Jframe Load as you wish


 

try

{
String mdurl=”file:///C:/Users/xyz/Desktop/phantom.mpg”;

URL url=new URL(mdurl);


Player player=Manager.createRealizedPlayer(url);

Component cmpt=player.getVisualComponent();  
    

Component ctrls=player.getControlPanelComponent();
    

cmpt.resize(600, 400);

this.add(cmpt,BorderLayout.CENTER);

ctrls.resize(600, 400);

this.add(ctrls,BorderLayout.SOUTH);

player.start();

this.resize(600, 400);

}

catch(Exception sdd)
{


System.out.println(sdd);


}

Simple Play Mp3 Files In Java

Thursday, 23 January 2014


First of all we need to download The Java Media Framework and install on our machine here is the link
Java Media Framework (JMF)  
now import the packages.

 

import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.Time;
Now Put that code on button click event
  try
  {               
   MediaLocator ml=new MediaLocator("File address here ex; c:/xyz.mp3”);
   player=Manager.createPlayer(ml);
   player.realize();
   player.start();             
   }
   catch(Exception yxz)
  {
   System.out.println(""+yxz);
   }

Paste Long Url