add movies in java

Is it possible to add movies (.mpeg) in java ?
[61 byte] By [edouard_g] at [2007-9-26 1:15:37]
# 1
Take a look at the Java Media Framework at: http://java.sun.com/products/java-media/jmf/index.htmlKurta
h230561 at 2007-6-29 0:42:17 > top of Java-index,Archived Forums,Java Programming...
# 2

Hi,

Here is the sample code for playing the movie.

public class MoviePlayer extends JFrame implements ControllerListener {

private Player player = null;

public static void main(String args[]) {

new MoviePlayer(args[0]);

}

public MoviePlayer(String movieFile) {

getContentPane().setLayout(new BorderLayout());

setSize(new Dimension(200, 200));

setVisible(true);

setTitle(movieFile);

loadMovie(movieFile);

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent we) {

player.stop();

player.deallocate();

System.exit(1);

}

});

}

private void loadMovie(String movieFile) {

try {

MediaLocator ml = new MediaLocator("file:" + movieFile);

player = Manager.createPlayer(ml);

player.addControllerListener(this);

player.start();

} catch (IOException ioe) {

ioe.printStackTrace();

} catch (NoPlayerException npe) {

npe.printStackTrace();

}

}

public synchronized void controllerUpdate(ControllerEvent ce) {

if (ce instanceof RealizeCompleteEvent) {

Component comp;

if ((comp = player.getVisualComponent()) != null)

getContentPane().add(comp, BorderLayout.CENTER);

if ((comp = player.getControlPanelComponent()) != null)

getContentPane().add(comp, BorderLayout.SOUTH);

validate();

}

}

}

I hope this will help you.

Thanks

Bakrudeen

Technical Support Engineer

Sun MicroSystems Inc, India

bakrudeen_indts at 2007-6-29 0:42:17 > top of Java-index,Archived Forums,Java Programming...
# 3

Hi,

Also you can refer this URL, which gives the excellent examples in Animation.

http://www.csse.monash.edu.au/courseware/cse3420/Lectures/Module8/module.html

I hope this will help you.

Thanks

Bakrudeen

Technical Support Engineer

Sun MicroSystems Inc, India

bakrudeen_indts at 2007-6-29 0:42:17 > top of Java-index,Archived Forums,Java Programming...