22.6 Playing Video with Media
, MediaPlayer
and MediaViewer
Many of today’s most popular apps are multimedia intensive. JavaFX provides audio and video multimedia capabilities via the classes of package javafx.scene.media
:
-
For simple audio playback you can use class
AudioClip
. -
For audio playback with more playback controls and for video playback you can use classes
Media
,MediaPlayer
andMediaView
.
In this section, you’ll build a basic video player. We’ll explain classes Media
, MediaPlayer
and MediaView
as we encounter them in the project’s controller class (Section 22.6.2). The video used in this example is from NASA’s multimedia library3 and was downloaded from
Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.