reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofVideoPlayer Class Reference

#include <ofVideoPlayer.h>

Inheritance diagram for ofVideoPlayer:
ofBaseVideoDraws ofBaseVideo ofBaseDraws ofBaseHasTexturePlanes ofBaseHasPixels_< unsigned char > ofBaseUpdates ofBaseHasTexture ofAbstractHasPixels

Public Member Functions

 ofVideoPlayer ()
 
bool load (std::string name)
 
void loadAsync (std::string name)
 
 OF_DEPRECATED_MSG ("Use load instead", bool loadMovie(std::string name))
 
std::string getMoviePath () const
 Get the path to the loaded video file.
 
bool setPixelFormat (ofPixelFormat pixelFormat)
 Set the requested ofPixelFormat.
 
ofPixelFormat getPixelFormat () const
 
void closeMovie ()
 Closes the movie file and releases its resources.
 
void close ()
 Closes the movie file releases its resources.
 
void update ()
 Update the video player's internal state to continue playback.
 
void play ()
 
void stop ()
 
bool isFrameNew () const
 
ofPixelsgetPixels ()
 Get a reference to the underlying ofPixels.
 
const ofPixelsgetPixels () const
 Get a const reference to the underlying ofPixels.
 
 OF_DEPRECATED_MSG ("Use getPixels() instead", ofPixels &getPixelsRef())
 
 OF_DEPRECATED_MSG ("Use getPixels() instead", const ofPixels &getPixelsRef() const)
 
float getPosition () const
 
float getSpeed () const
 
float getDuration () const
 
bool getIsMovieDone () const
 
void setPosition (float pct)
 
void setVolume (float volume)
 
void setLoopState (ofLoopType state)
 
ofLoopType getLoopState () const
 
void setSpeed (float speed)
 
void setFrame (int frame)
 
void setUseTexture (bool bUse)
 Enable or disable internal ofTexture use.
 
bool isUsingTexture () const
 
ofTexturegetTexture ()
 
const ofTexturegetTexture () const
 
 OF_DEPRECATED_MSG ("Use getTexture", ofTexture &getTextureReference())
 
 OF_DEPRECATED_MSG ("Use getTexture", const ofTexture &getTextureReference() const)
 
std::vector< ofTexture > & getTexturePlanes ()
 
const std::vector< ofTexture > & getTexturePlanes () const
 
void draw (float x, float y, float w, float h) const
 Draw at a position with the specified size.
 
void draw (float x, float y) const
 Draw at a position at the native size.
 
void bind () const
 Binds the video texture to the current rendering context.
 
void unbind () const
 Unbinds the video texture from the current rendering context.
 
void setAnchorPercent (float xPct, float yPct)
 Set the anchor point the item is drawn around as a percentage.
 
void setAnchorPoint (float x, float y)
 Set the anchor point the item is drawn around in pixels.
 
void resetAnchor ()
 Reset the anchor point to (0, 0).
 
void setPaused (bool bPause)
 
int getCurrentFrame () const
 
int getTotalNumFrames () const
 
void firstFrame ()
 
void nextFrame ()
 
void previousFrame ()
 
float getHeight () const
 Get the height.
 
float getWidth () const
 Get the width.
 
bool isPaused () const
 
bool isLoaded () const
 
bool isPlaying () const
 
bool isInitialized () const
 Determine if the video source is initialized.
 
void setPlayer (std::shared_ptr< ofBaseVideoPlayer > newPlayer)
 Set the internal video player implementation.
 
std::shared_ptr< ofBaseVideoPlayergetPlayer ()
 Get a pointer to the internal video player implementation.
 
const std::shared_ptr< ofBaseVideoPlayergetPlayer () const
 Get a const pointer to the internal video player implementation.
 
template<typename PlayerType >
std::shared_ptr< PlayerType > getPlayer ()
 Get a pointer to the internal video player implementation.
 
template<typename PlayerType >
const std::shared_ptr< PlayerType > getPlayer () const
 Get a const pointer to the internal video player implementation.
 
virtual void draw (float x, float y) const
 Draw at a position at the native size.
 
virtual void draw (float x, float y, float w, float h) const=0
 Draw at a position with the specified size.
 
virtual void draw (const glm::vec2 &point) const
 Draw at a position at the native size.
 
virtual void draw (const ofRectangle &rect) const
 Draw at a position and size specified by a rectangle.
 
