public class MediaPlayer extends Container
Video playback component with control buttons for back, play/pause and forward buttons. In the simulator those controls are implemented locally but on the device the native playback controls are used.
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR
Constructor and Description |
---|
MediaPlayer()
Empty constructor
|
MediaPlayer(Media video)
Empty constructor
|
Modifier and Type | Method and Description |
---|---|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
protected void |
deinitialize()
Invoked to indicate that the component initialization is being reversed
since the component was detached from the container hierarchy.
|
Image |
getBackIcon() |
String |
getDataSource()
Convenience JavaBean method, see other version of this method
|
Image |
getFwdIcon() |
Media |
getMedia()
Returns the Media Object of this MediaPlayer
|
Image |
getPauseIcon() |
Image |
getPlayIcon() |
String[] |
getPropertyNames()
A component may expose mutable property names for a UI designer to manipulate, this
API is designed for usage internally by the GUI builder code
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder
|
String |
getSeekBarUIID()
UIID for the seekBar slider
|
void |
hideControls()
Hides the controls for this media player.
|
protected void |
initComponent()
Allows subclasses to bind functionality that relies on fully initialized and
"ready for action" component state
|
boolean |
isAutoplay()
Sets playback to start automatically
|
boolean |
isHideNativeVideoControls()
On platforms that include native video player controls (Android and iOS), this indicates whether
these controls should be hidden for this media player.
|
boolean |
isLoop()
Sets playback to loop
|
boolean |
isMaximize()
Includes a maximize icon in the bar to show the native player
|
boolean |
isOnTopMode()
Shows the buttons on top of the video
|
boolean |
isSeekBar()
Shows video position bar as a slider
|
void |
run() |
void |
setAutoplay(boolean autoplay)
Sets playback to start automatically
|
void |
setBackIcon(Image backIcon)
Sets the back Button Icon
|
void |
setDataSource(InputStream is,
String mimeType,
Runnable onCompletion)
Sets the data source of this video player
|
void |
setDataSource(String uri)
Convenience JavaBean method, see other version of this method
|
void |
setDataSource(String uri,
Runnable onCompletion)
Sets the data source of this video player
|
void |
setFwdIcon(Image fwdIcon)
Sets the forward Button Icon
|
void |
setHideNativeVideoControls(boolean hideNativeControls)
On platforms that include native video player controls (Android and iOS), this allows you
to hide those controls.
|
void |
setLoop(boolean loop)
Sets playback to loop
|
void |
setMaxIcon(Image maxIcon)
Sets the maximize Button Icon
|
void |
setMaximize(boolean maximize)
Includes a maximize icon in the bar to show the native player
|
void |
setOnTopMode(boolean onTopMode)
Shows the buttons on top of the video
|
void |
setPauseIcon(Image pauseIcon)
Sets the pause Button Icon
|
void |
setPlayIcon(Image playIcon)
Sets the play Button Icon
|
String |
setPropertyValue(String name,
Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
void |
setSeekBar(boolean seekBar)
Shows video position bar as a slider
|
void |
setSeekBarUIID(String seekBarUIID)
UIID for the seekBar slider
|
void |
showControls()
Shows the controls for this media player.
|
boolean |
usesNativeVideoControls()
Checks to see if this player uses native video controls.
|
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintBackground, paintBorderBackground, paintComponentBackground, paintGlass, paramString, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndices
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains
public MediaPlayer()
public MediaPlayer(Media video)
public void setHideNativeVideoControls(boolean hideNativeControls)
hideNativeControls
- Set true to hide the native video controls for this player.Display.isNativeVideoPlayerControlsIncluded()
,
setHideNativeVideoControls(boolean)
,
usesNativeVideoControls()
public boolean isHideNativeVideoControls()
Display.isNativeVideoPlayerControlsIncluded()
,
setHideNativeVideoControls(boolean)
,
usesNativeVideoControls()
public boolean usesNativeVideoControls()
Display.isNativeVideoPlayerControlsIncluded()
to find out if current platform supports this; AND isHideNativeVideoControls()
must be false.
Note: on IOS, the controls won't display until the video's Media.prepare()
is called. This will happen automatically if isAutoplay()
is true, or if Media.play()
is called.
isHideNativeVideoControls()
,
setHideNativeVideoControls(boolean)
,
Display.isNativeVideoPlayerControlsIncluded()
public void showControls()
Note: on IOS, the controls won't display until the video's Media.prepare()
is called. This will happen automatically if isAutoplay()
is true, or if Media.play()
is called.
public void hideControls()
public Media getMedia()
protected void initComponent()
initComponent
in class Component
protected void deinitialize()
deinitialize
in class Component
protected Dimension calcPreferredSize()
calcPreferredSize
in class Container
public void setBackIcon(Image backIcon)
backIcon
- public void setFwdIcon(Image fwdIcon)
fwdIcon
- public void setMaxIcon(Image maxIcon)
maxIcon
- public void setPauseIcon(Image pauseIcon)
pauseIcon
- public void setPlayIcon(Image playIcon)
playIcon
- public void setDataSource(String uri, Runnable onCompletion) throws IOException
uri
- the uri of the media can start with file://, http:// (can also
use rtsp:// although may not be supported on all target platforms)IOException
- if creation of media from the given URI has failedpublic void setDataSource(String uri)
uri
- the URL for the mediapublic String getDataSource()
public void setDataSource(InputStream is, String mimeType, Runnable onCompletion) throws IOException
is
- the stream containing the media datamimeType
- the type of the data in the streamIOException
- if the creation of the Media has failedpublic void run()
public String[] getPropertyNames()
getPropertyNames
in class Component
public Class[] getPropertyTypes()
getPropertyTypes
in class Component
public Object getPropertyValue(String name)
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the propertypublic Image getPlayIcon()
public Image getPauseIcon()
public Image getBackIcon()
public Image getFwdIcon()
public boolean isAutoplay()
public void setAutoplay(boolean autoplay)
autoplay
- the autoplay to setpublic boolean isLoop()
public void setLoop(boolean loop)
loop
- the loop to setpublic boolean isOnTopMode()
public void setOnTopMode(boolean onTopMode)
onTopMode
- the onTopMode to setpublic boolean isSeekBar()
public void setSeekBar(boolean seekBar)
seekBar
- the seekBar to setpublic String getSeekBarUIID()
public void setSeekBarUIID(String seekBarUIID)
seekBarUIID
- the seekBarUIID to setpublic boolean isMaximize()
public void setMaximize(boolean maximize)
maximize
- the maximize to set