How to Create a Movie Player (Step 1: Setting Up and Testing JMF)

This is the first of a 3 part series of blog entries in which I intend to show you, as exactly as possible, how to create the movie player shown in yesterday's blog entry. At the end of this series, you should have something that looks a lot like the movie player shown in yesterday's blog entry.

The three part series will consist of the following:

So, this is part 1, the most complex part, in which we set up Java Media Framework API (JMF). Everything I know about JMF I learned from blogs and discussion threads, because I trust bloggers more than technical writers. (And I am a technical writer, so go figure.) But, seriously, bloggers tend to find the pain points of a product, while the official documentation tends to describe the best-case scenario, with some low-threshold troubleshooting tips near the end. I'm adding this disclaimer up front, because the procedure that follows is my own ad-hoc JMF setup procedure, and hasn't been tried and tested, and has worked for me only on Windows (although the same procedure should work on other operating systems, with the variations specified below).

But first, what is JMF? Here is the definition according to the website: "The Java Media Framework API (JMF) enables audio, video and other time-based media to be added to applications and applets built on Java technology. This optional package, which can capture, playback, stream, and transcode multiple media formats, extends the Java 2 Platform, Standard Edition (J2SE) for multimedia developers by providing a powerful toolkit to develop scalable, cross-platform technology."

Here's how I personally recommend getting JMF up and running:

  1. Click this link. You now find yourself in the JMF Diagnostics Applet. It tells you whether you have JMF set up or not. At the start of this procedure, I'm assuming you have nothing set up. Here is what I see in the text area in the JMF Diagnostics Applet:

    JMF Diagnostics:
    
    Java 1.1 compliant browser.....Maybe
    JMF classes.....Not Found

    Later we will go this JMF Diagnostics Applet again, and we will notice that the message we see here is different.

  2. Next, go to a command prompt and type the following:

    java JMStudio

    You should now see the following:

    Exception in thread "main" java.lang.NoClassDefFoundError: JMStudio

    This tells you that JMF's most important tool, JMStudio, is not available. It will be available after you install JMF. Let's do that and come back to the command prompt afterwards.

  3. Click here to go to the JMF download page. Click the Download button on that page. Click the Accept button. Next, select the JMF download applicable to your platform. (I don't know what the Java all-platform download is for, but somehow I haven't been able to download it thus far.)

  4. At the end of the wizard that installs JMF, you will be prompted to restart your computer. Do so. Then, go back to the JMF Diagnostics Applet. Depending on your operating system, you should now see this in the text area:

    JMF Version... 2.1.1e
    
    Win32 Build
    Native Libraries Found

  5. Next, start up the JMStudio application, which should now start up, because it is part of your JMF installation and because the right environment variables have been set by the installer. So type this in the command prompt:

    java JMStudio

    Now JMStudio starts up. Go to File | Open File. Browse to a movie (or music). Depending on the type of file you want to view, possibly you will now see a JMStudio Error dialog with this message:

    Controller Error: 
    Failed to realize: input media not supported: XVID video,
    mpgelayer3 audio

    Now here is an important rule to all of this stuff: If something does not play in JMStudio, it will not play in your own application either.

    So, we need to extend JMF. Let's do that in the next step.

  6. Click here to get to the Fobs download page. What is Fobs and why do you need it? This is what the Fobs website says about itself: "FOBS (Ffmpeg OBjectS) is a set of object oriented APIs to deal with media. It relies on the ffmpeg library, but provides developers with a much simpler programming interface."

    So, download Fobs. I use the Windows ZIP file. After you have unzipped it, double-click runjmstudio.bat. Now JMStudio starts up, with the Fobs JAR files registered. Choose File | Open File again and browse to your file. The movie should start. And the command prompt should now show you this:

    Fobs4JMF - Native shared library found
    7283.99First Position: 0, 41 Duration: 7283992
    Frame Rate: 23.976
    Opening Thread[JMF thread: com.sun.media.PlaybackEngine@111a3ac[ com.sun.media.P
    laybackEngine@111a3ac ] ( configureThread),9,system]
    Fobs Java2DRenderer: setInputFormat
    Fobs Java2DRenderer: setInputFormat
    Fobs Java2DRenderer: start

  7. Meanwhile, your movie is now playing in JMStudio. At the bottom of JMStudio, you see a slider for increasing/decreasing the volume. On the right side of the slider, in the far right corner, you see two buttons, one for toggling the sound on/off and another for calling up information on JMStudio. Click that button. In "Media Properties", click the "Plug-in Settings" tab. Then click the "Plugin Viewer" button. The Plugin Viewer dialog appears, showing you a diagram that should show you that both the video and audio are functioning. This is good news.

  8. Now type the following in the command prompt:

    java JMFRegistry

    You now end up in the JMF Registry Editor. (You could also get here by choosing File | Preferences in JMStudio.) Now look in the very useful Configuration of Fobs4JMF document. Specifically, look in step 5 of the "Manual Configuration" section. Check that everything has been registered correctly, which happened in the previous step, when you clicked the BAT file (or whatever file relevant to your operating system). For example, look in Plugins | Codec and check that the three Fobs Codecs have been added to the end of the list. If something has not been added automatically for some reason, do so manually, as described in step 5 of the "Manual Instructions" section.