virtual void draw (const glm::vec2 &point, float w, float h) const
 Draw at a position.
 
- Public Member Functions inherited from ofBaseVideoDraws
virtual ~ofBaseVideoDraws ()
 Destroy the ofBaseVideoDraws.
 
- Public Member Functions inherited from ofBaseVideo
virtual ~ofBaseVideo ()
 Destroy the ofBaseVideo.
 
- Public Member Functions inherited from ofBaseHasPixels_< unsigned char >
virtual ~ofBaseHasPixels_ ()
 Destroy the ofAbstractHasPixels.
 
- Public Member Functions inherited from ofAbstractHasPixels
virtual ~ofAbstractHasPixels ()
 Destroy the ofAbstractHasPixels.
 
- Public Member Functions inherited from ofBaseUpdates
virtual ~ofBaseUpdates ()
 Destroy the ofBaseUpdates.
 
- Public Member Functions inherited from ofBaseDraws
virtual ~ofBaseDraws ()
 Destroy the abstract object.
 
- Public Member Functions inherited from ofBaseHasTexturePlanes
virtual ~ofBaseHasTexturePlanes ()
 Destroy the ofBaseHasTexturePlanes.
 
- Public Member Functions inherited from ofBaseHasTexture
virtual ~ofBaseHasTexture ()
 Destroy the ofBaseHasTexture.
 

Constructor & Destructor Documentation

◆ ofVideoPlayer()

ofVideoPlayer::ofVideoPlayer ( )

Member Function Documentation

◆ bind()

void ofVideoPlayer::bind ( ) const

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()
http://www.opengl.org/sdk/docs/man4/html/glBindTexture.xhtml

◆ close()

void ofVideoPlayer::close ( )
virtual

Closes the movie file releases its resources.

This is an alias for closeMovie().

See also
closeMovie()

Implements ofBaseVideo.

◆ closeMovie()

void ofVideoPlayer::closeMovie ( )

Closes the movie file and releases its resources.

This is an alias for close().

See also
close()

◆ draw() [1/7]

void ofBaseDraws::draw ( const glm::vec2 &  point) const
virtual

Draw at a position at the native size.

Native size is determined by getWidth() and getHeight().

Parameters
pointDraw position.

Reimplemented from ofBaseDraws.

◆ draw() [2/7]

void ofBaseDraws::draw ( const glm::vec2 &  point,
float  w,
float  h 
) const
virtual

Draw at a position.

Parameters
pointDraw position.
wDraw width.
hDraw height.

Reimplemented from ofBaseDraws.

◆ draw() [3/7]

void ofBaseDraws::draw ( const ofRectangle rect) const
virtual

Draw at a position and size specified by a rectangle.

Parameters
rectDraw position and size.

Reimplemented from ofBaseDraws.

◆ draw() [4/7]

void ofVideoPlayer::draw ( float  x,
float  y 
) const
virtual

Draw at a position at the native size.

Native size is determined by getWidth() and getHeight().

Parameters
xDraw position on the x axis.
yDraw position on the y axis.

Reimplemented from ofBaseDraws.

◆ draw() [5/7]

virtual void ofBaseDraws::draw ( float  x,
float  y 
) const
inlinevirtual

Draw at a position at the native size.

Native size is determined by getWidth() and getHeight().

Parameters
xDraw position on the x axis.
yDraw position on the y axis.

Reimplemented from ofBaseDraws.

◆ draw() [6/7]

void ofVideoPlayer::draw ( float  x,
float  y,
float  w,
float  h 
) const
virtual

Draw at a position with the specified size.

Parameters
xDraw position on the x axis.
yDraw position on the y axis.
wDraw width.
hDraw height.

Implements ofBaseDraws.

◆ draw() [7/7]

virtual void ofBaseDraws::draw ( float  x,
float  y,
float  w,
float  h 
) const
virtual

Draw at a position with the specified size.

Parameters
xDraw position on the x axis.
yDraw position on the y axis.
wDraw width.
hDraw height.

Implements ofBaseDraws.

◆ firstFrame()

void ofVideoPlayer::firstFrame ( )

◆ getCurrentFrame()

int ofVideoPlayer::getCurrentFrame ( ) const

◆ getDuration()

float ofVideoPlayer::getDuration ( ) const

◆ getHeight()

float ofVideoPlayer::getHeight ( ) const
virtual

