Spec-Zone .ru
спецификации, руководства, описания, API
|
public class MediaView extends Node
Node
that provides a view of Media
being played by a
MediaPlayer
.
The following code snippet provides a simple example of an
Application.start()
method which displays a video:
The foregoing code will display the video as:
public void start(Stage stage) {
// Create and set the Scene.
Scene scene = new Scene(new Group(), 540, 209);
stage.setScene(scene);
// Name and display the Stage.
stage.setTitle("Hello Media");
stage.show();
// Create the media source.
String source = getParameters().getRaw().get(0);
Media media = new Media(source);
// Create the player and set to play automatically.
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
// Create the view and add it to the Scene.
MediaView mediaView = new MediaView(mediaPlayer);
((Group) scene.getRoot()).getChildren().add(mediaView);
}
Type | Property and Description |
---|---|
DoubleProperty |
fitHeight
Determines the height of the bounding box within which the source media is
resized as necessary to fit.
|
DoubleProperty |
fitWidth
Determines the width of the bounding box within which the source media is
resized as necessary to fit.
|
ObjectProperty<MediaPlayer> |
mediaPlayer
The
mediaPlayer whose output will be handled by this view. |
ObjectProperty<EventHandler<MediaErrorEvent>> |
onError
Event handler to be invoked whenever an error occurs on this
MediaView . |
BooleanProperty |
preserveRatio
Whether to preserve the aspect ratio (width / height) of the media when
scaling it to fit the node.
|
BooleanProperty |
smooth
If set to
true a better quality filtering
algorithm will be used when scaling this video to fit within the
bounding box provided by fitWidth and fitHeight or
when transforming. |
ObjectProperty<Rectangle2D> |
viewport
Specifies a rectangular viewport into the media frame.
|
DoubleProperty |
x
Defines the current x coordinate of the
MediaView origin. |
DoubleProperty |
y
Defines the current y coordinate of the
MediaView origin. |
blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
Constructor and Description |
---|
MediaView()
Creates a
MediaView instance with no associated
MediaPlayer . |
MediaView(MediaPlayer mediaPlayer)
Creates a
MediaView instance associated with the specified
MediaPlayer . |
Modifier and Type | Method and Description |
---|---|
DoubleProperty |
fitHeightProperty()
Determines the height of the bounding box within which the source media is
resized as necessary to fit.
|
DoubleProperty |
fitWidthProperty()
Determines the width of the bounding box within which the source media is
resized as necessary to fit.
|
double |
getFitHeight()
Retrieves the height of the bounding box of the resized media.
|
double |
getFitWidth()
Retrieves the width of the bounding box of the resized media.
|
MediaPlayer |
getMediaPlayer()
Retrieves the
MediaPlayer whose output is being handled by
this view. |
EventHandler<MediaErrorEvent> |
getOnError()
Retrieves the error event handler.
|
Rectangle2D |
getViewport()
Retrieves the rectangular viewport into the media frame.
|
double |
getX()
Retrieves the x coordinate of the
MediaView origin. |
double |
getY()
Retrieves the y coordinate of the
MediaView origin. |
boolean |
isPreserveRatio()
Returns whether the media aspect ratio is preserved when scaling.
|
boolean |
isSmooth()
Returns whether to smooth the media when scaling.
|
ObjectProperty<MediaPlayer> |
mediaPlayerProperty()
The
mediaPlayer whose output will be handled by this view. |
ObjectProperty<EventHandler<MediaErrorEvent>> |
onErrorProperty()
Event handler to be invoked whenever an error occurs on this
MediaView . |
BooleanProperty |
preserveRatioProperty()
Whether to preserve the aspect ratio (width / height) of the media when
scaling it to fit the node.
|
void |
setFitHeight(double value)
Sets the height of the bounding box of the resized media.
|
void |
setFitWidth(double value)
Sets the width of the bounding box of the resized media.
|
void |
setMediaPlayer(MediaPlayer value)
Sets the
MediaPlayer whose output will be handled by this view. |
void |
setOnError(EventHandler<MediaErrorEvent> value)
Sets the error event handler.
|
void |
setPreserveRatio(boolean value)
Sets whether to preserve the media aspect ratio when scaling.
|
void |
setSmooth(boolean value)
Sets whether to smooth the media when scaling.
|
void |
setViewport(Rectangle2D value)
Sets the rectangular viewport into the media frame.
|
void |
setX(double value)
Sets the x coordinate of the
MediaView origin. |
void |
setY(double value)
Sets the y coordinate of the
MediaView origin. |
BooleanProperty |
smoothProperty()
If set to
true a better quality filtering
algorithm will be used when scaling this video to fit within the
bounding box provided by fitWidth and fitHeight or
when transforming. |
ObjectProperty<Rectangle2D> |
viewportProperty()
Specifies a rectangular viewport into the media frame.
|
DoubleProperty |
xProperty()
Defines the current x coordinate of the
MediaView origin. |
DoubleProperty |
yProperty()
Defines the current y coordinate of the
MediaView origin. |
addEventFilter, addEventHandler, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getBaselineOffset, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToSceneTransformProperty, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, mouseTransparentProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, prefHeight, prefWidth, pressedProperty, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, visibleProperty
public final ObjectProperty<MediaPlayer> mediaPlayerProperty
mediaPlayer
whose output will be handled by this view.
Setting this value does not affect the status of the MediaPlayer
,
e.g., if the MediaPlayer
was playing prior to setting
mediaPlayer
then it will continue playing.getMediaPlayer()
,
setMediaPlayer(MediaPlayer)
public final ObjectProperty<EventHandler<MediaErrorEvent>> onErrorProperty
MediaView
.getOnError()
,
setOnError(EventHandler)
public final BooleanProperty preserveRatioProperty
true
.isPreserveRatio()
,
setPreserveRatio(boolean)
public final BooleanProperty smoothProperty
true
a better quality filtering
algorithm will be used when scaling this video to fit within the
bounding box provided by fitWidth
and fitHeight
or
when transforming.
If set to false
a faster but lesser quality filtering
will be used.
The default value depends on platform configuration.isSmooth()
,
setSmooth(boolean)
public final DoubleProperty xProperty
MediaView
origin.getX()
,
setX(double)
public final DoubleProperty yProperty
MediaView
origin.getY()
,
setY(double)
public final DoubleProperty fitWidthProperty
value ≤ 0
, then the width
of the bounding box will be set to the natural width of the media, but
fitWidth
will be set to the supplied parameter, even if
non-positive.
See preserveRatio
for information on interaction
between media views fitWidth
, fitHeight
and
preserveRatio
attributes.getFitWidth()
,
setFitWidth(double)
public final DoubleProperty fitHeightProperty
value ≤ 0
, then the height
of the bounding box will be set to the natural height of the media, but
fitHeight
will be set to the supplied parameter, even if
non-positive.
See preserveRatio
for information on interaction
between media views fitWidth
, fitHeight
and
preserveRatio
attributes.getFitHeight()
,
setFitHeight(double)
public final ObjectProperty<Rectangle2D> viewportProperty
viewport
to null will clear the viewport.getViewport()
,
setViewport(Rectangle2D)
public MediaView()
MediaView
instance with no associated
MediaPlayer
.public MediaView(MediaPlayer mediaPlayer)
MediaView
instance associated with the specified
MediaPlayer
. Equivalent to
MediaPlayer player; // initialization omitted
MediaView view = new MediaView();
view.setPlayer(player);
mediaPlayer
- the MediaPlayer
the playback of which is to be
viewed via this class.public final void setMediaPlayer(MediaPlayer value)
MediaPlayer
whose output will be handled by this view.value
- the associated MediaPlayer
.public final MediaPlayer getMediaPlayer()
MediaPlayer
whose output is being handled by
this view.MediaPlayer
.public final ObjectProperty<MediaPlayer> mediaPlayerProperty()
mediaPlayer
whose output will be handled by this view.
Setting this value does not affect the status of the MediaPlayer
,
e.g., if the MediaPlayer
was playing prior to setting
mediaPlayer
then it will continue playing.getMediaPlayer()
,
setMediaPlayer(MediaPlayer)
public final void setOnError(EventHandler<MediaErrorEvent> value)
value
- the error event handler.public final EventHandler<MediaErrorEvent> getOnError()
public final ObjectProperty<EventHandler<MediaErrorEvent>> onErrorProperty()
MediaView
.getOnError()
,
setOnError(EventHandler)
public final void setPreserveRatio(boolean value)
value
- whether to preserve the media aspect ratio.public final boolean isPreserveRatio()
public final BooleanProperty preserveRatioProperty()
true
.isPreserveRatio()
,
setPreserveRatio(boolean)
public final void setSmooth(boolean value)
value
- whether to smooth the media.public final boolean isSmooth()
public final BooleanProperty smoothProperty()
true
a better quality filtering
algorithm will be used when scaling this video to fit within the
bounding box provided by fitWidth
and fitHeight
or
when transforming.
If set to false
a faster but lesser quality filtering
will be used.
The default value depends on platform configuration.isSmooth()
,
setSmooth(boolean)
public final void setX(double value)
MediaView
origin.value
- the x coordinate of the origin of the view.public final double getX()
MediaView
origin.public final DoubleProperty xProperty()
MediaView
origin.getX()
,
setX(double)
public final void setY(double value)
MediaView
origin.value
- the y coordinate of the origin of the view.public final double getY()
MediaView
origin.public final DoubleProperty yProperty()
MediaView
origin.getY()
,
setY(double)
public final void setFitWidth(double value)
value
- the width of the resized media.public final double getFitWidth()
public final DoubleProperty fitWidthProperty()
value ≤ 0
, then the width
of the bounding box will be set to the natural width of the media, but
fitWidth
will be set to the supplied parameter, even if
non-positive.
See preserveRatio
for information on interaction
between media views fitWidth
, fitHeight
and
preserveRatio
attributes.getFitWidth()
,
setFitWidth(double)
public final void setFitHeight(double value)
value
- the height of the resized media.public final double getFitHeight()
public final DoubleProperty fitHeightProperty()
value ≤ 0
, then the height
of the bounding box will be set to the natural height of the media, but
fitHeight
will be set to the supplied parameter, even if
non-positive.
See preserveRatio
for information on interaction
between media views fitWidth
, fitHeight
and
preserveRatio
attributes.getFitHeight()
,
setFitHeight(double)
public final void setViewport(Rectangle2D value)
value
- the rectangular viewport.public final Rectangle2D getViewport()
public final ObjectProperty<Rectangle2D> viewportProperty()
viewport
to null will clear the viewport.getViewport()
,
setViewport(Rectangle2D)
Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to