JMF Solutions

Custom Player GUI

How to create custom controls using the Player API. You have created an application that embeds a JMF player. You'd like the JMF GUI to look like the rest of your application. You don't want to use the default control panel provided by JMF either because it clashes with your GUI design or because it has more/less functionality than you would like to expose to the user.


You can create your own GUI components and use them to control the JMF player. The typical VCR type controls such as start, stop and rewind can be implemented through the Player interface.

The playback volume can be controlled through the GainControl object exposed through the Player.getControls() method. The GainControl.setLevel() takes a value between 0.0 and 1.0. This example draws a rectangle on the control panel and translates mouse clicks within the box to a value between 0.0 and 1.0 and accordingly sets the volume of the player.

The seeking function can be implemented by making calls to Player.setMediaTime(). The bounds of the media time are not 0 to 1 as in the case of the volume level. The upper limit is the duration of the player retrieved through Player.getDuration(). The lower limit is 0. So the position of the mouse in the media time rectangle in the GUI is translated to a nanosecond position between 0 and duration.
Platform: JDK 1.1.6 or later
JMF API: 1.0 or later
Implementation: AJ, WPP, SPP *

* AJ = All Java, WPP = Windows Performance Pack, SPP = Solaris Performance Pack
Related Classes
How to run this sample
  1. Download the file and set the CLASSPATH to point to it.
  2. Run jamp.Main with an optional URL in the command line

  3. For example,

    java jamp.Main file:/C:/test.mpg
Source Code
See Also
  • JMF 2.0 Programmer's Guide
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve
Duke's Choice Awards Nomination RHS

VTS OnDemand RHS Banner

Virtual Tech Summit Sept 2015 RHS banner

JavaOne 2014 Replay banner