As far as I can tell, you have now completed the set up of JMF, and extended it with Fobs. You need Fobs for a lot of file types that are not covered by JMF by default. Without Fobs, I have not been able to watch a single movie in JMStudio (and, therefore, not in my own application either). There's also an MP3 Plugin for JMF (here), which only works under Windows.

Next, we are going to create a simple Swing application which will test our JMF set up. Once we have that, we are ready for the next stage (part 2 of this series), where we port our Swing application to a NetBeans module which we integrate in the IDE. Here are the steps for creating our simple swing application:

  1. Start up NetBeans IDE 5.5 or a 6.0 build. (Or start up 5.0, but why are you still using 5.0 anyway?)

  2. Create a new Java application called "MoviePlayer".

  3. Create a new JPanel called "MediaPanel". Rewrite the default constructor as follows:

    public MediaPanel( URL mediaURL ) {
    
        initComponents();
    
        setLayout( new BorderLayout() ); // use a BorderLayout
    
        try {
    
            // Create a JMF player to play the media specified in the URL:
            Player mediaPlayer = Manager.createRealizedPlayer( new MediaLocator(mediaURL) );
    
            // Get the components for the video and the playback controls:
            Component video = mediaPlayer.getVisualComponent();
            Component controls = mediaPlayer.getControlPanelComponent();
    
            if ( video != null )
                add( video, BorderLayout.CENTER ); // add video component
    
            if ( controls != null )
                add( controls, BorderLayout.SOUTH ); // add controls
    
            // Start the JMF player:
            mediaPlayer.start(); // start playing the media clip
    
        } // end try
    
        catch ( NoPlayerException noPlayerException ) {
            System.err.println( "No media player found" );
        } // end catch
    
        catch (CannotRealizeException ex) {
                ex.printStackTrace();
        } // end catch
    
        catch ( IOException iOException ) {
            System.err.println( "Error reading from the source" );
        } // end catch
    
    } // end MediaPanel constructor

    Notice that the constructor receives a URL. This URL is the URL to your movie. (We will use the IDE-generated Main.java class, in step 5 below, which will pass the URL, after the user has selected a movie via a file chooser.) Next, we create a JMF player object. We also create two components, a visual component and a controller component. The controller is the sliding bar at the bottom of a JMF application, for controlling the volume, as well as the additional buttons for toggling the sound, and so on. In other words, the controller is something you get for free when you use JMF. Finally, after adding the visual component and controller component, we start the player. And that's it! JMF in a nutshell.

  4. However, assuming that you want to wrap the JARs with the application (instead of using the installed JMF libraries that, thanks to the installer, must be on your classpath at this stage), we haven't put the JMF JAR on the application's classpath. Let's do that now. Right-click the Libraries node, choose "Add JAR/Folder" and browse to the two JARs provided by the Fobs download. In other words, you should have fobs4jmf.jar and jmf.jar added to the Libraries node. Also include the native library there. For example, create a Java library and put fobs4jmf.dll in its default package. That's all I need to do and it works. (You could also add the native library to the PATH environment variable, or its equivalent on your operating system.) Now the red underlines, if any, in the MediaPanel code should disappear.

  5. Next, we use the Main.java class that the IDE generated for us to pass the movie's URL to the MediaPanel. Here's the constructor:

    public static void main( String args[] ) {
    
        // Create a File Chooser:
        JFileChooser fileChooser = new JFileChooser();
    
        // Show Open File dialog:
        int result = fileChooser.showOpenDialog( null );
    
        if ( result == JFileChooser.APPROVE_OPTION ) // User chose a file
        {
            URL mediaURL = null;
    
            try {
                // Get the file as URL:
                mediaURL = fileChooser.getSelectedFile().toURI.toURL();
            } // end try
    
            catch ( MalformedURLException malformedURLException ) {
                System.err.println( "Could not create URL for the file" );
            } // end catch
    
            if ( mediaURL != null ) // Only display if there is a valid URL
            {
                JFrame mediaTest = new JFrame( "Movie Player" );
                mediaTest.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
                MediaPanel mediaPanel = new MediaPanel( mediaURL );
                mediaTest.add( mediaPanel );
                mediaTest.setSize( 300, 300 );
                mediaTest.setVisible( true );
            } // end inner if
    
        } // end outer if
    
    } // end main

    So here we have a simple file chooser. We convert the chosen file to a URL and send it to the MediaPanel. That's all.

  6. Now run the application. The file chooser appears. Select a movie. You should see this, after a moment, in the Output window:

    init:
    deps-jar:
    compile:
    run:
    Fobs4JMF - Native shared library found
    4820First Position: 0, 40 Duration: 4820000
    Frame Rate: 25
    Opening Thread[JMF thread: com.sun.media.PlaybackEngine@eb7859[ com.sun.media.PlaybackEngine@eb7859 ] ( configureThread),9,system]
    Fobs Java2DRenderer: setInputFormat
    Fobs Java2DRenderer: setInputFormat
    Fobs Java2DRenderer: start
    BUILD SUCCESSFUL (total time: 45 seconds)

    And now your movie starts up. Hurray, you've successfully set up and tested JMF.

