reference

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

#include <ofAVFoundationPlayer.h>

Inheritance diagram for ofAVFoundationPlayer:
ofBaseVideoPlayer ofBaseVideo ofBaseHasPixels_< unsigned char > ofBaseUpdates ofAbstractHasPixels

Public Member Functions

 ofAVFoundationPlayer ()
 
 ~ofAVFoundationPlayer ()
 
bool load (std::string name)
 Load a video resource by name.
 
void loadAsync (std::string name)
 Asynchronously load a video resource by name.
 
void close ()
 Close the video source.
 
void update ()
 Update the object's state.
 
void draw ()
 
void draw (float x, float y)
 
void draw (const ofRectangle &rect)
 
void draw (float x, float y, float w, float h)
 
bool setPixelFormat (ofPixelFormat pixelFormat)
 Set the requested ofPixelFormat.
 
ofPixelFormat getPixelFormat () const
 
void play ()
 Play the video from the current playhead position.
 
void stop ()
 Pause and reset the playhead position to the first frame.
 
bool isFrameNew () const
 
const ofPixelsgetPixels () const
 Get a const reference to the underlying ofPixels.
 
ofPixelsgetPixels ()
 Get a reference to the underlying ofPixels.
 
ofTexturegetTexturePtr ()
 Get a pointer to the video texture used internally if it exists.
 
void initTextureCache ()
 
void killTexture ()
 
void killTextureCache ()
 
float getWidth () const
 Get the width in pixels of the loaded video.
 
float getHeight () const
 Get the height in pixels of the loaded video.
 
bool isPaused () const
 Returns true if the video is paused.
 
bool isLoaded () const
 Returns true if a video is loaded.
 
bool isPlaying () const
 Returns true if the loaded video is playing.
 
float getPosition () const
 Get the current playhead position of the loaded video.
 
float getSpeed () const
 Get the playback speed of the video player.
 
float getDuration () const
 Get the duration of the loaded video in seconds.
 
bool getIsMovieDone () const
 Returns true if the loaded video has finished playing.
 
void setPaused (bool bPause)
 Set the paused state of the video.
 
void setPosition (float pct)
 Set the position of the playhead.
 
void setVolume (float volume)
 Set the volume of the video player.
 
void setLoopState (ofLoopType state)
 Set the video loop state.
 
void setSpeed (float speed)
 Set the video playback speed.
 
void setFrame (int frame)
 Set the current frame by frame number.
 
int getCurrentFrame () const
 Get the current playhead position as a frame number.
 
int getTotalNumFrames () const
 Get the total number of frames in the currently loaded video.
 
ofLoopType getLoopState () const
 Get the current loop state of the video.
 
void firstFrame ()
 Set the playhead position to the first frame.
 
void nextFrame ()
 Advance the playhead forward one frame.
 
void previousFrame ()
 Advance the playhead backward one frame.
 
ofAVFoundationPlayeroperator= (ofAVFoundationPlayer other)
 
void * getAVFoundationVideoPlayer ()
 
 OF_DEPRECATED_MSG ("ofAVFoundationPlayer::loadMovie() is deprecated, use load() instead.", bool loadMovie(std::string name))
 
 OF_DEPRECATED_MSG ("ofAVFoundationPlayer::getPixelsRef() is deprecated, use getPixels() instead.", ofPixels &getPixelsRef())
 
 OF_DEPRECATED_MSG ("ofAVFoundationPlayer::getPixelsRef() is deprecated, use getPixels() instead.", const ofPixels &getPixelsRef() const)
 
 OF_DEPRECATED_MSG ("ofAVFoundationPlayer::getTexture() is deprecated, use getTexturePtr() instead.", ofTexture *getTexture())
 
- Public Member Functions inherited from ofBaseVideoPlayer
virtual ~ofBaseVideoPlayer ()
 Destroys the ofBaseVideoPlayer.
 
virtual bool isInitialized () const
 Returns true if a video is loaded.
 
- 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.
 

Protected Member Functions

bool loadPlayer (std::string name, bool bAsync)
 
void disposePlayer ()
 
bool isReady () const
 

Protected Attributes

void * videoPlayer
 
bool bFrameNew
 
bool bResetPixels
 
bool bUpdatePixels
 
bool bUpdateTexture
 
bool bUseTextureCache
 
ofPixels pixels
 
ofPixelFormat pixelFormat
 
ofTexture videoTexture
 

Constructor & Destructor Documentation

◆ ofAVFoundationPlayer()

