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:
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);
}
The foregoing code will display the video as:
BASELINE_OFFSET_SAME_AS_HEIGHT
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() |
DoubleProperty |
fitWidthProperty() |
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. |
protected boolean |
impl_computeContains(double localX,
double localY)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
BaseBounds |
impl_computeGeomBounds(BaseBounds bounds,
BaseTransform tx)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
protected NGNode |
impl_createPeer()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
int |
impl_perfGetDecodedFrameCount()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
int |
impl_perfGetRenderedFrameCount()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_perfReset()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
Object |
impl_processMXNode(MXNodeAlgorithm alg,
MXNodeAlgorithmContext ctx)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_transformsChanged()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
void |
impl_updatePeer()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
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() |
ObjectProperty<EventHandler<MediaErrorEvent>> |
onErrorProperty() |
BooleanProperty |
preserveRatioProperty() |
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() |
ObjectProperty<Rectangle2D> |
viewportProperty() |
DoubleProperty |
xProperty() |
DoubleProperty |
yProperty() |
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBaselineOffset, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getContentBias, getCssMetaData, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, 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, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_clearDirty, impl_computeIntersects, impl_computeLayoutBounds, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_notifyLayoutBoundsChanged, impl_pickNode, impl_pickNodeLocal, impl_processCSS, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_traverse, impl_treeVisibleProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isResizable, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, 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, parentToLocal, parentToLocal, pickOnBoundsProperty, prefHeight, prefWidth, pressedProperty, pseudoClassStateChanged, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, 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, usesMirroring, visibleProperty
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.setMediaPlayer(player);
mediaPlayer
- the MediaPlayer
the playback of which is to be
viewed via this class.@Deprecated public void impl_transformsChanged()
Node
impl_transformsChanged
in class Node
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()
public final void setOnError(EventHandler<MediaErrorEvent> value)
value
- the error event handler.public final EventHandler<MediaErrorEvent> getOnError()
public final ObjectProperty<EventHandler<MediaErrorEvent>> onErrorProperty()
public final void setPreserveRatio(boolean value)
value
- whether to preserve the media aspect ratio.public final boolean isPreserveRatio()
public final BooleanProperty preserveRatioProperty()
public final void setSmooth(boolean value)
value
- whether to smooth the media.public final boolean isSmooth()
public final BooleanProperty smoothProperty()
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()
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()
public final void setFitWidth(double value)
value
- the width of the resized media.public final double getFitWidth()
public final DoubleProperty fitWidthProperty()
public final void setFitHeight(double value)
value
- the height of the resized media.public final double getFitHeight()
public final DoubleProperty fitHeightProperty()
public final void setViewport(Rectangle2D value)
value
- the rectangular viewport.public final Rectangle2D getViewport()
public final ObjectProperty<Rectangle2D> viewportProperty()
@Deprecated protected NGNode impl_createPeer()
impl_createPeer
in class Node
@Deprecated public BaseBounds impl_computeGeomBounds(BaseBounds bounds, BaseTransform tx)
Node
impl_computeGeomBounds
in class Node
@Deprecated protected boolean impl_computeContains(double localX, double localY)
impl_computeContains
in class Node
@Deprecated public void impl_updatePeer()
Node
impl_updatePeer
in class Node
@Deprecated public void impl_perfReset()
@Deprecated public int impl_perfGetDecodedFrameCount()
@Deprecated public int impl_perfGetRenderedFrameCount()
@Deprecated public Object impl_processMXNode(MXNodeAlgorithm alg, MXNodeAlgorithmContext ctx)
Node
impl_processMXNode
in class Node
alg
- current algorithm to process this nodectx
- current contextCopyright © 2020. All rights reserved.