Class ClipControl

java.lang.Object
org.opensourcephysics.display.OSPRuntime.Supported
org.opensourcephysics.media.core.ClipControl
All Implemented Interfaces:
PropertyChangeListener, EventListener
Direct Known Subclasses:
StepperClipControl, VideoClipControl

public abstract class ClipControl extends OSPRuntime.Supported implements PropertyChangeListener
A ClipControl controls a VideoClip. This is an abstract class that cannot be instantiated directly.
Version:
1.0
Author:
Douglas Brown
  • Field Details

    • stepNumber

      protected int stepNumber
    • videoFrameNumber

      protected int videoFrameNumber
    • clip

      protected final VideoClip clip
    • video

      protected Video video
    • rate

      protected double rate
    • looping

      protected boolean looping
    • timeStretch

      protected double timeStretch
    • timeSource

      protected DataTrack timeSource
    • savedFrameDuration

      protected double savedFrameDuration
    • videoVisible

      public boolean videoVisible
    • loadedStepNumber

      public int loadedStepNumber
    • PROPERTY_CLIPCONTROL_LOOPING

      public static final String PROPERTY_CLIPCONTROL_LOOPING
      See Also:
    • PROPERTY_CLIPCONTROL_PLAYING

      public static final String PROPERTY_CLIPCONTROL_PLAYING
      See Also:
    • PROPERTY_CLIPCONTROL_RATE

      public static final String PROPERTY_CLIPCONTROL_RATE
      See Also:
    • PROPERTY_CLIPCONTROL_STEPNUMBER

      public static final String PROPERTY_CLIPCONTROL_STEPNUMBER
      See Also:
    • PROPERTY_CLIPCONTROL_FRAMEDURATION

      public static final String PROPERTY_CLIPCONTROL_FRAMEDURATION
      See Also:
  • Constructor Details

    • ClipControl

      protected ClipControl(VideoClip videoClip)
      Constructs a ClipControl object. This is an abstract class that cannot be instantiated directly.
      Parameters:
      videoClip - the video clip
  • Method Details

    • getControl

      public static ClipControl getControl(VideoClip clip)
      Returns an instance of ClipControl.
      Parameters:
      clip - the video clip
      Returns:
      an appropriate clip control
    • getVideoClip

      public VideoClip getVideoClip()
      Gets the clip that is controlled by this clip control.
      Returns:
      the clip
    • 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.
    • setFrameNumber

      public void setFrameNumber(int n)
      Sets the frame number.
      Parameters:
      n - the desired frame number
    • 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
    • setRate

      public void setRate(double newRate)
      Sets the play rate.
      Parameters:
      newRate - the desired rate
    • getRate

      public double getRate()
      Gets the play rate.
      Returns:
      the current rate
    • getMeasuredRate

      public double getMeasuredRate()
      Gets the measured play rate. Default is the set rate. StepperClipControl overrides to report true measured rate.
      Returns:
      the measured rate
    • setLooping

      public void setLooping(boolean loops)
      Turns on/off looping.
      Parameters:
      loops - true to turn looping on
    • isLooping

      public boolean isLooping()
      Gets the looping status.
      Returns:
      true if looping is on
    • getFrameNumber

      public int getFrameNumber()
      Gets the current frame number.
      Returns:
      the frame number
    • getTimeSource

      public DataTrack getTimeSource()
      Gets the DataTrack time source, if any.
      Returns:
      the time source (may be null)
    • setTimeSource

      public void setTimeSource(DataTrack source)
      Sets the time source to a DataTrack.
      Parameters:
      source - the time source (may be null)
    • propertyChange

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

      public abstract boolean isPlaying()
      Gets the playing status.
      Returns:
      true if playing
    • getTime

      public abstract double getTime()
      Gets the current time in milliseconds measured from step 0.
      Returns:
      the current time
    • getStepTime

      public abstract double getStepTime(int stepNumber)
      Gets the start time of the specified step measured from step 0.
      Parameters:
      stepNumber - the step number
      Returns:
      the step time
    • setFrameDuration

      public abstract void setFrameDuration(double duration)
      Sets the frame duration.
      Parameters:
      duration - the desired frame duration in milliseconds
    • getMeanFrameDuration

      public abstract double getMeanFrameDuration()
      Gets the average frame duration in milliseconds.
      Returns:
      the mean frame duration in milliseconds
    • dispose

      public void dispose()
      Empty dispose method.
      Overrides:
      dispose in class OSPRuntime.Supported
    • isTimeSource

      public static boolean isTimeSource(DataTrack track)
      Determines if a DataTrack is actively providing time data.