I hope the above steps all make sense and, if they don't, especially for non-Windows operating systems, please leave a note at the end of this blog entry. Plus, note that many/all of the instructions could be wrong, since they're all based on my personal flounderings in JMF land, during the past few days.

In the next entry in this 3 part series, we will port our Swing application to a NetBeans module, which we will install in the IDE. This will give us a movie player inside our IDE.

Comments:

You know, if you just want a simple player, the ion guys (https://ion.dev.java.net/) have a basic player that passes through to the native player on the platform (WMP/QT/Mplayer). It is way way better than grappling with JMF.

Posted by Robert Cooper on January 21, 2007 at 05:53 AM PST #

Wow, that sounds complicated. Isn't there any easier way packing all this up so that it is more easy to use? Just thought how this may be really if you could download all this via an update center ;-)

Posted by Sven Reimers on January 21, 2007 at 06:51 AM PST #

Hi Robert, thanks for that tip, will definitely have a look at that site. Sven, yes, it's pretty complicated, especially for the end user who, in this scenario, needs to set up JMF (plus additional codecs), before being able to use the movie player! I agree it would be better to pack everything up and bundle it together somehow, but don't know how to do that yet. Getting it all from an update center would be ideal.

Posted by Geertjan on January 21, 2007 at 07:18 PM PST #

Just for guys that want to copy the code, there is a tiny mistake in one line : mediaURL = fileChooser.getSelectedFile().toURI().toURL(); Only 2 missing parenthesis ;-) ps: if anyone manage to switch the player from Java2D renderer to JoGL renderer, I will appreciate the trick. Even if I put com.omnvidea.media.renderer.video.OpenGLRenderer at the top of the render JMF registry, it doesn't work. ps2: it will be also good to compress/clean the DLL provided by Fobs as it's huge (13mb) and therefore it takes time to download using JNLP installation.

