Class VideoPlayer

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener

public class VideoPlayer extends JComponent implements 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:
  • Field Details

    • PROPERTY_VIDEOPLAYER_BACKBUTTON

      public static final String PROPERTY_VIDEOPLAYER_BACKBUTTON
      See Also:
    • PROPERTY_VIDEOPLAYER_PLAYING

      public static final String PROPERTY_VIDEOPLAYER_PLAYING
      See Also:
    • PROPERTY_VIDEOPLAYER_SLIDER

      public static final String PROPERTY_VIDEOPLAYER_SLIDER
      See Also:
    • PROPERTY_VIDEOPLAYER_STEPBUTTON

      public static final String PROPERTY_VIDEOPLAYER_STEPBUTTON
      See Also:
    • PROPERTY_VIDEOPLAYER_FRAMEDURATION

      public static final String PROPERTY_VIDEOPLAYER_FRAMEDURATION
      See Also:
    • PROPERTY_VIDEOPLAYER_STEPNUMBER

      public static final String PROPERTY_VIDEOPLAYER_STEPNUMBER
      See Also:
    • PROPERTY_VIDEOPLAYER_VIDEOCLIP

      public static final String PROPERTY_VIDEOPLAYER_VIDEOCLIP
      See Also:
    • inOutIcon

      protected static Icon inOutIcon
    • playIcon

      protected static Icon playIcon
    • grayPlayIcon

      protected static Icon grayPlayIcon
    • pauseIcon

      protected static Icon pauseIcon
    • resetIcon

      protected static Icon resetIcon
    • loopIcon

      protected static Icon loopIcon
    • noloopIcon

      protected static Icon noloopIcon
    • videoClipIcon

      protected static Icon videoClipIcon
    • stepIcon

      protected static Icon stepIcon
    • grayStepIcon

      protected static Icon grayStepIcon
    • backIcon

      protected static Icon backIcon
    • grayBackIcon

      protected static Icon grayBackIcon
    • vidPanel

      protected VideoPanel vidPanel
    • clipControl

      protected ClipControl clipControl
    • height

      protected int height
    • readout

      protected OSPButton readout
    • playButton

      protected OSPButton playButton
    • resetButton

      protected OSPButton resetButton
    • stepSizeBtnListener

      protected ActionListener stepSizeBtnListener
  • Constructor Details

    • 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 Details

    • addActionListener

      public void addActionListener(PropertyChangeListener c)
    • removeActionListener

      public void removeActionListener(PropertyChangeListener c)
    • addFrameListener

      public void addFrameListener(PropertyChangeListener c)
    • removeFrameListener

      public void removeFrameListener(PropertyChangeListener c)
    • 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(String types, String typeToSelect)
      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

      public void setReadoutType(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. Only invoked during VideoGrabber.createGUI
      Parameters:
      visible - true to show the looping button
    • propertyChange

      public void propertyChange(PropertyChangeEvent e)
      Responds to property change events.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      e - the property change event
    • refresh

      public void refresh()
      Refreshes the GUI.
    • setLocale

      public void setLocale(Locale locale)
      Overrides:
      setLocale in class Component
    • setEnabled

      public void setEnabled(boolean enabled)
      Enables and disables this component.
      Overrides:
      setEnabled in class JComponent
      Parameters:
      enabled - true to enable
    • paintChildren

      protected void paintChildren(Graphics g)
      Overrides:
      paintChildren in class JComponent
    • doSliderKey

      protected void doSliderKey(int keyCode)
    • doPlay

      protected void doPlay()
    • doReset

      protected void doReset()
    • fireButtonEvent

      protected void fireButtonEvent(String name, boolean b)
    • sliderMovedAction

      protected void sliderMovedAction(MouseEvent e)
    • sliderPressedAction

      protected void sliderPressedAction(MouseEvent e)
    • sliderDraggedAction

      protected void sliderDraggedAction(MouseEvent e)
    • sliderReleasedAction

      protected void sliderReleasedAction(MouseEvent e)
    • updatePlayButtonsPosted

      protected void updatePlayButtonsPosted(boolean playing)
    • updateSliderAsync

      protected void updateSliderAsync(String option, Object o)
    • showGoToDialog

      public void showGoToDialog()
    • dispose

      public void dispose()
    • finalize

      public void finalize()
      Overrides:
      finalize in class Object