Java Reference
In-Depth Information
}
}
}
}
If you have
JavaFX
installed (see
The Evolution of Client-Side Java: Applets, Browser Wars,
Swing, JavaFX
), you can also play using the JavaFX media APIs:
/** Simple Audio Playing with JavaFX */
public
public class
class
AudioPlay
AudioPlay
{
public
public static
void
main
(
String
[]
args
) {
String clipName
=
"demo.mp3"
;
Media clip
=
new
static
void
new
Media
(
clipName
);
MediaPlayer mediaPlayer
=
new
new
MediaPlayer
(
clip
);
mediaPlayer
.
play
();
}
}
See Also
The JMFPlayer interface discussed in
Playing a Video File
plays sound files with a volume
control panel.
Playing a Video File
Problem
You want to display a video file within a Java program.
Solution
Use the Java Media Framework (JMF), a standard extension, or some third-party tool like
VLCJ, or use JavaFX.
Discussion
There are several media frameworks. Let's look first at the Java Media Framework (JMF).