org.opensourcephysics.media.core
Class VideoPlayer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.opensourcephysics.media.core.VideoPlayer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class VideoPlayer
extends javax.swing.JComponent
implements java.beans.PropertyChangeListener

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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  ClipControl clipControl
           
protected  int height
           
protected  VideoPanel vidPanel
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
VideoPlayer(VideoPanel panel)
          Constructs a VideoPlayer.
VideoPlayer(VideoPanel panel, VideoClip clip)
          Constructs a VideoPlayer to play the specified video clip.
 
Method Summary
 void back()
          Steps back one step.
 ClipControl getClipControl()
          Gets the current clip control.
 int getFrameNumber()
          Gets the current frame number.
 double getFrameTime(int frameNumber)
          Gets the start time of the specified frame in milliseconds.
 double getMeanStepDuration()
          Gets the mean step duration in milliseconds for the current video clip.
 double getRate()
          Gets the play rate.
 int getStepNumber()
          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.
 VideoClip getVideoClip()
          Gets the video clip.
 boolean isLooping()
          Gets the looping status.
 void play()
          Plays the clip.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
 void refresh()
          Refreshes the GUI.
 void setInspectorButtonVisible(boolean visible)
          Shows or hides the inspector button.
 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(java.lang.String type)
          Sets the type of data displayed in the readout.
 void setReadoutTypes(java.lang.String types)
          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 step()
          Steps forward one step.
 void stop()
          Stops at the next step.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setEnabled, 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, transferFocusBackward, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vidPanel

protected VideoPanel vidPanel

clipControl

protected ClipControl clipControl

height

protected int height
Constructor Detail

VideoPlayer

public VideoPlayer(VideoPanel panel,
                   VideoClip clip)
Constructs a VideoPlayer to play the specified video clip.

Parameters:
panel - the video panel
clip - the video clip

VideoPlayer

public VideoPlayer(VideoPanel panel)
Constructs a VideoPlayer.

Parameters:
panel - the video panel
Method Detail

setVideoClip

public void setVideoClip(VideoClip clip)
Sets the video clip.

Parameters:
clip - the video clip

getVideoClip

public VideoClip getVideoClip()
Gets the video clip.

Returns:
the video clip

getClipControl

public ClipControl getClipControl()
Gets the current clip control.

Returns:
the clip control

setReadoutTypes

public void setReadoutTypes(java.lang.String types)
Sets the readout data types made available to the user. The type initially displayed in the readout is the first listed.

Parameters:
types - a list of data types. Supported types are "time", "step", and "frame".

setReadoutType

public void setReadoutType(java.lang.String type)
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.

Parameters:
visible - true to show the looping button

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. VideoPlayer listens for the following events: "playing", "stepnumber". "frameduration" and "looping" from ClipControl, and "startframe", "stepsize", "stepcount" and "starttime" from VideoClip.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the property change event

refresh

public void refresh()
Refreshes the GUI.