Get the height.

Returns
the height.

Implements ofBaseDraws.

◆ getIsMovieDone()

bool ofVideoPlayer::getIsMovieDone ( ) const

◆ getLoopState()

ofLoopType ofVideoPlayer::getLoopState ( ) const

◆ getMoviePath()

string ofVideoPlayer::getMoviePath ( ) const

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.

◆ getPixelFormat()

ofPixelFormat ofVideoPlayer::getPixelFormat ( ) const
virtual
Returns
the current ofPixelFormat.

Implements ofBaseVideo.

◆ getPixels() [1/2]

ofPixels & ofVideoPlayer::getPixels ( )
virtual

Get a reference to the underlying ofPixels.

Returns
a reference the underlying ofPixels.

Implements ofBaseHasPixels_< unsigned char >.

◆ getPixels() [2/2]

const ofPixels & ofVideoPlayer::getPixels ( ) const
virtual

Get a const reference to the underlying ofPixels.

Returns
a const reference the underlying ofPixels.

Implements ofBaseHasPixels_< unsigned char >.

◆ getPlayer() [1/4]

shared_ptr< ofBaseVideoPlayer > ofVideoPlayer::getPlayer ( )

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<MyVideoPlayerImplementation>(getPlayer()) or the templated getPlayer<MyVideoPlayerImplementation>() method.

Returns
A pointer to the internal video player implementation.

◆ getPlayer() [2/4]

template<typename PlayerType >
std::shared_ptr< PlayerType > ofVideoPlayer::getPlayer ( )
inline

Get a pointer to the internal video player implementation.

Calling getPlayer<MyVideoPlayerImplementation>() is equivalent to dynamic_pointer_cast<MyVideoPlayerImplementation>(getPlayer()).

Returns
A pointer to the internal video player implementation or nullptr if the cast fails.

◆ getPlayer() [3/4]

const shared_ptr< ofBaseVideoPlayer > ofVideoPlayer::getPlayer ( ) const

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<MyVideoPlayerImplementation>(getPlayer()) or the templated getPlayer<MyVideoPlayerImplementation>() method.

Returns
A const pointer to the internal video player implementation.

◆ getPlayer() [4/4]

template<typename PlayerType >
const std::shared_ptr< PlayerType > ofVideoPlayer::getPlayer ( ) const
inline

Get a const pointer to the internal video player implementation.

Calling getPlayer<MyVideoPlayerImplementation>() is equivalent to dynamic_pointer_cast<MyVideoPlayerImplementation>(getPlayer()).

Returns
A const pointer to the internal video player implementation or nullptr if the cast fails.

◆ getPosition()

float ofVideoPlayer::getPosition ( ) const

◆ getSpeed()

float ofVideoPlayer::getSpeed ( ) const

◆ getTexture() [1/2]

ofTexture & ofVideoPlayer::getTexture ( )
virtual
Returns
a reference to the ofTexture.

Implements ofBaseHasTexture.

◆ getTexture() [2/2]

const ofTexture & ofVideoPlayer::getTexture ( ) const
virtual
Returns
a const reference to the ofTexture.

Implements ofBaseHasTexture.

◆ getTexturePlanes() [1/2]

vector< ofTexture > & ofVideoPlayer::getTexturePlanes ( )
virtual
Returns
a reference to a std::vector containing the ofTexture planes.

Implements ofBaseHasTexturePlanes.

◆ getTexturePlanes() [2/2]

const vector< ofTexture > & ofVideoPlayer::getTexturePlanes ( ) const
virtual
Returns
a const reference to a std::vector containing the ofTexture planes.

Implements ofBaseHasTexturePlanes.

◆ getTotalNumFrames()

int ofVideoPlayer::getTotalNumFrames ( ) const

◆ getWidth()

float ofVideoPlayer::getWidth ( ) const
virtual

Get the width.

Returns
the width.

Implements ofBaseDraws.

◆ isFrameNew()

bool ofVideoPlayer::isFrameNew ( ) const
virtual
Returns
true if the pixel data was updated since the last call to update().

Implements ofBaseVideo.

◆ isInitialized()

bool ofVideoPlayer::isInitialized ( ) const
virtual

Determine if the video source is initialized.

Video sources such as cameras are often initialized with a setup() method. Video sources such as movie players are often initialized with a load() method.

Returns
true if the video source is initialized.

