Package org.opensourcephysics.media.core
Class VideoPlayer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.opensourcephysics.media.core.VideoPlayer
- All Implemented Interfaces:
ImageObserver,MenuContainer,PropertyChangeListener,Serializable,EventListener
This is a GUI component for playing a VideoClip. It uses a subclass of
ClipControl to control the clip and updates its display based on
PropertyChangeEvents it receives from the ClipControl.
- Version:
- 1.0
- Author:
- Douglas Brown
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classGoToDialog inner classNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Iconprotected ClipControlprotected static Iconprotected static Iconprotected static Iconprotected intprotected static Iconprotected static Iconprotected static Iconprotected static Iconprotected OSPButtonprotected static Iconstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected OSPButtonprotected OSPButtonprotected static Iconprotected static Iconprotected ActionListenerprotected static Iconprotected VideoPanelFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionVideoPlayer(VideoPanel panel) Constructs a VideoPlayer.VideoPlayer(VideoPanel panel, VideoClip clip) Constructs a VideoPlayer to play the specified video clip. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidback()Steps back one step.voiddispose()protected voiddoPlay()protected voiddoReset()protected voiddoSliderKey(int keyCode) voidfinalize()protected voidfireButtonEvent(String name, boolean b) Gets the current clip control.intGets the current frame number.doublegetFrameTime(int frameNumber) Gets the start time of the specified frame in milliseconds.doubleGets the mean step duration in milliseconds for the current video clip.doublegetRate()Gets the play rate.intGets the step number.doublegetStepTime(int stepNumber) Gets the start time of the specified step in milliseconds.doublegetTime()Gets the current time in milliseconds.Gets the video clip.booleanGets the looping status.protected voidvoidplay()Plays the clip.voidResponds to property change events.voidrefresh()Refreshes the GUI.voidvoidvoidsetEnabled(boolean enabled) Enables and disables this component.voidsetInspectorButtonVisible(boolean visible) Shows or hides the inspector button.voidvoidsetLooping(boolean looping) Turns on/off looping.voidsetLoopingButtonVisible(boolean visible) Shows or hides the looping button.voidsetRate(double rate) Sets the play rate.voidsetReadoutType(String type) Sets the type of data displayed in the readout.voidsetReadoutTypes(String types, String typeToSelect) Sets the readout data types made available to the user.voidsetStepNumber(int n) Sets the step number.voidsetVideoClip(VideoClip clip) Sets the video clip.voidprotected voidprotected voidprotected voidprotected voidvoidstep()Steps forward one step.voidstop()Stops at the next step.protected voidupdatePlayButtonsPosted(boolean playing) protected voidupdateSliderAsync(String option, Object o) Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUIMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
PROPERTY_VIDEOPLAYER_BACKBUTTON
- See Also:
-
PROPERTY_VIDEOPLAYER_PLAYING
- See Also:
-
PROPERTY_VIDEOPLAYER_SLIDER
- See Also:
-
PROPERTY_VIDEOPLAYER_STEPBUTTON
- See Also:
-
PROPERTY_VIDEOPLAYER_FRAMEDURATION
- See Also:
-
PROPERTY_VIDEOPLAYER_STEPNUMBER
- See Also:
-
PROPERTY_VIDEOPLAYER_VIDEOCLIP
- See Also:
-
inOutIcon
-
playIcon
-
grayPlayIcon
-
pauseIcon
-
resetIcon
-
loopIcon
-
noloopIcon
-
videoClipIcon
-
stepIcon
-
grayStepIcon
-
backIcon
-
grayBackIcon
-
vidPanel
-
clipControl
-
height
protected int height -
readout
-
playButton
-
resetButton
-
stepSizeBtnListener
-
-
Constructor Details
-
VideoPlayer
Constructs a VideoPlayer to play the specified video clip.- Parameters:
panel- the video panelclip- the video clip
-
VideoPlayer
Constructs a VideoPlayer.- Parameters:
panel- the video panel
-
-
Method Details
-
addActionListener
-
removeActionListener
-
addFrameListener
-
removeFrameListener
-
setVideoClip
Sets the video clip.- Parameters:
clip- the video clip
-
getVideoClip
Gets the video clip.- Returns:
- the video clip
-
getClipControl
Gets the current clip control.- Returns:
- the clip control
-
setReadoutTypes
Sets the readout data types made available to the user.- Parameters:
types- a list of data types. Supported types are "time", "step", "frame".typeToSelect- the initially selected type
-
setReadoutType
Sets the type of data displayed in the readout.- Parameters:
type- "time", "step", or "frame"
-
play
public void play()Plays the clip. -
stop
public void stop()Stops at the next step. -
step
public void step()Steps forward one step. -
back
public void back()Steps back one step. -
setRate
public void setRate(double rate) Sets the play rate.- Parameters:
rate- the desired rate
-
getRate
public double getRate()Gets the play rate.- Returns:
- the current rate
-
setLooping
public void setLooping(boolean looping) Turns on/off looping.- Parameters:
looping-trueto turn looping on
-
isLooping
public boolean isLooping()Gets the looping status.- Returns:
trueif looping is on
-
setStepNumber
public void setStepNumber(int n) Sets the step number.- Parameters:
n- the desired step number
-
getStepNumber
public int getStepNumber()Gets the step number.- Returns:
- the current step number
-
getFrameNumber
public int getFrameNumber()Gets the current frame number.- Returns:
- the frame number
-
getTime
public double getTime()Gets the current time in milliseconds. Includes the start time defined by the video clip.- Returns:
- the current time
-
getStepTime
public double getStepTime(int stepNumber) Gets the start time of the specified step in milliseconds. Includes the start time defined by the video clip.- Parameters:
stepNumber- the step number- Returns:
- the time
-
getFrameTime
public double getFrameTime(int frameNumber) Gets the start time of the specified frame in milliseconds. Includes the start time defined by the video clip.- Parameters:
frameNumber- the frame number- Returns:
- the time
-
getMeanStepDuration
public double getMeanStepDuration()Gets the mean step duration in milliseconds for the current video clip.- Returns:
- the mean step duration
-
setInspectorButtonVisible
public void setInspectorButtonVisible(boolean visible) Shows or hides the inspector button. The inspector button shows and hides the clip inspector.- Parameters:
visible-trueto show the inspector button
-
setLoopingButtonVisible
public void setLoopingButtonVisible(boolean visible) Shows or hides the looping button. Only invoked during VideoGrabber.createGUI- Parameters:
visible-trueto show the looping button
-
propertyChange
Responds to property change events.- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
e- the property change event
-
refresh
public void refresh()Refreshes the GUI. -
setLocale
-
setEnabled
public void setEnabled(boolean enabled) Enables and disables this component.- Overrides:
setEnabledin classJComponent- Parameters:
enabled- true to enable
-
paintChildren
- Overrides:
paintChildrenin classJComponent
-
doSliderKey
protected void doSliderKey(int keyCode) -
doPlay
protected void doPlay() -
doReset
protected void doReset() -
fireButtonEvent
-
sliderMovedAction
-
sliderPressedAction
-
sliderDraggedAction
-
sliderReleasedAction
-
updatePlayButtonsPosted
protected void updatePlayButtonsPosted(boolean playing) -
updateSliderAsync
-
showGoToDialog
public void showGoToDialog() -
dispose
public void dispose() -
finalize
public void finalize()
-