Posted by conan_fr on January 24, 2007 at 06:08 PM PST #

Hi conan_fr. Maybe you should just delete the Java@D renderer. That way, you will force JMF to use an alternative, in your case JoGL. Let me know if that works. Thanks for the code correction. By the way, are you using this code with the JoGL renderer? If so, what's the result of doing that? Curious to know.

Posted by Geertjan on January 24, 2007 at 07:13 PM PST #

JMF? It's a dead technology. Sun has not developed it for years. Why build your applications on a dead technology. As matter of fact, lack of media framework will prevent Java going on rich client. Swing is getting a lot better. Wish that Java developers will have a better Media framework to work with, something like WPF.

Posted by guest on January 25, 2007 at 03:58 AM PST #

For "dead" technology, it is really pretty powerful, 192.85.47.2!

Posted by Geertjan on January 25, 2007 at 05:55 AM PST #

Geertjan, I managed to do it using another way. First there is an example of setRenderer() used here : http://java.sun.com/products/java-media/jmf/2.1.1/solutions/DemoJMFJ3D.html (this one is using JMF with Java3D != JoGL) Then in the source code package of fobs4jmf, you can see some examples of code using a video mapped cube with JoGL (those sources are backupped and renamed inside the package) So my idea was to mix video as a 3D texture (which is great if you put it fullscreen, then with OpenGL you can have bilinear filtering that will improve the rendering quality using hardware. You have now the same in image viewers like GLiv or ...) and do some effects with multiples video ... Like those pretty examples in Apple Leopard : http://www.apple.com/macosx/leopard/coreanimation.html Or as it was done in the good example with Java2D over JoGL : http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html I pretty sure that we can now do it easily with a mixure of Java2D, JoGL and JMF. And also Netbeans as a wonderful IDE ;-)

Posted by CONAN_Fr on January 26, 2007 at 01:58 AM PST #

Hi, I have followed the steps recommended to set up JMF and downloaded Fobs to use runjmstudio.bat to startup JMStudio. However, when I tried to open a video file or an audio file(in wma format), the JMStudio application terminates immediately and an error log is obtianed: # An unexpected error has been detected by HotSpot Virtual Machine: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6b338d3d, pid=3456, tid=620 # # Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode, sharing) # Problematic frame: # C [fobs4jmf.dll+0x3b8d3d] # Is it possible that I have not fully extended JMF with Fobs. If so, what can I do to get my JMStudio application up and running?

Posted by zhenrong on February 21, 2007 at 04:00 PM PST #

Hi All and Geertjan. In your blobs there are lot of information for new people on JMF, but there are no discussion regarding the "java media player on applet" if my applet want show the movies like ".wmv" to a client browser. how we manage configuration on client side mean how we manage the FOBS dll, packages etc. etc. waiting for reply..... Thanks in advance Here some information require

Posted by FAROOQ on February 26, 2007 at 05:45 PM PST #

Hi, I am having the same trouble that CONAN_Fr is. Does anyone know what the problem is?

Posted by Jason on March 11, 2007 at 06:53 AM PDT #

Hi, i have the same problem. I canĀ“t play wmv files. Does anyone have the same trouble? waiting for replies. Ths.

Posted by Mihte on May 23, 2007 at 07:45 AM PDT #

Hi, I actually followed these instructions and it all works fine until I try to register fobs4jmf jar files using jmstudio. In fact, it works when i open runjmstudio.bat. The movie is played fine, jars are correctly registered ... but when I close it and I open jmstudio again it fails and I get the error : "Failed to realize: input media not supported: XVID video, mpgelayer3 audio" plus codecs, demultiplexer ... are not registered anymore. When I try to add them manually I get the error : "Could not add Item". It only works for the package add but neither for the demultiplexer nore the codecs. Hope someone51 would be able to help me solving my problem. Thx a lot ...

Posted by Alassane on June 30, 2007 at 09:21 AM PDT #

Hi Alassane, don't know the specific answer to your question, but will be blogging about JMF again soon, so watch this space.

Posted by Geertjan on June 30, 2007 at 09:24 AM PDT #

Thx for answering anyway. I'll post the solution soon as I find it.

