#class ofVideoPlayer ##InlineDescription ##Description 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: ~~~~{.cpp} ofVideoPlayer myPlayer; myPlayer.load("movies/fingers.mov"); ~~~~ You need to call play() for your video to begin playing: ~~~~{.cpp} myPlayer.play(); ~~~~ and update to ensure that you're grabbing new frames from the file as the video library decodes them and serves them up as textures: ~~~~{.cpp} void myApp::update(){ myPlayer.update(); // get all the new frames } ~~~~ Just like the ofImage, the ofVideoPlayer can be drawn: ~~~~{.cpp} myPlayer.draw(20,20); // draw at 20, 20 from the current transform matrix ~~~~ or you can just get the pixels from the player, as we do in the videoGrabberExample in the examples: ~~~~{.cpp} if (vidGrabber.isFrameNew()){ int totalPixels = camWidth*camHeight*3; unsigned char * pixels = vidGrabber.getPixels(); for (int i = 0; i < totalPixels; i++){ videoInverted[i] = 255 - pixels[i]; } texture.loadData(videoInverted, camWidth,camHeight, GL_RGB); } ~~~~ ##Methods ###void bind() _inlined_description: _ Binds the video texture to the current rendering context. For advanced users who need to manually manage texture drawing without calling draw(). Only binds the texture if one exists. **See also**: ofTexture::bind() **See also**: http://www.opengl.org/sdk/docs/man4/html/glBindTexture.xhtml _description: _ ###void close() _inlined_description: _ Closes the movie file releases its resources. This is an alias for closeMovie(). **See also**: closeMovie() _description: _ ###void closeMovie() _inlined_description: _ Closes the movie file and releases its resources. This is an alias for close(). **See also**: close() _description: _ Example: ~~~~{.cpp} ofVideoPlayer myPlayer; myPlayer.loadMovie("myMovie.mov"); //Loads video resources myPlayer.closeMovie(); //Unloads video resources ~~~~ ###void draw(x, y) _inlined_description: _ _description: _ Draws the texture of the movie player class as the position (x,y) with the internal width and height of the loaded movie. ###void draw(x, y, w, h) _inlined_description: _ _description: _ Draws the texture of the movie player class at the position (x,y) with the given width (w) and height (h). ###void firstFrame() _inlined_description: _ _description: _ ###int getCurrentFrame() _inlined_description: _ _description: _ ###float getDuration() _inlined_description: _ _description: _ The getDuration() method returns a _float_ value with the duration in seconds of the movie. ###float getHeight() _inlined_description: _ _description: _ ###bool getIsMovieDone() _inlined_description: _ _description: _ ###ofLoopType getLoopState() _inlined_description: _ _description: _ ###string getMoviePath() _inlined_description: _ Get the path to the loaded video file. If no video file is loaded this returns an empty string. **Returns**: A path to the loaded video or an empty string if not loaded. _description: _ ###ofPixelFormat getPixelFormat() _inlined_description: _ _description: _ ###ofPixels & getPixels() _inlined_description: _ _description: _ For example, to get the red, green, and blue of the pixel at (100,20): ~~~~{.cpp} unsigned char * pixels = myMovie.getPixels(); int nChannels = movie.getPixelsRef().getNumChannels(); int widthOfLine = myMovie.width; // how long is a line of pixels int red = pixels[(20 * widthOfLine + 100) * nChannels ]; int green = pixels[(20 * widthOfLine + 100) * nChannels + 1]; int blue = pixels[(20 * widthOfLine + 100) * nChannels + 2]; ~~~~ ###const ofPixels & getPixels() _inlined_description: _ _description: _ ###shared_ptr< ofBaseVideoPlayer > getPlayer() _inlined_description: _ Get a pointer to the internal video player implementation. This returns a pointer to the ofBaseVideoPlayer interface. For implementation-specfic features, this can be cast to the subtype using dynamic_cast(getPlayer()) or the templated getPlayer() method. **Returns**: A pointer to the internal video player implementation. _description: _ ###const shared_ptr< ofBaseVideoPlayer > getPlayer() _inlined_description: _ Get a const pointer to the internal video player implementation. This returns a pointer to the ofBaseVideoPlayer interface. For implementation-specfic features, this can be cast to the subtype using dynamic_pointer_cast(getPlayer()) or the templated getPlayer() method. **Returns**: A const pointer to the internal video player implementation. _description: _ ###shared_ptr< PlayerType > getPlayer() _inlined_description: _ Get a pointer to the internal video player implementation. Calling getPlayer() is equivalent to dynamic_pointer_cast(getPlayer()). **Returns**: A pointer to the internal video player implementation or nullptr if the cast fails. _description: _ ###const shared_ptr< PlayerType > getPlayer() _inlined_description: _ Get a const pointer to the internal video player implementation. Calling getPlayer() is equivalent to dynamic_pointer_cast(getPlayer()). **Returns**: A const pointer to the internal video player implementation or nullptr if the cast fails. _description: _ ###float getPosition() _inlined_description: _ _description: _ The getPosition() method returns a _float_ value between 0 and 1 with the relative position in the movie. A return value of _0_ means the start point in the movie, a return value of _1_ means the end of the movie. Example: ~~~~{.cpp} void main() { myPlayer.load("movies/fingers.mov"); } void update() { myPlayer.update(); } void draw() { ofLogNotice() << "The movie is playing the " << (myPlayer.getPosition() * 100) << "%"; ofLogNotice() << "The movie is in the following time in secs: " << myPlayer.getPosition()*myPlayer.getDuration(); } ~~~~ ###float getSpeed() _inlined_description: _ _description: _ ###ofTexture & getTexture() _inlined_description: _ _description: _ ###const ofTexture & getTexture() _inlined_description: _ _description: _ ###int & getTexturePlanes() _inlined_description: _ _description: _ ###const int & getTexturePlanes() _inlined_description: _ _description: _ ###int getTotalNumFrames() _inlined_description: _ _description: _ ###float getWidth() _inlined_description: _ _description: _ ###void initDefaultPlayer() _inlined_description: _ Initialize the default player implementations. _description: _ ###bool isFrameNew() _inlined_description: _ _description: _ This gets whether there are new pixels in your movies player. This is a way to poll the library that's actually reading your video file to see whether there's something new: For example, if the pixels are new, you could then process them. ~~~~{.cpp} if (myMovie.isFrameNew()){ ofPixels p = myPlayer.getPixelsRef(); // walk over each pixel and make something fun } ~~~~ ###bool isInitialized() _inlined_description: _ _description: _ ###bool isLoaded() _inlined_description: _ _description: _ Whether the resources that you've tried to load into your ofVideoPlayer have been loaded yet. ###bool isPaused() _inlined_description: _ _description: _ Whether the the ofVideoPlayer is currently paused. ###bool isPlaying() _inlined_description: _ _description: _ Whether the the ofVideoPlayer is currently playing. ###bool isUsingTexture() _inlined_description: _ _description: _ ###bool load(name) _inlined_description: _ _description: _ ###void loadAsync(name) _inlined_description: _ _description: _ ###void nextFrame() _inlined_description: _ _description: _ ### ofVideoPlayer() _inlined_description: _ _description: _ Constructor. ###void play() _inlined_description: _ _description: _ ###void previousFrame() _inlined_description: _ _description: _ ###void resetAnchor() _inlined_description: _ _description: _ Resets the ancher point of this ofVideoPlayer, if one has been set. ###void setAnchorPercent(xPct, yPct) _inlined_description: _ _description: _ Sets an anchor percentage for this ofVideoPlayer instance ###void setAnchorPoint(x, y) _inlined_description: _ _description: _ Sets anchor points for this ofVideoPlayer instance. ###void setFrame(frame) _inlined_description: _ _description: _ ###void setLoopState(state) _inlined_description: _ _description: _ ~~~~{.cpp} 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. Movie will play forward until it gets to the last frame, then plays backwards until it gets to the first frame, and so on. ~~~~ ###void setPaused(bPause) _inlined_description: _ _description: _ ###bool setPixelFormat(pixelFormat) _inlined_description: _ _description: _ OSX: Choose from OF_PIXELS_RGB or OF_PIXELS_RGBA ###void setPlayer(newPlayer) _inlined_description: _ Set the internal video player implementation. Advanced users may find it useful to set a custom internal video player implementation. The custom video player must implment the ofBaseVideoPlayer interface. **Parameters:** newPlayer Shared pointer to the new video player that extends from ofBaseVideoPlayer. _description: _ ###void setPosition(pct) _inlined_description: _ _description: _ Sets the position of the playhead to a given percentage through the movie. This can be used to scrub through a movie. ###void setSpeed(speed) _inlined_description: _ _description: _ ###void setUseTexture(bUse) _inlined_description: _ _description: _ 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: ~~~~{.cpp} myMovie.setUseTexture(false); myMovie.loadMovie("blah.mov"); ~~~~ ###void setVolume(volume) _inlined_description: _ _description: _ ###void stop() _inlined_description: _ _description: _ ###void unbind() _inlined_description: _ Unbinds the video texture from the current rendering context. For advanced users who need to manually manage texture drawing without calling draw(). Only binds the texture if one exists. **See also**: ofTexture::unbind() _description: _ ###void update() _inlined_description: _ Update the video player's internal state to continue playback. If normal video playback is desired, this method is usually called once per animation frame inside of ofApp::update(). _description: _ ##Variables ###bool bUseTexture _inlined_description: _ True if the video player is using a texture. _description: _ ###ofPixelFormat internalPixelFormat _inlined_description: _ The internal pixel format. _description: _ ###string moviePath _inlined_description: _ The stored path to the video's path. _description: _ ###ofPtr player _inlined_description: _ A pointer to the internal video player implementation. _description: _ ###ofTexture * playerTex _inlined_description: _ A pointer to the internal player's texture if available. Video players that implement ofBaseVideoPlayer::getTexturePtr() can provide a pointer to an internal texture. When possible, ofVideoPlayer will use the internal texture to avoid extra pixel copies. _description: _ ###ofTexture tex _inlined_description: _ A collection of texture planes used by the video player. _description: _