Java Media Framework
Get some popcorn—Java can play movies! To do this, though,
we’ll need one of Java’s standard extension APIs, the Java Media Framework
(JMF). The JMF defines a set of interfaces and classes in the javax.media and
javax.media.protocol
packages. You can download the latest JMF from Oracle’s website. To use the JMF, add
jmf.jar to your classpath. Or,
depending on what version of the JMF you download, a friendly installation
program may do this for you.
We’ll only scratch the surface of JMF here, by working with an
important interface called Player. Specific
implementations of Player deal with
different media “container” types, such as Apple QuickTime
(.mov) and Windows Video (.avi).
For a full list of supported media types and codecs, consult the latest
JMF documentation. There are also players for audio types, including MP3.
Players are handed out by a high-level
class in the JMF called Manager. One way to
obtain a Player is to specify the URL
of a movie.
What about Windows media player format as well as MP3?
Playerplayer=Manager.createPlayer(url);
Because video files are so large and playing them requires
significant system resources, Players
have a multistep lifecycle from the time they’re created to the time they
actually play something. We’ll look at only one step,
realizing. In this step, the Player determines (by looking at the media file)
the system resources that it needs to play the media file.
player.realize();
The realize() method returns right away; ...