Posted by Alassane on June 30, 2007 at 09:56 AM PDT #

Just in case ... when i try to play a media file with my application, I get this error : "Fobs4JMF - Native shared library NOT found". Maybe it could help ...

Posted by Alassane on June 30, 2007 at 11:37 AM PDT #

Try putting that error in Google, that's what I would do anyway.

Posted by Geertjan on June 30, 2007 at 02:42 PM PDT #

Hi, Now my problem is partly solved. I can play mp3s with jmstudio but i still get an error when i try to open other formats. Ive also tried to to play an mp3 file with my application but it still fails and i still get the "Fobs4JMF - Native shared library NOT found" error despite its played by jmstudio. I really don't have NO idea of what i should do right now. Wonder if there is a modification of classpath i should do or something like that. I really need help on that. thx a lot.

Posted by Alassane on July 02, 2007 at 08:37 AM PDT #

I installed fobs4jmf and I am able to play mpeg-4 media files in JMStudio. But when I try to run the media using my application which is a knopflerfish bundle, I am getting the following error Media Ad Player Exception javax.media.NoPlayerException: Cannot find a Player for :file:C:/jurassic.mp4 How to configure the fobs4jmf plugin for Knopflerfish bundle?

Posted by Dinesh on July 13, 2007 at 07:31 PM PDT #

I also get the error: "Fobs4JMF - Native shared library NOT found". I discovered that the 'libFobs4JMF.jnilib' seems to get corrupt when you use it from two separate web sites that use this library. Only the first web site wins -- after that I have to shutdown the web browser and restart it to get the library to load and play a video from a separate site's applet.

Posted by Dan on July 26, 2007 at 09:06 AM PDT #

I followed the instructions and I tried to run the code but I had the following errors:

mediaTest.add( mediaPanel and
add( video, BorderLayout.CENTER );

Actually, I'm quite new in java language but please I need to complete using jmf for my project. If any one knows what's wrong please tell me. Thank you,,

Posted by Hend on August 31, 2007 at 11:14 AM PDT #

The solution to "Fobs4JMF - Native shared library NOT found" is that you need to set the path to Fobs as LD_LIBRARY_PATH in .bashrc, if you're on Linux.

Posted by Geertjan on November 06, 2007 at 02:11 PM PST #

Also see this blog entry:

http://blogs.sun.com/geertjan/date/20071107

Posted by Geertjan on November 06, 2007 at 05:08 PM PST #

When we tried fobs4jmf with standalone application it's working fine. But when we are tying to play the mp4 using fobs4jmf with jboss server we are not able create the player.

Please share your knowledge on the same.

Posted by gopikrishna on November 06, 2008 at 07:13 PM PST #

Hi, Geertjan,

I've been learning and following your guidance--thank you. However, when I get to this point in your lesson:
For example, create a Java library and put
fobs4jmf.dll in its default package.

I'm stuck. I've added a library, under Tools, and included fobs4jmf.dll, but it doesn't appear to be part of my project. I've also added a new project (Java Class Library), and only there do I find a <default package>, but that doesn't appear to work (i.e., the red lines are still in my proj).

I wonder where/how do I create a Java lib, as you've suggested, to include fobs4jmf.dll.

Thanks.

Posted by Gymus on January 24, 2009 at 12:06 AM PST #

Gymus, when I say "Java Library" I mean a project type of the type "Java Library", from the New Project dialog (under the File menu).

Posted by Geertjan on January 24, 2009 at 12:11 AM PST #

Thanks, Geertjan. I've done what you suggested (although it's called "Java Class Library" when I add it through File-New Project (NetBeans 6.5). So, now it looks as though I have two projects--the new one, which I called fobs4jmf, and MoviePlayer.

Now I see <default package> under the fobs4jmf Source Packages and Test Packages, but I haven't (yet) figured out how to get fobs4jmf.dll in there.

Posted by Gymus on January 24, 2009 at 12:53 AM PST #

Just copy and paste it, in your file system. No direct support for this inside NetBeans IDE.

Posted by Geertjan on January 24, 2009 at 12:57 AM PST #

PS: Or use the Favorites window to do so (Ctrl-3). That window present a view on your file system. Very handy.

Posted by Geertjan on January 24, 2009 at 12:58 AM PST #

OK, that's done. I see my Favorites pane, and I right clicked and selected Add to Favorites... I found the DLL, added it, and moved it above Home.

Not only am I "surprised" that there's nothing to save (File-Save isn't an option), but the red lines are still in MediaPanel. I've put up a couple pix to show my situation--they're at http://subjectsignups.com/files/.

