-1

I am very very new at java (as in, I took one beginner course) so please don't get super technical when answering me.

Earlier today I learned how you can load an image in java and display it in an applet. I found a step-by-step youtube video that helped me do this.

Now I want to know how I can load an animation in java. Is that something that can be done? And can I get step-by-step instructions on how to do it? Basically, I already have a short .wmv file and I would like to display it when I run the program.

It also has audio that I would like to play along with it.

(i'm actually trying to make a video game with an animated character. java can be used to program games, so this should be doable, right? i don't care about making a game the "right" way or the way game developers usually do it, right now i just want to figure out the simple task of displaying an animation in java.)

thanks!

  • Well, I would say you should try to find tutorials for *this* subject as well. Also, I wouldn't bother with not doing things the "right" way. If you do, especially with a game, you will hate yourself later. Furthermore, this isn't a site meant for delivering code requests. Start to do this yourself and when you face a specific problem, ask it. – ChiefTwoPencils Jun 01 '14 at 05:59
  • I think you should use the word "video" instead of "animation" since your file is `.wmv` – Christian Tapia Jun 01 '14 at 06:00
  • Java can play GIF animation through the use of a `ImageIcon` and `JLabel` – MadProgrammer Jun 01 '14 at 06:29

2 Answers2

1

First of all, the wmv extension stands for video, and an animation is not a video. Its either a spritesheet, a gif image ect. In order to create a even simple animation, you must first learn some basic object oriented programming, become comfortable in creating and using classes, than you can advance to making your own class for taking care of sprites and cutting an image in a way that you can use it ect.

Example of a simple spriteshet: enter image description here This spritesheet is an simple image showing you one way to implement your 2d animation. You just have to cut the image parts from it using some rectangles. For 3d, you must use some other software and you must know that they use different kinds of extensions.

I wont dive into code, for the simple reason that I do not have time right now, but if you want further help, give my some contact like skype, facebook ect, I would love to help.

Lynx
  • 506
  • 2
  • 10
0

You could try the Java Media Framework javax.media.*. (caveat: rather old framework)

It appears you simply need to embed a media file such as video or audio into an applet. This can be achieved through a player embedded into an applet, similar to an individual frame or a .GIF file, that would be able to handle the .WMV extension.

Assuming awareness of the basic structure of a Java program, the main declaration to get an instance of a player is of the generic form, after:

player = Manager.createRealizedPlayer( mediaURL );

or

player = Manager.createPlayer( file.toURL() );

Good idea to go through the JMF documentation.