Jump to content
  • Advertisement
Sign in to follow this  
Pracka

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

This topic is 4092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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) {
        dispose();
      }
    });
  
    }
    public static void playVideo() {
        VideoPlayer prehravac = new VideoPlayer(); 
        prehravac.setUndecorated(true);
        prehravac.show();
        prehravac.setExtendedState(MAXIMIZED_BOTH);
        prehravac.setLocation(0, 0);
        prehravac.play();
    }
    
    public void play()  
    {
        URL url;
        try {
            url = new URL("file:///f:\\1.mov");
            videoPlayer = Manager.createPlayer(url);
            videoPlayer.addControllerListener(this);
            videoPlayer.start();
        } catch (Exception e) {
            e.printStackTrace();
        }

     videoPlayer.addControllerListener(this);
    }
    public synchronized void controllerUpdate(ControllerEvent event) {
    if (event instanceof RealizeCompleteEvent) {
    	Component comp;
    	if ((comp = videoPlayer.getVisualComponent()) != null)
    		add ("Center", comp);
    	validate();
    }
    
    }
    
}
Main method of game(in LWJGL OpenGl Window
 
public static void main(String[] args)
	{
		VideoPlayer.playVideo();
		Window window = new Window(1024,768,true);
		okno.startGame();
    }
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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!