ofAVFoundationPlayer::ofAVFoundationPlayer ( )

◆ ~ofAVFoundationPlayer()

ofAVFoundationPlayer::~ofAVFoundationPlayer ( )

Member Function Documentation

◆ close()

void ofAVFoundationPlayer::close ( )
virtual

Close the video source.

Implements ofBaseVideo.

◆ disposePlayer()

void ofAVFoundationPlayer::disposePlayer ( )
protected

◆ draw() [1/4]

void ofAVFoundationPlayer::draw ( )

◆ draw() [2/4]

void ofAVFoundationPlayer::draw ( const ofRectangle rect)

◆ draw() [3/4]

void ofAVFoundationPlayer::draw ( float  x,
float  y 
)

◆ draw() [4/4]

void ofAVFoundationPlayer::draw ( float  x,
float  y,
float  w,
float  h 
)

◆ firstFrame()

void ofAVFoundationPlayer::firstFrame ( )
virtual

Set the playhead position to the first frame.

This is functionally equivalent to setFrame(0) or setPosition(0.0).

Reimplemented from ofBaseVideoPlayer.

◆ getAVFoundationVideoPlayer()

void * ofAVFoundationPlayer::getAVFoundationVideoPlayer ( )

◆ getCurrentFrame()

int ofAVFoundationPlayer::getCurrentFrame ( ) const
virtual

Get the current playhead position as a frame number.

Returns
The current playhead position as a frame number.

Reimplemented from ofBaseVideoPlayer.

◆ getDuration()

float ofAVFoundationPlayer::getDuration ( ) const
virtual

Get the duration of the loaded video in seconds.

Returns
The duration of the loaded video in seconds.

Reimplemented from ofBaseVideoPlayer.

◆ getHeight()

float ofAVFoundationPlayer::getHeight ( ) const
virtual

Get the height in pixels of the loaded video.

Returns
The height in pixels of the loaded video or 0 if none is loaded.

Implements ofBaseVideoPlayer.

◆ getIsMovieDone()

bool ofAVFoundationPlayer::getIsMovieDone ( ) const
virtual

Returns true if the loaded video has finished playing.

Returns
True if the loaded video has finished playing.

Reimplemented from ofBaseVideoPlayer.

◆ getLoopState()

ofLoopType ofAVFoundationPlayer::getLoopState ( ) const
virtual

Get the current loop state of the video.

See also
ofLoopType

Reimplemented from ofBaseVideoPlayer.

◆ getPixelFormat()

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

Implements ofBaseVideo.

◆ getPixels() [1/2]

ofPixels & ofAVFoundationPlayer::getPixels ( )
virtual

Get a reference to the underlying ofPixels.

Returns
a reference the underlying ofPixels.

Implements ofBaseHasPixels_< unsigned char >.

◆ getPixels() [2/2]

const ofPixels & ofAVFoundationPlayer::getPixels ( ) const
virtual

Get a const reference to the underlying ofPixels.

Returns
a const reference the underlying ofPixels.

Implements ofBaseHasPixels_< unsigned char >.

◆ getPosition()

float ofAVFoundationPlayer::getPosition ( ) const
virtual

Get the current playhead position of the loaded video.

This value is a normalized floating point value between 0.0 and 1.0 that represents the position of the playhead. 0.0 maps to the first frame of the loaded video and 1.0 maps to the last frame of the loaded video.

Returns
A value between 0.0 and 1.0 representing playhead position.

Reimplemented from ofBaseVideoPlayer.

◆ getSpeed()

float ofAVFoundationPlayer::getSpeed ( ) const
virtual

Get the playback speed of the video player.

When the loop state is OF_LOOP_NONE or OF_LOOP_NORMAL, positive speed will scale a forward playback rate while a negative speed will scale a a backward playback rate. When the loop state is OF_LOOP_PALINDROME, the direction of playback will change each loop, but the playback rate will still be scaled by the absolute value of the speed.

Returns
The playback speed of the video player.

Reimplemented from ofBaseVideoPlayer.

◆ getTexturePtr()

ofTexture * ofAVFoundationPlayer::getTexturePtr ( )
virtual

Get a pointer to the video texture used internally if it exists.

If the video player implementation supports direct-to-texture rendering, this method will return a pointer to the internal texture. If direct-to-texture rendering is not supported, nullptr is returned.

Returns
A valid pointer to the internal texture, otherwise a nullptr.

Reimplemented from ofBaseVideoPlayer.

◆ getTotalNumFrames()

int ofAVFoundationPlayer::getTotalNumFrames ( ) const
virtual