Implements ofBaseVideo.

◆ isLoaded()

bool ofVideoPlayer::isLoaded ( ) const

◆ isPaused()

bool ofVideoPlayer::isPaused ( ) const

◆ isPlaying()

bool ofVideoPlayer::isPlaying ( ) const

◆ isUsingTexture()

bool ofVideoPlayer::isUsingTexture ( ) const
virtual
Returns
true if an internal ofTexture is being used.

Implements ofBaseHasTexture.

◆ load()

bool ofVideoPlayer::load ( std::string  name)

◆ loadAsync()

void ofVideoPlayer::loadAsync ( std::string  name)

◆ nextFrame()

void ofVideoPlayer::nextFrame ( )

◆ OF_DEPRECATED_MSG() [1/5]

ofVideoPlayer::OF_DEPRECATED_MSG ( "Use getPixels() instead"  ,
const ofPixels &getPixelsRef() const   
)

◆ OF_DEPRECATED_MSG() [2/5]

ofVideoPlayer::OF_DEPRECATED_MSG ( "Use getPixels() instead"  ,
ofPixels getPixelsRef() 
)

◆ OF_DEPRECATED_MSG() [3/5]

ofVideoPlayer::OF_DEPRECATED_MSG ( "Use getTexture"  ,
const ofTexture &getTextureReference() const   
)

◆ OF_DEPRECATED_MSG() [4/5]

ofVideoPlayer::OF_DEPRECATED_MSG ( "Use getTexture"  ,
ofTexture getTextureReference() 
)

◆ OF_DEPRECATED_MSG() [5/5]

ofVideoPlayer::OF_DEPRECATED_MSG ( "Use load instead"  ,
bool   loadMoviestd::string name 
)

◆ play()

void ofVideoPlayer::play ( )

◆ previousFrame()

void ofVideoPlayer::previousFrame ( )

◆ resetAnchor()

void ofVideoPlayer::resetAnchor ( )
virtual

Reset the anchor point to (0, 0).

Reimplemented from ofBaseDraws.

◆ setAnchorPercent()

void ofVideoPlayer::setAnchorPercent ( float  xPct,
float  yPct 
)
virtual

Set the anchor point the item is drawn around as a percentage.

This can be useful if you want to rotate an image around a particular point.

Parameters
xPctHorizontal position as a percentage (0 - 1).
yPctVertical position as a percentage (0 - 1).

Reimplemented from ofBaseDraws.

◆ setAnchorPoint()

void ofVideoPlayer::setAnchorPoint ( float  x,
float  y 
)
virtual

Set the anchor point the item is drawn around in pixels.

This can be useful if you want to rotate an image around a particular point.

Parameters
xHorizontal texture position in pixels.
yVertical texture position in pixels.

Reimplemented from ofBaseDraws.

◆ setFrame()

void ofVideoPlayer::setFrame ( int  frame)

◆ setLoopState()

void ofVideoPlayer::setLoopState ( ofLoopType  state)

◆ setPaused()

void ofVideoPlayer::setPaused ( bool  bPause)

◆ setPixelFormat()

bool ofVideoPlayer::setPixelFormat ( ofPixelFormat  pixelFormat)
virtual

Set the requested ofPixelFormat.

Parameters
pixelFormatthe requested ofPixelFormat.
Returns
true if the format was successfully changed.

Implements ofBaseVideo.

◆ setPlayer()

void ofVideoPlayer::setPlayer ( std::shared_ptr< ofBaseVideoPlayer newPlayer)

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
newPlayerShared pointer to the new video player that extends from ofBaseVideoPlayer.

◆ setPosition()

void ofVideoPlayer::setPosition ( float  pct)

◆ setSpeed()

void ofVideoPlayer::setSpeed ( float  speed)

◆ setUseTexture()

void ofVideoPlayer::setUseTexture ( bool  bUseTex)
virtual

Enable or disable internal ofTexture use.

Parameters
bUseTextrue if an ofTexture should be used.

Implements ofBaseHasTexture.

◆ setVolume()

void ofVideoPlayer::setVolume ( float  volume)

◆ stop()

void ofVideoPlayer::stop ( )

◆ unbind()

void ofVideoPlayer::unbind ( ) const

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()

◆ update()

void ofVideoPlayer::update ( )
virtual

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().

Implements ofBaseUpdates.


The documentation for this class was generated from the following files: