JMF Solutions

Using JMF in Swing

How to use JMF with JFC/Swing components. JFC/Swing components are light weight components and JMF by default uses heavy weight components. Heavy weight components are used to JMF's advantage as they permit using native rendering methods for higher frame rate video.

JMF 2.0 comes with several different video renderers. Although the default video renderer uses heavy weight components, it is possible to force a player to render using light weight components. This solution is implementation dependent since it may not work with all players and all implementations of JMF 2.0.

The JMF 2.0 Manager API provides a new method setHint that allows programmers to request certain behaviour during player creation. One such hint is Manager.LIGHTWEIGHT_RENDERER. Before creating a player, set the LIGHTWEIGHT_RENDERER hint to true using the setHint method as so:

  Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));

This internally requests the PlugInManager to only allow light weight renderers. Any player created from now on will use the light weight renderer that gives you a light weight visual component. 

Please note that this is not a JComponent. Not all light weight components are JComponents. It will still work well with overlapping Swing components, provided that double-buffering is turned on in the parent container. For more information on double-buffering, please refer to the JFC documentation.

The sample program "MDIApp" allows you to open JMF players and place them in JInternalFrames inside a JFrame.
Platform: JDK 1.1.6 or later
JMF API: 2.0 or later
Implementation: AJ, WPP, SPP *
Other software requirements: Swing 1.1

* AJ = All Java, WPP = Windows Performance Pack, SPP = Solaris Performance Pack
Related Classes
How to run this sample
  1. Download and compile

  2.     javac
  3. Run MDIApp

  4.     java MDIApp
    Note: If you are using Java 1.1, then make sure that you have Swing 1.1.x in your CLASSPATH.
  5. Select File->Open and select your favourite movie.
Source Code
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
VTS OnDemand RHS Banner

Duke's Choice RHS Banner

JavaOne 2014 Replay banner