There are a number of additional functions in ofVideoPlayer
for controlling video playing and positioning:
stop()
function is used to stop playing the video.setPaused( bPause )
function sets/resets pause of video playing, where bPause
has type bool
. If you pause the video, you can still switch its frames using the setFrame()
or setPosition()
function. It is extremely useful for the exact frame number control.setPosition( pos )
function sets playing position in file, where pos
is a float number in range [0, 1]
.setFrame( frame )
function sets current frame to frame
, where frame
is an integer value from 0
to video. getTotalNumFrames() - 1
.getCurrentFrame()
function returns current frame number.getTotalNumFrames()
function returns number of frames in video.getDuration()
function returns internal duration of video in seconds as a float number.isLoaded()
function returns true
if video is successfully loaded, this can be used for handling errors like a mistake in filename.isPaused()
and isPlaying()
functions return value of type bool
on pausing and playing state correspondingly.getIsMovieDone()
function returns true
when the last frame of the video is achieved.You can freely change the speed of playing using the following functions:
setSpeed( speed )
function where speed
is a float value. Value 1.0
means the normal video speed and value 2.0
means the double speed. Negative speed plays the video backwards; for example, value -1.0
means backward playing with normal speed.getSpeed()
function returns float value equal to the current playing speed.Please note that you can change the speed continuously. It is an important feature for adding lifelikeness to the video backgrounds. For example, if you are playing a video of a rotating mill, you can slowly change the speed of the video to simulate wind changes using Perlin noise. See Appendix B, Perlin Noise, for more details.
For creating nonstop playing videos, it is possible to set up and control the loop mode using the following functions:
setLoopState( state )
function sets the looping mode, where state can be one of the three values:OF_LOOP_NONE
: Looping is disabled and playing stops when the video reaches the last frame.OF_LOOP_NORMAL
: When playing reaches the last frame, it jumps to the first frame. This is default loop state.OF_LOOP_PALINDROME
: Also known as ping-pong looping, this loop goes forward and backward infinitely, and is good for creating a smooth "infinite video" from any video piece.getLoopState()
function returns the current loop mode.If the video contains an audio track, you can adjust its playing volume, changing it using the setVolume( volume )
method, where volume is a float number in range [0, 1]
.