aspose file tools*
The moose likes Game Development and the fly likes Play JMF Video (uses JFrame) Over Graphics During Game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Play JMF Video (uses JFrame) Over Graphics During Game" Watch "Play JMF Video (uses JFrame) Over Graphics During Game" New topic
Author

Play JMF Video (uses JFrame) Over Graphics During Game

Ike Gentz
Greenhorn

Joined: Jan 01, 2013
Posts: 15
Hi, I am currently building a Sonic game and the main game itself is mostly done. I run it all through a Graphics2D object and it all works fine. However, I realized that I wanted to add in video capabilities for certain screens and cutscenes, because it is much easier to show one video than storing a ton of animations in memory. Anyways, I have installed and got a video player working through JMF (Java Media Framework). When I run it by itself, I simply create a new JFrame and add the video player to it, which works great. However, during my game, since it is constantly updating the Graphics2D object and repainting, it always paints over the video when I run it. I would like to know how to add the video player directly to my graphics object (similar to how I use drawImage() ) for drawing animations and things, so that the video plays in the graphics object instead of under it, and can be treated similarly to the rest of my graphics on the screen.

Here is teh VideoPlayer class that I have taken from JMF and tweaked for my needs...



Also, here is the class which creates the main loop for the game...



And finally, here is the ScreenManager class which is referenced from the Core class.



//a lot of the code in these core classes were taken from a tutorial on TheNewboston.

So anyways, my game runs fine, I have graphcis, music, the works all in it and it is playable. I just need a way to play videos during the game w/o them being painted over by the Graphics object which is drawing all the other stuff. Thanks
Ike Gentz
Greenhorn

Joined: Jan 01, 2013
Posts: 15
Also I just wanted to note that if it is not possible to add the video / the JFrame containing the video to the Grahics object, is there a way to simply display the JFrame OVER the graphics? I already set it to "alwaysOnTop" but I believe this only applies to other SWING components and that is why it does not work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Play JMF Video (uses JFrame) Over Graphics During Game