Articles Index
How to Create a Multimedia Player: Using Java Media
Lisa Stapleton, JavaSoft
One of the most interesting Java development efforts today is the JavaTM
Media Player, which is part of the Java Media Framework. It can play audio
and video files, handle synchronization of different multimedia, and can
help you use events to trigger the playing of different types of media. But
if you're designing Java-based multimedia content, how will you use it?
The Java Media Player is a way to handle what JavaSoft staff engineer David
Rivas calls self-describing content. (For instance, a container object
could be described by yet another object describing the kind of container.)
It can do playback, capture, and conferencing of multimedia. The
programmer provides information to obtain a media asset, and the media
asset provides the information necessary to render the object.
First, you create an instance of a player. Next, you make the controller
aware of the resources. Then, you "prefetch" those resources it's going to
use (sort of like starting a car up in neutral; the car is ready to go, but
hasn't started yet). "You essentially go from instance to realize to
prefetch to start," says Rivas.
Here's what the different parts of the Player API are and how they work
together:
- The central structure is the player. A player is a controller and a
clock. It knows where media data is; it knows what kind of data is there,
and how it's going to get that data. It also has something called a time
base, which is a replaceable base of time. You can ask what time it is;
you can't change the time, but you can, for instance, get the time base
from an audio clock. As an example, If you wanted to synchronize audio and
video, you might call getTimeBase to get the time base from the audio and
syncronize the video with the audio. Most important, you can use one
player to synchronize several other players, if you need to synchronize a
varitety of media.
- A controller manages resources. It's also a clock. To use it, you have
to put it in the
realize state, so that it can discover what
resources will be needed to play the specified multimedia. When realize
QuickTime, for example, the controller knows, for example, what it has to
do to play a QuickTime video.
- Next, you use prefetch to grab resources and do some housekeeping chores
such as filling up buffers, so that the player can start up as soon as the
order is given. After you've used prefetch, you're ready to start playing.
- Finally, you acquire a synchronization lock between a time base and a
clock. When the player is done playing, an event notification is thrown.
"So you kick a player, it does its work for a given state, and on
completion, it throws an event," says Rivas. This, in essence, is how to
use a media player.
Intel and SGI have been working on implementations of the Java Media
Framework. In addition, the JavaSoft team is working on the following
items for possible inclusion in a future version of the framework:
- Incomplete players, which are players without rendering components. They
would be used so that Java programs could "get their hands on the data" so
they could do things other than rendering.
- Handling high-bandwidth events, such as getting an event every frame.
- The track-description interface. This way, you could have different
tracks, for, say, audio, video, and foreign languages.
- The building of 100% Pure JavaTM players.
|
|