Again, thank you.

Posted by Gymus on January 24, 2009 at 01:27 AM PST #

You need more than the DLL. You also need jmf.jar. Please, read each step in the instructions above again. Then, read it again. Then, again.

Posted by Geertjan on January 24, 2009 at 01:41 AM PST #

Thanks. I have re-read, and even recreated my project(s), but it doesn't work. I apologize.

This time, I put the MediaPanel under Source Packages-<default packages>; the previous time it went under movieplayer, with Main.java. My two .jar files are under MoviePlayer-Libraries, and also under fobs4jmf-Libraries.
http://subjectsignups.com/files/whole_win2.jpg
There presently seems to be a problem finding JFileChooser (see Output, in the .jpg above).

I appreciate your time. Have a great day.

Posted by Gymus on January 24, 2009 at 02:41 AM PST #

Success! The problem was, of course, my fault. I didn't pay good attention to the NetBeans error light bulbs, etc., and so I wasn't importing the correct classes. Ugh!

Thank you, very much, for your time. I did learn things from you. Now on to Step 2.

Posted by Gymus on January 24, 2009 at 05:11 AM PST #

Thank you Geertjan, that's sound god, I really I like it,but I tried i still have problem. I'm using netbeans 6.0 i managed to add those 2 files in library but I couldn't make next as you said "Also include the native library there. For example, create a Java library and put fobs4jmf.dll in its default package. That's all I need to do and it works. (You could also add the native library to the PATH environment variable, or its equivalent on your operating system.) Now the red underlines, if any, in the MediaPanel code should disappear. " pls elaborate it cleary

Posted by Emmanuel Kondela on February 08, 2009 at 01:48 PM PST #

Great writeup Geertjan.

My question concerns streaming media. Does JMF have the capability to buffer streaming video so at any point I could rewind (in a sense) the streamed video all the way back to the beginning of the first frame received (or the beginning of the buffer)?

Posted by Marc Hall on February 22, 2009 at 12:10 PM PST #

Hi everybody,can you give a hint how to save media data while playing it in a media player.I capture video from web camera and play it in a player, but can't save it i a file. Help me please.

Posted by Vardouhi on February 24, 2009 at 12:30 AM PST #

Hi everyone...

i'm really fed up with a bug.. i'm playing video file usinf jmf/fobs4jmf 4.1 on ubuntu 8.04 the problem i face is when i seek or skip using FramePositioningControl
... it skips alot of frames does not move to specified frame.. it works fine on windows...
heres output of a program i wrote

Fobs Java2DRenderer: stop
Resetting Thread[Loop thread: com.omnividea.media.parser.video.VideoTrack@1df5a8f,3,system]
Opening Thread[Loop thread: com.omnividea.media.parser.video.VideoTrack@1df5a8f,3,system]
599.067First Position: 0, 0 Duration: 599066
Frame Rate: 15
Setting position Thread[AWT-EventQueue-0,6,main]
New position request: 45.9214
Seeking pos: 45921 - Real: 44921000
mdb:466, lastbuf:0 skiping granule 0
mdb:466, lastbuf:0 skiping granule 1
mdb:478, lastbuf:397 skiping granule 0
Fobs Java2DRenderer: start
mdb:461, lastbuf:458 skiping granule 0
bits_left=189
bits_left=35
bits_left=-5
mdb:509, lastbuf:493 skiping granule 0
overread, skip -9 enddists: -3 -3
overread, skip -4 enddists: -2 -2
bits_left=178
mdb:474, lastbuf:461 skiping granule 0
overread, skip -6 enddists: -4 -4
mdb:503, lastbuf:486 skiping granule 0
bits_left=47

