reference

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

ofBaseVideoPlayer Class Referenceabstract

A base class representing a video player. More...

#include <ofVideoBaseTypes.h>

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

Public Member Functions

virtual ~ofBaseVideoPlayer ()
 Destroys the ofBaseVideoPlayer.
 
virtual bool load (std::string name)=0
 Load a video resource by name.
 
virtual void loadAsync (std::string name)
 Asynchronously load a video resource by name.
 
virtual void play ()=0
 Play the video from the current playhead position.
 
virtual void stop ()=0
 Pause and reset the playhead position to the first frame.
 
virtual ofTexturegetTexturePtr ()
 Get a pointer to the video texture used internally if it exists.
 
virtual float getWidth () const =0
 Get the width in pixels of the loaded video.
 
virtual float getHeight () const =0
 Get the height in pixels of the loaded video.
 
virtual bool isPaused () const =0
 Returns true if the video is paused.
 
virtual bool isLoaded () const =0
 Returns true if a video is loaded.
 
virtual bool isPlaying () const =0
 Returns true if the loaded video is playing.
 
virtual bool isInitialized () const
 Returns true if a video is loaded.
 
virtual float getPosition () const
 Get the current playhead position of the loaded video.
 
virtual float getSpeed () const
 Get the playback speed of the video player.
 
virtual float getDuration () const
 Get the duration of the loaded video in seconds.
 
virtual bool getIsMovieDone () const
 Returns true if the loaded video has finished playing.
 
virtual void setPaused (bool bPause)
 Set the paused state of the video.
 
virtual void setPosition (float pct)
 Set the position of the playhead.
 
virtual void setVolume (float volume)
 Set the volume of the video player.
 
virtual void setLoopState (ofLoopType state)
 Set the video loop state.
 
virtual void setSpeed (float speed)
 Set the video playback speed.
 
virtual void setFrame (int frame)
 Set the current frame by frame number.
 
virtual int getCurrentFrame () const
 Get the current playhead position as a frame number.
 
virtual int getTotalNumFrames () const
 Get the total number of frames in the currently loaded video.
 
virtual ofLoopType getLoopState () const
 Get the current loop state of the video.
 
virtual void firstFrame ()
 Set the playhead position to the first frame.
 
virtual void nextFrame ()
 Advance the playhead forward one frame.
 
virtual void previousFrame ()
 Advance the playhead backward one frame.
 
- Public Member Functions inherited from ofBaseVideo
virtual ~ofBaseVideo ()
 Destroy the ofBaseVideo.
 
virtual bool isFrameNew () const =0
 
virtual void close ()=0
 Close the video source.
 
virtual bool setPixelFormat (ofPixelFormat pixelFormat)=0
 Set the requested ofPixelFormat.
 
virtual ofPixelFormat getPixelFormat () const =0
 
- Public Member Functions inherited from ofBaseHasPixels_< unsigned char >
virtual ~ofBaseHasPixels_ ()
 Destroy the ofAbstractHasPixels.
 
virtual ofPixels_< unsigned char > & getPixels ()=0
 Get a reference to the underlying ofPixels.
 
virtual const ofPixels_< unsigned char > & getPixels () const=0
 Get a const reference to the underlying ofPixels.
 
- Public Member Functions inherited from ofAbstractHasPixels
virtual ~ofAbstractHasPixels ()
 Destroy the ofAbstractHasPixels.
 
- Public Member Functions inherited from ofBaseUpdates
virtual ~ofBaseUpdates ()
 Destroy the ofBaseUpdates.
 
virtual void update ()=0
 Update the object's state.
 

Detailed Description

A base class representing a video player.

Constructor & Destructor Documentation

◆ ~ofBaseVideoPlayer()

ofBaseVideoPlayer::~ofBaseVideoPlayer ( )
virtual

Destroys the ofBaseVideoPlayer.

Member Function Documentation

◆ firstFrame()

void ofBaseVideoPlayer::firstFrame ( )
virtual

Set the playhead position to the first frame.

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

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getCurrentFrame()

int ofBaseVideoPlayer::getCurrentFrame ( ) const
virtual

Get the current playhead position as a frame number.

Returns
The current playhead position as a frame number.

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getDuration()

float ofBaseVideoPlayer::getDuration ( ) const
virtual

Get the duration of the loaded video in seconds.

Returns
The duration of the loaded video in seconds.

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getHeight()

virtual float ofBaseVideoPlayer::getHeight ( ) const
pure 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.

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getIsMovieDone()

bool ofBaseVideoPlayer::getIsMovieDone ( ) const
virtual

Returns true if the loaded video has finished playing.

Returns
True if the loaded video has finished playing.

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getLoopState()

ofLoopType ofBaseVideoPlayer::getLoopState ( ) const
virtual

Get the current loop state of the video.

See also
ofLoopType

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getPosition()

float ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getSpeed()

float ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getTexturePtr()

virtual ofTexture * ofBaseVideoPlayer::getTexturePtr ( )
inlinevirtual

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 in ofAVFoundationPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getTotalNumFrames()

int ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ getWidth()

virtual float ofBaseVideoPlayer::getWidth ( ) const
pure 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.

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ isInitialized()

virtual bool ofBaseVideoPlayer::isInitialized ( ) const
inlinevirtual

Returns true if a video is loaded.

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

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

Implements ofBaseVideo.

Reimplemented in ofMediaFoundationPlayer.

◆ isLoaded()

virtual bool ofBaseVideoPlayer::isLoaded ( ) const
pure 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.

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ isPaused()

virtual bool ofBaseVideoPlayer::isPaused ( ) const
pure virtual

Returns true if the video is paused.

Returns
True if the video is paused.

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ isPlaying()

virtual bool ofBaseVideoPlayer::isPlaying ( ) const
pure virtual

Returns true if the loaded video is playing.

Returns
True if the loaded video is playing.

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ load()

virtual bool ofBaseVideoPlayer::load ( std::string  name)
pure 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()

Implemented in ofAVFoundationPlayer, ofMediaFoundationPlayer, ofDirectShowPlayer, and ofGstVideoPlayer.

◆ loadAsync()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ nextFrame()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ play()

virtual void ofBaseVideoPlayer::play ( )
pure virtual

Play the video from the current playhead position.

See also
getPosition()
setPostion()

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ previousFrame()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ setFrame()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ setLoopState()

void ofBaseVideoPlayer::setLoopState ( ofLoopType  state)
virtual

Set the video loop state.

Parameters
stateThe loop state of the video.
See also
ofLoopType

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ setPaused()

void ofBaseVideoPlayer::setPaused ( bool  bPause)
virtual

Set the paused state of the video.

Parameters
bPauseTrue to pause the video, false to play.

Reimplemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ setPosition()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ setSpeed()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ setVolume()

void ofBaseVideoPlayer::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 in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.

◆ stop()

virtual void ofBaseVideoPlayer::stop ( )
pure virtual

Pause and reset the playhead position to the first frame.

Implemented in ofAVFoundationPlayer, ofDirectShowPlayer, ofGstVideoPlayer, and ofMediaFoundationPlayer.


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