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 class
GoToDialog inner classNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Icon
protected ClipControl
protected static Icon
protected static Icon
protected static Icon
protected int
protected static Icon
protected static Icon
protected static Icon
protected static Icon
protected OSPButton
protected static Icon
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected OSPButton
protected OSPButton
protected static Icon
protected static Icon
protected ActionListener
protected static Icon
protected VideoPanel
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields 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 TypeMethodDescriptionvoid
void
void
back()
Steps back one step.void
dispose()
protected void
doPlay()
protected void
doReset()
protected void
doSliderKey
(int keyCode) void
finalize()
protected void
fireButtonEvent
(String name, boolean b) Gets the current clip control.int
Gets the current frame number.double
getFrameTime
(int frameNumber) Gets the start time of the specified frame in milliseconds.double
Gets the mean step duration in milliseconds for the current video clip.double
getRate()
Gets the play rate.int
Gets the step number.double
getStepTime
(int stepNumber) Gets the start time of the specified step in milliseconds.double
getTime()
Gets the current time in milliseconds.Gets the video clip.boolean
Gets the looping status.protected void
void
play()
Plays the clip.void
Responds to property change events.void
refresh()
Refreshes the GUI.void
void
void
setEnabled
(boolean enabled) Enables and disables this component.void
setInspectorButtonVisible
(boolean visible) Shows or hides the inspector button.void
void
setLooping
(boolean looping) Turns on/off looping.void
setLoopingButtonVisible
(boolean visible) Shows or hides the looping button.void
setRate
(double rate) Sets the play rate.void
setReadoutType
(String type) Sets the type of data displayed in the readout.void
setReadoutTypes
(String types, String typeToSelect) Sets the readout data types made available to the user.void
setStepNumber
(int n) Sets the step number.void
setVideoClip
(VideoClip clip) Sets the video clip.void
protected void
protected void
protected void
protected void
void
step()
Steps forward one step.void
stop()
Stops at the next step.protected void
updatePlayButtonsPosted
(boolean playing) protected void
updateSliderAsync
(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, updateUI
Methods 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, validateTree
Methods 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
-true
to turn looping on
-
isLooping
public boolean isLooping()Gets the looping status.- Returns:
true
if 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
-true
to show the inspector button
-
setLoopingButtonVisible
public void setLoopingButtonVisible(boolean visible) Shows or hides the looping button. Only invoked during VideoGrabber.createGUI- Parameters:
visible
-true
to show the looping button
-
propertyChange
Responds to property change events.- Specified by:
propertyChange
in 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:
setEnabled
in classJComponent
- Parameters:
enabled
- true to enable
-
paintChildren
- Overrides:
paintChildren
in 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()
-