FoxNet

Hi, this is a small demo of my multi media project foxnet.



http://www.youtube.com/watch?v=ShRi-edrobo



Chris

what did you use to implement the video component?

Hi,



since there is JavaFX, there is the new media framework called Java Media Classes. You can simply extract these classes and use them in every java application. llama creates another solution to render videos. He uses Fobs4Java, but it is not very useful. (Massive A/V Sync problems) JMC1.2 uses the native codecs on your OS.



JMC1.2 will be released with JDK 7 in March next year. But you can use the JavaFX classes as well.

I'm using ImageGraphics to render a BufferedImage to an opengl texture. The performance is very good, although converting from BufferedImage to Texture needs some time…



If you have problems to extract these files, i'll upload the files…



Greetings,



Chris

Cool solution!

Would be great if you can share the files!



One thing I really missed!

+1…

this is something that is sorely missing from jme…

great work…

Hi,

thanks for the replies :slight_smile:



I think it would be the best to write a small tutorial about JMC. The rest (Drawing a BufferedImage to ImageGraphics)

is nothing special.



Because JMC is officially not part of the jdk, there is no documentation about these classes. I read a lot about JMC and finally i was able to create a simple MediaPlayer.


  1. At first you'll need the JMC files. The files consist of a jmc.jar file, which is used for every OS and a few dynamic library files. (On windows they are called *.dll)



    How can i get these files ?



    Download and install JavaFX SDK 1.2. After installation switch to the install folder and enter the directory "lib/desktop".



    Now you will see a lot of files. You need the jmc.jar file and the particular dll files (On mac and linux these files have another extension)



    The names of the files: jmc.dll, msvcp71.dll, msvcr71.dll



    Now you have everything to create a very fast media application. If your java application runs on Windows, the DirectShow codecs are used, on Mac the Core library and on Linux the GStreamer library… You do not have to care about compiling new codecs… I think the library will be released offcially in JDK 7!



    To use the classes in your java application you have to add the files to your buildpath.







    How can i create a simple media application ?



    It's easier than you think! The following code shows a simple implementation of a MediaPlayer:



public class MediaPlayer implements VideoRendererListener {

    private MediaProvider prov; //This is the most important class!

    private VideoRenderControl renderer; //It's a interface to control the rendering

    private Graphics2D g2;

    public MediaPlayer(File path, Graphics2D g2) {
        this.g2 = g2;
        prov = new MediaProvider(path.toURI());
       renderer = prov.getControl(VideoRenderControl.class);      
       renderer.addVideoRendererListener(this);      
    }

    @Override
    public void videoFrameUpdated(VideoRendererEvent arg0) {
   if(g2 != null)
      renderer.paintVideoFrame(g2, new Rectangle(0, renderer.getFrameSize().height,
                                                                                         getWidth(),  getHeight()));      
    }   
}



It could be happen that the MediaProvider says that the media file is invalid... Check your path! Empty spaces are restricted!

Now you can draw a video on a Graphics2D object! So you are ready! To access the track control or sound control, you can easily use prov.getControl(VideoRenderControl.class); You must replace VideoRenderControl in this case with the control type you need. The package com.sun.media.jmc.control contains all control interfaces...

Ok, i hope i could help to intergrate the new Java Media Classes! They are very powerful and should be used instead of JMF!!

Chris