Sign in to follow this  

[java] How to close Frame window after it player video?(JMF)

Recommended Posts

Iam using Java media framework to play intro from my game. I've got one class(it extends Frame) which takes care about playing video and another class(which is in LWJGL OPenGl window)to start the game. I want to play video in and after it and I want to create class which start the game and close the Frame window. Please take a look on code. Class playing video
ublic class VideoPlayer extends Frame implements ControllerListener{
    private Player videoPlayer;
    public VideoPlayer() {
     addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent we) {
    public static void playVideo() {
        VideoPlayer prehravac = new VideoPlayer(); 
        prehravac.setLocation(0, 0);;
    public void play()  
        URL url;
        try {
            url = new URL("file:///f:\\");
            videoPlayer = Manager.createPlayer(url);
        } catch (Exception e) {

    public synchronized void controllerUpdate(ControllerEvent event) {
    if (event instanceof RealizeCompleteEvent) {
    	Component comp;
    	if ((comp = videoPlayer.getVisualComponent()) != null)
    		add ("Center", comp);
Main method of game(in LWJGL OpenGl Window
public static void main(String[] args)
		Window window = new Window(1024,768,true);
Probably this isnt best way to play video, but if you got better I will be pleased if you share it with me. Thank to every advice.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this