Java Reference
In-Depth Information
mediaPlayer.currentTimeProperty().getValue().toMillis());
pauseMessage.setOpacity(.90);
});
16-4. Marking a Position in a Video
Problem
You want to provide closed caption text while playing a video in the media player.
Solution
Begin by applying the solution in Recipe 16-3. By obtaining the marked durations (in
milliseconds) from the previous recipe, you will create media marker events at points
into the video. With each media marker you will associate text that will be displayed as
closed captions. When a marker comes to pass, the text will be shown in the upper-
right side.
The following code snippet demonstrates media marker events being handled in the
onDragDropped event property of the Scene object:
... // inside the start() method
final VBox messageArea = createClosedCaptionArea(scene);
root.getChildren().add(messageArea);
// Dropping over surface
scene.setOnDragDropped((DragEvent event) -> {
Dragboard db = event.getDragboard();
boolean success = false;
URI resourceUrlOrFile = null;
// dragged from web browser address line?
if (db.hasContent(DataFormat.URL)) {
try {
resourceUrlOrFile = new
Search WWH ::




Custom Search