
368
|
Chapter 10, Audio
#72 Play a Sound with Java Media Framework
HACK
The downside to JavaSound is the small number of supported formats. Java-
Sound, at least out of the box, isn’t well suited to handle having random
sound formats thrown at it. That’s not a problem if you’re supplying your
own sounds for your application—just stick with AIFF or WAV. But it does
make JavaSound less than useful in a media browser or some other applica-
tion that is going to have to deal with random formats encountered on the
Net or the user’s local storage. Of course, that’s part of the idea of the
spi
sub-package: Sun provides the framework, and third parties make their for-
mats available to Java by implementing
spi interfaces.
H A C K
#72
Play a Sound with Java Media Framework Hack #72
Use the Java Media Framework for better performance and support for more
audio formats.
Java Media Framework (JMF) is Sun’s attempt to bring a broadly focused
multimedia framework to Java, supporting audio, video, and other time-
based media types. The idea is to provide Java desktop applications with
these features across operating systems. Like JavaSound, it’s meant to be
extended so that Sun or third parties could add support for new file formats
or codecs (the compression/decompression encoding schemes used inside
those files).
JMF offers another way to provide sound from an application. The advan-
tages of doing so are that JMF may ...