Get the total number of frames in the currently loaded video.

Returns
The total number of frames in the currently loaded video.

Reimplemented from ofBaseVideoPlayer.

◆ getWidth()

float ofAVFoundationPlayer::getWidth ( ) const
virtual

Get the width in pixels of the loaded video.

Returns
The width in pixels of the loaded video or 0 if none is loaded.

Implements ofBaseVideoPlayer.

◆ initTextureCache()

void ofAVFoundationPlayer::initTextureCache ( )

video texture cache is available. this means we don't have to copy any pixels, and we can reuse the already existing video texture. this is very fast! :)

CVOpenGLESTextureCache does this operation for us. it automatically returns a texture reference which means we don't have to create the texture ourselves. this creates a slight problem because when we create an ofTexture objects, it also creates a opengl texture for us, which is unecessary in this case because the texture already exists. so... we can use ofTexture::setUseExternalTextureID() to get around this.

◆ isFrameNew()

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

Implements ofBaseVideo.

◆ isLoaded()

bool ofAVFoundationPlayer::isLoaded ( ) const
virtual

Returns true if a video is loaded.

This is helpful when loading a video with loadAsync(). This is also an alias of isInitialized().

See also
loadAsync()
Returns
True if a video is loaded.

Implements ofBaseVideoPlayer.

◆ isPaused()

bool ofAVFoundationPlayer::isPaused ( ) const
virtual

Returns true if the video is paused.

Returns
True if the video is paused.

Implements ofBaseVideoPlayer.

◆ isPlaying()

bool ofAVFoundationPlayer::isPlaying ( ) const
virtual

Returns true if the loaded video is playing.

Returns
True if the loaded video is playing.

Implements ofBaseVideoPlayer.

◆ isReady()

bool ofAVFoundationPlayer::isReady ( ) const
protected

◆ killTexture()

void ofAVFoundationPlayer::killTexture ( )

◆ killTextureCache()

void ofAVFoundationPlayer::killTextureCache ( )

◆ load()

bool ofAVFoundationPlayer::load ( std::string  name)
virtual

Load a video resource by name.

