Package org.opensourcephysics.media.core
Interface Video
- All Superinterfaces:
Drawable,DrawableImage,EventListener,Interactive,InteractiveImage,Measurable,PropertyChangeListener,Trackable
- All Known Implementing Classes:
GifVideo,ImageVideo,JSMovieVideo,MovieVideo,VideoAdapter,XuggleVideo
This defines methods to control a video image sequence. Individual images
within the sequence are referred to as frames.
- Version:
- 1.0
- Author:
- Douglas Brown
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface org.opensourcephysics.media.core.Trackable
PROPERTY_ADJUSTING -
Method Summary
Modifier and TypeMethodDescriptiondefault voidvoidAdds a PropertyChangeListener to this object.voidaddPropertyChangeListener(String property, PropertyChangeListener listener) Adds a PropertyChangeListener to this object.voidback()Steps backward in the video.voiddispose()Disposes of this video.default doublegetAverageFrameDuration(boolean allowOneFrame) Calculate (last frame start time - first frame start time)/(final frame number - first frame number) when there is more than one frame.default doubleintGets the end frame number.doubleGets the end time in milliseconds.intGets the total number of frames.doubleGets the duration of the media, including a time for the last frame From XuggleVideo code, now also for JSMovieVideodoublegetFrameDuration(int n) Gets the duration of the specified frame in milliseconds.intGets the current frame number.doublegetFrameTime(int n) Gets the start time of the specified frame in milliseconds.getImageSize(boolean withFilters) Gets the image size as a Dimensiondefault BitSetgetOutliers(double tolerance) doublegetRate()Gets the rate at which the media plays relative to its normal rate.intGets the start frame number.doubleGets the start time in milliseconds.Returns the VideoType name of this video.voidgoToEnd()Sets the time to the end time.voidSets the time to the start time.voidInvalidate the video and its filter so that it can be refreshed and so that data can be rebuilt.booleanGets the looping behavior of the media.booleanGets whether the media is playing.default booleanisValid()voidplay()Plays the media.default voidvoidRemoves a PropertyChangeListener from this object.voidremovePropertyChangeListener(String property, PropertyChangeListener listener) Removes a PropertyChangeListener from this object.voidreset()Resets the media.voidsetEndFrameNumber(int n) Sets the end frame number.voidsetEndTime(double millis) Sets the end time in milliseconds.voidsetFrameAngle(int n, double angle) Sets the angle in radians of the specified video frame measured ccw from the world x-axis.voidsetFrameHeight(int n, double height) Sets the height of the specified video frame in world units.voidsetFrameNumber(int n) Sets the frame number.voidsetFrameRelativeAspect(int n, double relativeAspect) Sets the relative aspect of the specified video frame.voidsetFrameWidth(int n, double width) Sets the width of the specified video frame in world units.voidsetFrameX(int n, double x) Sets x position of UL corner of the specified video frame in world units.voidsetFrameXY(int n, double x, double y) Sets the x and y position of the UL corner of the specified video frame in world units.voidsetFrameY(int n, double y) Sets y position of UL corner of the specified video frame in world units.voidsetLooping(boolean looping) Sets the looping behavior of the media.voidsetPlaying(boolean playing) Deprecated.voidsetRate(double rate) Sets the rate at which the media plays relative to its normal rate.voidsetStartFrameNumber(int n) Sets the start frame number.voidsetStartTime(double millis) Sets the start time in milliseconds.voidstep()Steps forward in thevoidstop()Stops the media.Methods inherited from interface org.opensourcephysics.media.core.DrawableImage
getFilterStack, getImage, getProperty, getPropertyNames, isVisible, setFilterStack, setProperty, setVisibleMethods inherited from interface org.opensourcephysics.display.Interactive
findInteractive, getX, getY, isEnabled, isInteractive, setEnabled, setX, setXY, setYMethods inherited from interface org.opensourcephysics.media.core.InteractiveImage
getAngle, getCoords, getHeight, getRelativeAspect, getWidth, setAngle, setCoords, setHeight, setRelativeAspect, setWidthMethods inherited from interface org.opensourcephysics.display.Measurable
getXMax, getXMin, getYMax, getYMin, isMeasuredMethods inherited from interface java.beans.PropertyChangeListener
propertyChange
-
Field Details
-
PROPERTY_VIDEO_COORDS
- See Also:
-
PROPERTY_VIDEO_FILTERCHANGED
- See Also:
-
PROPERTY_VIDEO_IMAGE
- See Also:
-
PROPERTY_VIDEO_SIZE
- See Also:
-
PROPERTY_VIDEO_VIDEOVISIBLE
- See Also:
-
PROPERTY_VIDEO_FRAMENUMBER
- See Also:
-
PROPERTY_VIDEO_NEXTFRAME
- See Also:
-
PROPERTY_VIDEO_ENDFRAME
- See Also:
-
PROPERTY_VIDEO_LOOPING
- See Also:
-
PROPERTY_VIDEO_PLAYING
- See Also:
-
PROPERTY_VIDEO_RATE
- See Also:
-
-
Method Details
-
removeListener
-
addListener
-
getImageSize
Gets the image size as a Dimension- Parameters:
withFilters- true to return size displayed after filters are applied
-
step
void step()Steps forward in the -
back
void back()Steps backward in the video. -
getFrameCount
int getFrameCount()Gets the total number of frames.- Returns:
- the number of frames in the image sequence
-
getFrameNumber
int getFrameNumber()Gets the current frame number.- Returns:
- the number of the current frame
-
setFrameNumber
void setFrameNumber(int n) Sets the frame number.- Parameters:
n- a number between getStartFrameNumber() and getEndFrameNumber()- See Also:
-
getStartFrameNumber
int getStartFrameNumber()Gets the start frame number.- Returns:
- the number of the start frame
- See Also:
-
setStartFrameNumber
void setStartFrameNumber(int n) Sets the start frame number.- Parameters:
n- a number between 0 and getEndFrameNumber()- See Also:
-
getEndFrameNumber
int getEndFrameNumber()Gets the end frame number.- Returns:
- the number of the end frame
- See Also:
-
setEndFrameNumber
void setEndFrameNumber(int n) Sets the end frame number.- Parameters:
n- a number between getStartFrameNumber() and getFrameCount()- See Also:
-
getFrameTime
double getFrameTime(int n) Gets the start time of the specified frame in milliseconds.- Parameters:
n- the frame number- Returns:
- the start time of the frame in milliseconds
-
getFrameDuration
double getFrameDuration(int n) Gets the duration of the specified frame in milliseconds.- Parameters:
n- the frame number- Returns:
- the duration of the frame in milliseconds
-
setFrameX
void setFrameX(int n, double x) Sets x position of UL corner of the specified video frame in world units.- Parameters:
n- the video frame numberx- the world x position
-
setFrameY
void setFrameY(int n, double y) Sets y position of UL corner of the specified video frame in world units.- Parameters:
n- the video frame numbery- the world y position
-
setFrameXY
void setFrameXY(int n, double x, double y) Sets the x and y position of the UL corner of the specified video frame in world units.- Parameters:
n- the video frame numberx- the world x positiony- the world y position
-
setFrameRelativeAspect
void setFrameRelativeAspect(int n, double relativeAspect) Sets the relative aspect of the specified video frame. The pixel aspect of an image is the ratio of its pixel width to height. Its world aspect is the ratio of width to height in world units. For example, a 320 x 240 pixel image has a pixel aspect of 4/3. If its relative aspect is set to 2, then the world aspect of the image will be 8/3. This means that if the image width is set to 16, its height will be 6. Conversely, if its height is set to 10, its width will be 8/3 x 10 = 26.666.- Parameters:
n- the video frame numberrelativeAspect- the world aspect of the image relative to its pixel aspect.
-
setFrameWidth
void setFrameWidth(int n, double width) Sets the width of the specified video frame in world units. This method also sets the height using the relative aspect.- Parameters:
n- the video frame numberwidth- the width in world units
-
setFrameHeight
void setFrameHeight(int n, double height) Sets the height of the specified video frame in world units. This method also sets the width using the relative aspect.- Parameters:
n- the video frame numberheight- the height in world units
-
setFrameAngle
void setFrameAngle(int n, double angle) Sets the angle in radians of the specified video frame measured ccw from the world x-axis.- Parameters:
n- the video frame numberangle- the angle n radians
-
dispose
void dispose()Disposes of this video. -
getTypeName
String getTypeName()Returns the VideoType name of this video. -
isValid
default boolean isValid() -
addPropertyChangeListener
Adds a PropertyChangeListener to this object.- Parameters:
listener- the listener requesting property change notification
-
addPropertyChangeListener
Adds a PropertyChangeListener to this object.- Parameters:
property- the name of the property of interest to the listenerlistener- the listener requesting property change notification
-
removePropertyChangeListener
Removes a PropertyChangeListener from this object.- Parameters:
listener- the listener requesting removal
-
removePropertyChangeListener
Removes a PropertyChangeListener from this object.- Parameters:
property- the name of the property of interest to the listenerlistener- the listener requesting removal
-
play
void play()Plays the media. -
stop
void stop()Stops the media. -
reset
void reset()Resets the media. -
getStartTime
double getStartTime()Gets the start time in milliseconds.- Returns:
- the start time in milliseconds
-
setStartTime
void setStartTime(double millis) Sets the start time in milliseconds.- Parameters:
millis- the desired start time in milliseconds
-
getEndTime
double getEndTime()Gets the end time in milliseconds.- Returns:
- the end time in milliseconds
-
setEndTime
void setEndTime(double millis) Sets the end time in milliseconds.- Parameters:
millis- the desired end time in milliseconds
-
goToStart
void goToStart()Sets the time to the start time. -
goToEnd
void goToEnd()Sets the time to the end time. -
getFrameCountDurationMS
double getFrameCountDurationMS()Gets the duration of the media, including a time for the last frame From XuggleVideo code, now also for JSMovieVideo// ....[0][1][2]...[startFrame][i]...[j][endFrame]...[frameCount-1] // ....|--------frameCountDurationMS--(nframes * aveDuration)-----| // ....^..^..^..^..^...........^..^..^..^.........^..^ startTimes[i] // ............................|--| frameDuration[i] // ..................................................|------------| // ..................................................frameDuration[frameCoumt-1] // ....|-------------video-specified rawDuration------------------|
- Returns:
- the duration of the media in milliseconds or -1 if no video, or 100 if one frame
-
getAverageFrameDuration
default double getAverageFrameDuration(boolean allowOneFrame) Calculate (last frame start time - first frame start time)/(final frame number - first frame number) when there is more than one frame. If there is just one frame and we allow just one frame, then return the 1/(average frame rate), which is the movie duration divided by the frame count. Note that this does not account for the length of the final frame, should it have one. (Xuggle, for instance, assigns the last frame time as the second-to-last frame time, and JSMovieVideo assigns the remainder of the duration to the final frame time. In addition, since first and last frame are set by the user and may not be the video itself, when there is just one frame selected, this method still returns the average frame duration for the whole video, not the duration of this selected frame. None of this particularly matters for a single frame, because the play button in the Tracker control panel is disabled in that case.- Parameters:
allowOneFrame-- Returns:
-
getRate
double getRate()Gets the rate at which the media plays relative to its normal rate.- Returns:
- the relative play rate. A rate of 1.0 plays at the normal rate.
-
setRate
void setRate(double rate) Sets the rate at which the media plays relative to its normal rate.- Parameters:
rate- the relative play rate. A rate of 1.0 plays at the normal rate.
-
setPlaying
Deprecated.Never called Starts and stops the media.- Parameters:
playing-truestarts the media, andfalsestops it
-
isPlaying
boolean isPlaying()Gets whether the media is playing.- Returns:
trueif the media is playing
-
setLooping
void setLooping(boolean looping) Sets the looping behavior of the media. When true, the media restarts when reaching the end.- Parameters:
looping-trueif the media is looping
-
isLooping
boolean isLooping()Gets the looping behavior of the media. When true, the video restarts when reaching the end.- Returns:
trueif the media is looping
-
invalidateVideoAndFilter
void invalidateVideoAndFilter()Invalidate the video and its filter so that it can be refreshed and so that data can be rebuilt. -
getAverageFrameRate
default double getAverageFrameRate() -
getOutliers
-