O'Reilly logo

JavaFX™ Developer’s Guide by Kim Topley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

19. Video and Audio

It has been possible for many years to play both audio and video in Java, but the application programming interfaces (APIs) that are provided to do this are complex. In JavaFX, it is almost trivial to embed a media player that will play some sound or a video clip into your application. The code shown in Listing 19-1 is all that it takes.

Listing 19-1 Media Playback with JavaFX

image

This code opens a short video hosted by Sun Microsystems and streams it onto your screen. As you can see, there are three key classes that cooperate to play the content of a video file:

MediaView is a node that renders video delivered by a MediaPlayer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required