- english
- /
- japanese
methods
- close()
- closeMovie()
- draw()
- firstFrame()
- getCurrentFrame()
- getDuration()
- getHeight()
- getIsMovieDone()
- getLoopState()
- getMoviePath()
- getPixelFormat()
- getPixels()
- getPixelsRef()
- getPlayer()
- getPosition()
- getSpeed()
- getTextureReference()
- getTotalNumFrames()
- getWidth()
- idleMovie()
- isFrameNew()
- isLoaded()
- isPaused()
- isPlaying()
- loadMovie()
- nextFrame()
- play()
- previousFrame()
- setFrame()
- setLoopState()
- setPaused()
- setPixelFormat()
- setPlayer()
- setPosition()
- setSpeed()
- setUseTexture()
- setVolume()
- stop()
- update()
variables
The ofVideoPlayer class loads in a movie file via quicktime in windows and OSX or gstreamer in linux, and offers various controls to play the movie, control the properties of the movie, and to access the pixels of a given frame.
Example:
ofVideoPlayer myPlayer;
close()
void ofVideoPlayer::close()
Calls the closeMovie() function, which closes the movie file and de-allocates resources.
closeMovie()
void ofVideoPlayer::closeMovie()
Closes the movie file and de-allocates resources.
Example:
ofVideoPlayer myPlayer;
myPlayer.loadMovie("myMovie.mov"); //Loads video resources
myPlayer.closeMovie(); //Unloads video resources
draw(...)
void ofVideoPlayer::draw(float x, float y, float w, float h)
Draws the texture of the movie player class at the position (x,y) with the given width (w) and height (h).
draw(...)
void ofVideoPlayer::draw(float x, float y)
Draws the texture of the movie player class as the position (x,y) with the internal width and height of the loaded movie.
firstFrame()
void ofVideoPlayer::firstFrame()
Moves the playhead to the first frame of the movie. This can also be accomplished using setCurrentFrame(0).
getDuration()
float ofVideoPlayer::getDuration()
Returns the duration of the movie in seconds as a floating number.
getIsMovieDone()
bool ofVideoPlayer::getIsMovieDone()
Returns whether the movie has played all the way until the end.
getPixels()
unsigned char * ofVideoPlayer::getPixels()
For example, to get the red, green, and blue of the pixel at (100,20):
unsigned char * pixels = myMovie.getPixels();
int widthOfLine = myMovie.width; // how long is a line of pixels
int red = pixels[(20 * widthOfLine) + 100 * 3 ];
int green = pixels[(20 * widthOfLine) + 100 * 3 + 1];
int blue = pixels[(20 * widthOfLine) + 100 * 3 + 2];
getSpeed()
float ofVideoPlayer::getSpeed()
Returns the speed that the movie is being played at as a floating point number. 1 = normal speed, 0 = paused, -1 = backwards.
getTextureReference()
ofTexture ofVideoPlayer::getTextureReference()
Returns a reference to the videoPlayer's texture.
getTotalNumFrames()
int ofVideoPlayer::getTotalNumFrames()
Get the number of frames that the movie file being played contains.
idleMovie()
void ofVideoPlayer::idleMovie()
This function idles the movie player, so that the movie can play. If you don't call it, when the movie is playing then you may encouter problems, especially on winodws machines.
isFrameNew()
bool ofVideoPlayer::isFrameNew()
For example, if the pixels are new, you could then process them.
if (myMovie.isFrameNew()){
// do something
}
loadMovie(...)
bool ofVideoPlayer::loadMovie(string name)
Load a movie file (fileName) into that object. It will look for the movie file inside of the data/ folder. The movie does not automatically play once loaded.
Example:
ofVideoPlayer myPlayer;
myPlayer.loadMovie("myMovie.mov");
play()
void ofVideoPlayer::play()
Plays the movie. If the movie has been stopped or paused it will the continue playback at the point it was stopped.
setFrame(...)
void ofVideoPlayer::setFrame(int frame)
Sets the current frame of the video. Should be used only if you know the bounds of the movie ( using totalNumberFrames() ) or store a location using getCurrentFrame();
setLoopState(...)
void ofVideoPlayer::setLoopState(int state)
Sets the looping state of the movie. Deafult behavior is to loop. There are three options:
OF_LOOP_NONE - don't loop, the movie will stop when it gets to the last frame (or first frame, if playing backwards)
OF_LOOP_NORMAL - loop normally (the last frame loops to the first frame)
OF_LOOP_PALINDROME - loop back and forth
setPaused(...)
void ofVideoPlayer::setPaused(bool bPause)
Sets the paused state of the movie. Use "true" to pause and false to unpause.
setPosition(...)
void ofVideoPlayer::setPosition(float pct)
Sets the position of the playhead to a given percentage through the movie. This can be used to scrub through a movie.
setSpeed(...)
void ofVideoPlayer::setSpeed(float speed)
Sets the speed of the movie that is playing. 1 = normal, 2 = 2x as fast, 0 = stopped, -1 = backwards, etc;
setUseTexture(...)
void ofVideoPlayer::setUseTexture(bool bUse)
Set the usage of texture inside this object. Typically, you will want to draw the movie on screen, and so it will be necessary to use a texture, but there may be cases where it helps to not use a texture in order to save memory or for better performance. To disable the internal use of the texture, you can load the movie like this:
myMovie.setUseTexture(false);
myMovie.loadMovie("blah.mov");
setVolume(...)
void ofVideoPlayer::setVolume(float volume)
Sets the volume of a movie as it plays. The maximum values is 1.0f, 0.0f is silent.
update()
void ofVideoPlayer::update()
Calls the idleMovie() function. This function idles the movie player, so that the movie can play. If you don't call it, when the movie is playing then you may encounter problems, especially on windows machines.
bool allocated
bool ofVideoPlayer::allocated
Boolean varible containing true if the texture has been already allocated inside our video player.
bool bHavePixelsChanged
bool ofVideoPlayer::bHavePixelsChanged
A boolean controlling if pixels have change.
bool bUseTexture
bool ofVideoPlayer::bUseTexture
bUseTexture enables and disables the use of ofTexture in our video player.
unsigned char * pixels
unsigned char * ofVideoPlayer::pixels
Array of pixels that represents the current frame of live video. The data is stored as RGB in an array which is the size: widthheight3.
float speed
float ofVideoPlayer::speed
Contains the playback speed of the video. 1.0 is the normal speed. 2.0 is double the normal speed, -1 is backwards etc.
Last updated
Tuesday, 18 June 2013 17:22:35 UTC
-
b9108c2c3a74b748f90c430e68d4bbb155402a77