Please help

Posted by Arsalaan on February 27, 2009 at 04:38 PM PST #

Hi,
Thank you for this great guide, I have managed to set up and use JMF with fobs to play a variety of videos while inside my program in netbeans.

However, when I build my project, the jmf.jar and fobs.jar appear correctly in my /lib folder and my manifest points to them, but videos do not work when I run my jar.

What am I doing wrong?

Posted by Awoken on November 04, 2009 at 12:08 AM PST #

I tried to run the above program but it shows red bulb in initcomponent

Posted by preethi on December 15, 2009 at 09:40 PM PST #

Which class is used in jmf so that the selected not supported media files will be converted internally in to supported format files ?

Posted by swapnil on September 28, 2010 at 10:24 PM PDT #

hey folks I am trying to play a .h264 encoded video... using JMF. I managed to play the video but the audio is not there in the player...

what must be the problem..

any1 help plz.

Posted by tukaram on October 04, 2010 at 05:29 PM PDT #

Excelent post. Some days ago I was trying to configuring fobs4jmf with netbeans but I found a trouble. Fortunately I could solve it but I managed to do that. If you want, you can check my post about fobs4jmf and netbeans here: rolandopalermo[dot]blogspot[dot]com/2010/10/fobs4jmf-netbeans-windows-java[dot]html

I'm sure it will be useful.

Posted by guest on November 02, 2010 at 04:02 PM PDT #

hey i cant add a device in jmf registry.so i get a error in capturing video.could anyone please help me out?

Posted by guest on October 10, 2011 at 04:17 AM PDT #

I have a webcams and a usb camera (and even only 1 on some systems) jmf likes to popup a window asking you to "Select a Video Device" for your "Capture Source". Is there any way around this without user intervention? The issue is both webcams use the same vfw locator, I need to programmatically pick one etc without the popup window.
It happen when I use:

Vector devices = CaptureDeviceManager.getDeviceList(new VideoFormat("yuv"));
or
Vector devices = CaptureDeviceManager.getDeviceList(null);

Any idea's? I have something I am going to try if it works I'll post it here but wanted to get this question out there in case someone has the answer. Thanks in advance.

Posted by Gaditano on November 11, 2011 at 12:30 PM PST #

dear Geertjan Wielenga ,
i m having following msg in my out put box and video is playing but audio is not . so please help me out sir.

Fobs4JMF - Native shared library found
Audio codec unsupported!
5857.86First Position: 0, 0 Duration: 5857857
Frame Rate: 23.976
Opening Thread[JMF thread: com.sun.media.PlaybackEngine@6d8d73[ com.sun.media.PlaybackEngine@6d8d73 ] ( configureThread),9,system]
Fobs Java2DRenderer: setInputFormat
Fobs Java2DRenderer: setInputFormat
Fobs Java2DRenderer: start
Fobs Java2DRenderer: stop
Resetting Thread[Loop thread: com.omnividea.media.parser.video.VideoTrack@8b83e3,3,system]
Opening Thread[Loop thread: com.omnividea.media.parser.video.VideoTrack@8b83e3,3,system]
Audio codec unsupported!
Audio codec unsupported!
5857.86First Position: 0, 0 Duration: 5857857
Frame Rate: 23.976
Setting position Thread[AWT-EventQueue-0,6,main]
Audio codec unsupported!
New position request: 644.364
Seeking pos: 644364 - Real: 643364000
Fobs Java2DRenderer: start
Fobs Java2DRenderer: stop
Resetting Thread[Loop thread: com.omnividea.media.parser.video.VideoTrack@8b83e3,3,system]
Opening Thread[Loop thread: com.omnividea.media.parser.video.VideoTrack@8b83e3,3,system]
Audio codec unsupported!
5857.86First Position: 0, 0 Duration: 5857857
Frame Rate: 23.976
Setting position Thread[AWT-EventQueue-0,6,main]
Audio codec unsupported!
New position request: 2486.47
Seeking pos: 2486473 - Real: 2485473000
Fobs Java2DRenderer: start
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[h264 @ 63DACB08]brainfart cropping not supported, this could look slightly wrong ...
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[h264 @ 63DACB08]brainfart cropping not supported, this could look slightly wrong ...
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[h264 @ 63DACB08]brainfart cropping not supported, this could look slightly wrong ...
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[h264 @ 63DACB08]brainfart cropping not supported, this could look slightly wrong ...
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[h264 @ 63DACB08]brainfart cropping not supported, this could look slightly wrong ...
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[mov,mp4,m4a,3gp,3g2,mj2 @ 63D97D50]edit list not starting at 0, a/v desync might occur, patch welcome
[h264 @ 63DACB08]brainfart cropping not supported, this could look slightly wrong ...
BUILD SUCCESSFUL (total time: 25 seconds)

