3-2. Playing Video


You want to view a video file complete with controls to play, pause, stop, and seek.


Create a video media player by utilizing the following classes:

  • javafx.scene.media.Media
  • javafx.scene.media.MediaPlayer
  • javafx.scene.media.MediaView

The following code is an implementation of a JavaFX basic video player:

public void start(final Stage primaryStage) {     primaryStage.setTitle("Chapter 3-2 Playing Video");     ... setting up the stage     // rounded rectangle with slightly transparent             Node applicationArea = createBackground(scene);     root.getChildren().add(applicationArea);     // allow the user to drag window on the desktop     attachMouseEvents(scene, primaryStage);     // allows the user ...

Get JavaFX 2.0: Introduction by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.