3-3. Controlling Media Actions and Events

Problem

You want the media player to provide feedback in response to certain events. An example is displaying the text “Paused” on the screen when the media player’s paused event is triggered.

Solution

You can use many media event handler methods. Shown in Table 3-3 are all the possible media events that are raised to allow the developer to attach EventHandlers or Runnables.

images

images

The following code will present to the user a text “Paused” with “Duration” with a decimal of milliseconds which is overlaid on top ...

Get JavaFX 2.0: Introduction by Example 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.