Posted by Gurpreet on November 17, 2011 at 03:20 AM PST #

after run the application choose the file then error
.............no media player found
pls help me ........in window 7 netbeans ide 6.9
my jmf is well run with fobs.....but after writing this code will not generate the player only show the file chooser then above problem find

Posted by guest on November 23, 2011 at 03:34 AM PST #

Thanks very much. This article was very helpful! Was going mad trying to get JMF to use other codecs. All good now!

Posted by Brian O Carroll on December 06, 2012 at 09:24 AM PST #

What if I want to loop a video? and play one video after another one has finished playing?

I know about EndOfMediaEvent.. But it doesn't play the next video..

Posted by Subodh on March 23, 2013 at 12:28 AM PDT #

after following the procedure its still showing controller error but some files are playing and some are not please show me the way.

Posted by guest on July 18, 2013 at 01:11 AM PDT #

HELLO everyone I write this for creating an audio player its not showing any error and running in netbeans IDE but audio file is not playing help me

package player;

**/**
*
* @author me
*/
import javax.media.*;
import javax.swing.JFrame;
import java.io.IOException;
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;

public class Plugin extends JFrame
{
private Player audioPlayer=null;
public Plugin(URL url) throws IOException,
NoPlayerException,
CannotRealizeException {
audioPlayer = Manager.createRealizedPlayer(url);
audioPlayer= Manager.createPlayer(url);
}
public Plugin(File file) throws IOException,
NoPlayerException,
CannotRealizeException {
this(file.toURI().toURL());

}
public void play() {
audioPlayer.start();
}
public void stop() {
audioPlayer.stop();
audioPlayer.close();
}
public static void main(String[] args){

try
{
File audioFile=new File(args[0]);

Plugin player=new Plugin(audioFile);
player.play();

} catch (IOException ioe) {

System.out.println("IOException");
} catch (NoPlayerException npe) {
System.out.println("NoPlayerException");
} catch (CannotRealizeException cre) {
System.out.println("IOexception");
}
catch (ArrayIndexOutOfBoundsException aiobe) {

}

}
}

Posted by Neha on July 18, 2013 at 02:03 AM PDT #

hello, I have created a media player now I want to run it on other systems without having to install jmf on other systems.Please help me I am fed up of googling.No results where found.

Posted by Neha on July 29, 2013 at 09:12 AM PDT #

Could anybody give an advise how to make aac player with JMF? I am asking because I couldn't find any information about it, I am just trying simple player which could play online aac streaming from Internet. Thanks in advance.

Posted by hospel on July 30, 2013 at 05:19 AM PDT #

Hi,
I am new to JMF.
It seems, the steps you mentioned here are for windows. But how to do it on ubuntu.
can you please help me. Thank you

Posted by tirupathi on August 26, 2013 at 03:50 AM PDT #

hi
i followed the above steps but no media player found exception is getting thrown.How should i rectify that?

Posted by guest on October 15, 2013 at 02:43 AM PDT #

thankuuuuu...soo much..it helped me lot..

Posted by guest on November 10, 2013 at 06:09 AM PST #

I just wanna know is there any way of playing the video using the bytes array. I have a encrypted video and I have decrypted it. Now I have decrypted video in the form of bytes. Is there any way that I can play the same using bytes as I dont want to create the decrypted file.

Posted by guest on March 05, 2014 at 09:33 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today