The list of supported video types and sources (e.g. rtsp:// sources) is implementation dependent.

Parameters
nameThe name of the video resource to load.
Returns
True if the video was loaded successfully.
See also
loadAsync()

Implements ofBaseVideoPlayer.

◆ loadAsync()

void ofAVFoundationPlayer::loadAsync ( std::string  name)
virtual

Asynchronously load a video resource by name.

The list of supported video types and sources (e.g. rtsp:// sources) is implementation dependent.

When this method is used to load a video resouce, users can determine when the video is loaded by calling isLoaded().

Parameters
nameThe name of the video resource to load.
See also
isLoaded()

Reimplemented from ofBaseVideoPlayer.

◆ loadPlayer()

bool ofAVFoundationPlayer::loadPlayer ( std::string  name,
bool  bAsync 
)
protected

◆ nextFrame()

void ofAVFoundationPlayer::nextFrame ( )
virtual

Advance the playhead forward one frame.

This allows the user to advance through the video manually one frame at a time without calling play().

Reimplemented from ofBaseVideoPlayer.

◆ OF_DEPRECATED_MSG() [1/4]

ofAVFoundationPlayer::OF_DEPRECATED_MSG ( "ofAVFoundationPlayer::getPixelsRef() is  deprecated,
use getPixels() instead."  ,
const ofPixels &getPixelsRef() const   
)

◆ OF_DEPRECATED_MSG() [2/4]

ofAVFoundationPlayer::OF_DEPRECATED_MSG ( "ofAVFoundationPlayer::getPixelsRef() is  deprecated,
use getPixels() instead."  ,
ofPixels getPixelsRef() 
)

◆ OF_DEPRECATED_MSG() [3/4]

ofAVFoundationPlayer::OF_DEPRECATED_MSG ( "ofAVFoundationPlayer::getTexture() is  deprecated,
use getTexturePtr() instead."  ,
ofTexture getTexture() 
)

◆ OF_DEPRECATED_MSG() [4/4]

ofAVFoundationPlayer::OF_DEPRECATED_MSG ( "ofAVFoundationPlayer::loadMovie() is  deprecated,
use load() instead."  ,
bool   loadMoviestd::string name 
)

◆ operator=()

ofAVFoundationPlayer & ofAVFoundationPlayer::operator= ( ofAVFoundationPlayer  other)

◆ play()

void ofAVFoundationPlayer::play ( )
virtual

Play the video from the current playhead position.

See also
getPosition()
setPostion()

Implements ofBaseVideoPlayer.

◆ previousFrame()

void ofAVFoundationPlayer::previousFrame ( )
virtual

Advance the playhead backward one frame.

This allows the user to advance backward through the video manually one frame at a time without calling play().

Reimplemented from ofBaseVideoPlayer.

◆ setFrame()

void ofAVFoundationPlayer::setFrame ( int  frame)
virtual

Set the current frame by frame number.

Similar to setPosition(), but accepts a frame number instead of a normalized floating point value. Frame count begins with the first frame as 0 and the last frame as getTotalNumFrames() - 1.

Parameters
frameThe frame number to set the new playhead to.

Reimplemented from ofBaseVideoPlayer.

◆ setLoopState()

void ofAVFoundationPlayer::setLoopState ( ofLoopType  state)
virtual

Set the video loop state.

Parameters
stateThe loop state of the video.
See also
ofLoopType

Reimplemented from ofBaseVideoPlayer.

◆ setPaused()

void ofAVFoundationPlayer::setPaused ( bool  bPause)
virtual

Set the paused state of the video.

Parameters
bPauseTrue to pause the video, false to play.

Reimplemented from ofBaseVideoPlayer.

◆ setPixelFormat()

bool ofAVFoundationPlayer::setPixelFormat ( ofPixelFormat  pixelFormat)
virtual

Set the requested ofPixelFormat.

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

Implements ofBaseVideo.

◆ setPosition()

void ofAVFoundationPlayer::setPosition ( float  pct)
virtual

Set the position of the playhead.

This value is a normalized floating point value between 0.0 and 1.0 that represents the position of the playhead. 0.0 maps to the first frame of the loaded video and 1.0 maps to the last frame of the loaded video.

Parameters
pctA value between 0.0 and 1.0 representing playhead position.

Reimplemented from ofBaseVideoPlayer.

◆ setSpeed()

void ofAVFoundationPlayer::setSpeed ( float  speed)
virtual

Set the video playback speed.

When the loop state is OF_LOOP_NONE or OF_LOOP_NORMAL, positive speed will scale a forward playback rate while a negative speed will scale a a backward playback rate. When the loop state is OF_LOOP_PALINDROME, the direction of playback will change each loop, but the playback rate will still be scaled by the absolute value of the speed.

To play a video forward at normal speed, set the loop state to OF_LOOP_NONE or OF_LOOP_NORMAL and a speed of 1.0. To double the playback rate, set the speed to 2.0. To play a video backward, set the speed to a negative number. A speed 0.25 will play the video at 1/4 the the normal rate and a rate of 0.0 will effectively stop playback.

Parameters
speedThe desired playback speed of the video.

Reimplemented from ofBaseVideoPlayer.

◆ setVolume()

void ofAVFoundationPlayer::setVolume ( float  volume)
virtual

Set the volume of the video player.

This value is a normalized floating point value between 0.0 and 1.0 that represents the video player volume. 0.0 maps to silence and 1.0 maps to maximum volume.

Parameters
volumeA value between 0.0 and 1.0 representing volume.

Reimplemented from ofBaseVideoPlayer.

◆ stop()

void ofAVFoundationPlayer::stop ( )
virtual

Pause and reset the playhead position to the first frame.

Implements ofBaseVideoPlayer.

◆ update()

void ofAVFoundationPlayer::update ( )
virtual

Update the object's state.

mark pixels to be updated. pixels are then only updated if the getPixels() method is called, internally or externally to this class. this ensures the pixels are updated only once per frame.

Implements ofBaseUpdates.

Member Data Documentation

◆ bFrameNew

bool ofAVFoundationPlayer::bFrameNew
protected

◆ bResetPixels

bool ofAVFoundationPlayer::bResetPixels
protected

◆ bUpdatePixels

bool ofAVFoundationPlayer::bUpdatePixels
protected

◆ bUpdateTexture

bool ofAVFoundationPlayer::bUpdateTexture
protected

◆ bUseTextureCache

bool ofAVFoundationPlayer::bUseTextureCache
protected

◆ pixelFormat

ofPixelFormat ofAVFoundationPlayer::pixelFormat
protected

◆ pixels

ofPixels ofAVFoundationPlayer::pixels
protected

◆ videoPlayer

void* ofAVFoundationPlayer::videoPlayer
protected

◆ videoTexture

ofTexture ofAVFoundationPlayer::videoTexture
protected

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