Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Java Media Framework basics

Eric A. Olson (zpalffy@yahoo.com), Software Developer, Independent
Eric Olson is a software developer at Retek Inc. He has four years of experience with the Java platform, and is experienced with many different Java-based technologies, including JMF, Jini, Jiro, JSP, servlets, and EJBs. Eric graduated from the University of St. Thomas in St. Paul, MN, with a degree in Computer Science. He has worked for IBM on the SanFrancisco Project and the WebSphere Business Components initiative. He has also worked for Imation Corp. on storage appliances. He currently is developing Web-based software solutions for the retail industry. In his spare time, Eric collaborates with Paul Monday on Stereo Beacon -- a distributed peer-to-peer media player based on JMF.

Summary:  The Java Media Framework (JMF) is an exciting and versatile API that allows Java developers to process media in many different ways. This tutorial provides an overview of some of the major features of JMF, mainly through the use of working examples. Upon completion of this tutorial, you will understand the major players in the JMF architecture. You also will have worked directly with JMF, using live examples and source code that may be extended for more specific purposes.

Date:  07 May 2002
Level:  Introductory PDF:  A4 and Letter (164 KB | 27 pages)Get Adobe® Reader®

Activity:  89330 views
Comments:  

About this tutorial

What is this tutorial about?

The Java Media Framework (JMF) is an exciting and versatile API that allows Java developers to process media in many different ways. This tutorial provides an overview of some of the major features of JMF, mainly through the use of working examples. Upon completion of this tutorial, you will understand the major players in the JMF architecture. You also will have worked directly with JMF, using live examples and source code that may be extended for more specific purposes.

Topics covered in this tutorial are as follows:

  • Tips for downloading and installing JMF
  • Major JMF classes and their uses in the JMF architecture
  • Playing local media files
  • Presenting a graphical user interface (GUI) for media access and manipulation
  • Broadcasting media over a network
  • Receiving broadcast media over a network

Almost any type of media manipulation or processing is possible through JMF. A comprehensive discussion of all the features JMF has to offer is well beyond the scope of this tutorial. Instead, we'll use three simplified media applications to learn about the framework's building blocks. In this way, the tutorial will prepare you for future study and the implementation of more specific applications.


Should I take this tutorial?

This tutorial will walk you through the basics of working with JMF. To accomplish this, we'll create three separate working example applications. Each of these examples will build upon the previous examples, displaying different aspects of JMF's functionality.

The examples in this tutorial assume that you have used and are already familiar with the Java programming language. In addition to the core Java and JMF classes, we will be working with some of the Java AWT and Swing classes (for presenting a GUI), as well as some Java networking classes (for transmitting media over a network). Some familiarity with both the GUI and networking classes will help you more quickly understand the discussion and examples here, but are not prerequisites of this tutorial.

The example applications we'll work with are as follows:

  • A simple audio media player (the JMF HelloWorld application): This command-line-driven media player lets you play most audio types by simply specifying the media file name on the command line. The audio media player demo showcases mainly JMF-specific classes.

  • A GUI-driven media player: We'll use built-in JMF interface components to build the GUI, so little GUI programming experience will be necessary for this exercise. The media viewer demo uses some of the Java AWT and Swing classes to present GUI components to the user.

  • A media broadcasting application: This application allows a local media file to be transmitted over a network. The application is flexible enough to transmit media only to a specified network node, or to broadcast it to all the nodes within a subnet. This demo uses some of the Java networking APIs to allow media transmission over a network.

As part of the third exercise, we'll modify the GUI-enabled media player to let it receive and play broadcast media.

See Resources for a listing of articles, tutorials, and other references that will help you learn more about the topics covered in this tutorial.


Installation requirements

To run the examples in this tutorial, you need the following tools and components:

  • The Java 2 platform, Standard Edition, to compile and run the demo applications
  • The Java Media Framework, version 2.1.1a or above
  • A properly installed and configured sound card
  • One or more test machines
  • The demo source files in mediaplayer.jar (see Download).

The final demo application shows how JMF can be used over a network. If necessary, the demo can be run on a single machine using the machine as both the transmitter and receiver. To see the full power of using JMF over a network, however, you will need at least two machines that are reachable on the same network.

See Resources to download the Java 2 platform, complete source files, and other tools essential for the completion of this tutorial.


Downloading the installer

The first step in installing the JMF on your machine is to download the installer through the JMF home page, which also contains links to the JMF source code and the API documentation. See Resources for a link to download JMF.

Currently, JMF has versions for Windows, Solaris, Linux, and a pure-Java version that works on any machine with a JVM. To increase performance, you should download the version that is specific to your OS. Any code that is written and compiled with an OS-specific version of JMF is portable across other OSs. For example, if you download the Solaris version of JMF and compile a number of classes, those same classes can be used on a Linux machine without any problems.

Alternatively, you may choose to download the pure-Java, or "cross-platform," version of JMF. This version doesn't employ any OS-specific libraries. The cross-platform version is a good choice if your OS doesn't have its own version of JMF installed or if you don't know what OS the target machine will be running.


Installing JMF

After you've downloaded the JMF installer to your desktop, double-click the installer icon.

Most installers have an option to install native libraries in a system directory; for example, the Windows installer will present an option to "Move DLLs to Windows/System directory." For best results, choose this option, because it ensures the OS-specific libraries will be installed correctly.

You should also choose the option to update the system CLASSPATH and PATH variables during installation. If this option is turned off, remember to include the JMF jar files in the classpath when you compile or run any of the examples in this tutorial.

1 of 9 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=131849
TutorialTitle=Java Media Framework basics
publish-date=05072002
author1-email=zpalffy@yahoo.com
author1-email-cc=jaloi@us.ibm.com