reference

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

ofAVFoundationPlayer.h
Go to the documentation of this file.
1//
2// ofAVFoundationPlayer.h
3// Created by Lukasz Karluk on 06/07/14.
4// Merged with code by Sam Kronick, James George and Elie Zananiri.
5//
6
7#pragma once
8
9#include "ofVideoBaseTypes.h"
10#include "ofTexture.h"
11#include "ofThread.h"
12#include "ofPixels.h"
13
14#ifdef __OBJC__
16#endif
17
18#if defined TARGET_OF_IOS || defined TARGET_OSX
19#import <CoreVideo/CoreVideo.h>
20#endif
21
23
24public:
25
28
29 bool load(std::string name);
30 void loadAsync(std::string name);
31 void close();
32 void update();
33
34 void draw();
35 void draw(float x, float y);
36 void draw(const ofRectangle & rect);
37 void draw(float x, float y, float w, float h);
38
41
42 void play();
43 void stop();
44
45 bool isFrameNew() const;
46 const ofPixels & getPixels() const;
49 void initTextureCache();
50 void killTexture();
51 void killTextureCache();
52
53 float getWidth() const;
54 float getHeight() const;
55
56 bool isPaused() const;
57 bool isLoaded() const;
58 bool isPlaying() const;
59
60 float getPosition() const;
61 float getSpeed() const;
62 float getDuration() const;
63 bool getIsMovieDone() const;
64
65 void setPaused(bool bPause);
66 void setPosition(float pct);
67 void setVolume(float volume); // 0..1
68 void setLoopState(ofLoopType state);
69 void setSpeed(float speed);
70 void setFrame(int frame); // frame 0 = first frame...
71
72 int getCurrentFrame() const;
73 int getTotalNumFrames() const;
75
76 void firstFrame();
77 void nextFrame();
78 void previousFrame();
79
81
82#ifdef __OBJC__
84#else
86#endif
87
88 OF_DEPRECATED_MSG("ofAVFoundationPlayer::loadMovie() is deprecated, use load() instead.", bool loadMovie(std::string name));
89 OF_DEPRECATED_MSG("ofAVFoundationPlayer::getPixelsRef() is deprecated, use getPixels() instead.", ofPixels & getPixelsRef());
90 OF_DEPRECATED_MSG("ofAVFoundationPlayer::getPixelsRef() is deprecated, use getPixels() instead.", const ofPixels & getPixelsRef() const);
91 OF_DEPRECATED_MSG("ofAVFoundationPlayer::getTexture() is deprecated, use getTexturePtr() instead.", ofTexture * getTexture());
92
93protected:
94
95 bool loadPlayer(std::string name, bool bAsync);
96 void disposePlayer();
97 bool isReady() const;
98
99#ifdef __OBJC__
101#else
103#endif
104
110
114
115#ifdef TARGET_OF_IOS
116 CVOpenGLESTextureCacheRef _videoTextureCache = nullptr;
117 CVOpenGLESTextureRef _videoTextureRef = nullptr;
118#endif
119
120#ifdef TARGET_OSX
121 CVOpenGLTextureCacheRef _videoTextureCache = nullptr;
122 CVOpenGLTextureRef _videoTextureRef = nullptr;
123#endif
124};
125
Definition ofAVFoundationPlayer.h:22
ofTexture videoTexture
Definition ofAVFoundationPlayer.h:113
void setPosition(float pct)
Set the position of the playhead.
Definition ofAVFoundationPlayer.mm:646
void setFrame(int frame)
Set the current frame by frame number.
Definition ofAVFoundationPlayer.mm:685
bool bFrameNew
Definition ofAVFoundationPlayer.h:105
bool load(std::string name)
Load a video resource by name.
Definition ofAVFoundationPlayer.mm:60
bool isPlaying() const
Returns true if the loaded video is playing.
Definition ofAVFoundationPlayer.mm:588
void setVolume(float volume)
Set the volume of the video player.
Definition ofAVFoundationPlayer.mm:655
void killTexture()
Definition ofAVFoundationPlayer.mm:508
bool getIsMovieDone() const
Returns true if the loaded video has finished playing.
Definition ofAVFoundationPlayer.mm:624
ofPixels pixels
Definition ofAVFoundationPlayer.h:111
bool isFrameNew() const
Definition ofAVFoundationPlayer.mm:292
ofPixelFormat getPixelFormat() const
Definition ofAVFoundationPlayer.mm:220
bool isPaused() const
Returns true if the video is paused.
Definition ofAVFoundationPlayer.mm:561
void close()
Close the video source.
Definition ofAVFoundationPlayer.mm:181
ofLoopType getLoopState() const
Get the current loop state of the video.
Definition ofAVFoundationPlayer.mm:710
void firstFrame()
Set the playhead position to the first frame.
Definition ofAVFoundationPlayer.mm:723
void stop()
Pause and reset the playhead position to the first frame.
Definition ofAVFoundationPlayer.mm:283
void draw()
Definition ofAVFoundationPlayer.mm:249
bool bResetPixels
Definition ofAVFoundationPlayer.h:106
ofPixelFormat pixelFormat
Definition ofAVFoundationPlayer.h:112
ofTexture * getTexturePtr()
Get a pointer to the video texture used internally if it exists.
Definition ofAVFoundationPlayer.mm:384
void initTextureCache()
Definition ofAVFoundationPlayer.mm:406
int getCurrentFrame() const
Get the current playhead position as a frame number.
Definition ofAVFoundationPlayer.mm:694
OF_DEPRECATED_MSG("ofAVFoundationPlayer::getPixelsRef() is deprecated, use getPixels() instead.", ofPixels &getPixelsRef())
bool setPixelFormat(ofPixelFormat pixelFormat)
Set the requested ofPixelFormat.
Definition ofAVFoundationPlayer.mm:198
bool bUseTextureCache
Definition ofAVFoundationPlayer.h:109
void loadAsync(std::string name)
Asynchronously load a video resource by name.
Definition ofAVFoundationPlayer.mm:55
~ofAVFoundationPlayer()
Definition ofAVFoundationPlayer.mm:30
void update()
Update the object's state.
Definition ofAVFoundationPlayer.mm:225
void nextFrame()
Advance the playhead forward one frame.
Definition ofAVFoundationPlayer.mm:732
bool isReady() const
Definition ofAVFoundationPlayer.mm:579
void disposePlayer()
Definition ofAVFoundationPlayer.mm:150
void setLoopState(ofLoopType state)
Set the video loop state.
Definition ofAVFoundationPlayer.mm:667
bool isLoaded() const
Returns true if a video is loaded.
Definition ofAVFoundationPlayer.mm:570
ofAVFoundationPlayer & operator=(ofAVFoundationPlayer other)
Definition ofAVFoundationPlayer.mm:35
void previousFrame()
Advance the playhead backward one frame.
Definition ofAVFoundationPlayer.mm:741
void setSpeed(float speed)
Set the video playback speed.
Definition ofAVFoundationPlayer.mm:676
void * videoPlayer
Definition ofAVFoundationPlayer.h:102
void * getAVFoundationVideoPlayer()
Definition ofAVFoundationPlayer.mm:758
OF_DEPRECATED_MSG("ofAVFoundationPlayer::getPixelsRef() is deprecated, use getPixels() instead.", const ofPixels &getPixelsRef() const)
ofAVFoundationPlayer()
Definition ofAVFoundationPlayer.mm:18
float getHeight() const
Get the height in pixels of the loaded video.
Definition ofAVFoundationPlayer.mm:552
float getSpeed() const
Get the playback speed of the video player.
Definition ofAVFoundationPlayer.mm:606
bool bUpdateTexture
Definition ofAVFoundationPlayer.h:108
float getWidth() const
Get the width in pixels of the loaded video.
Definition ofAVFoundationPlayer.mm:543
void setPaused(bool bPause)
Set the paused state of the video.
Definition ofAVFoundationPlayer.mm:633
float getDuration() const
Get the duration of the loaded video in seconds.
Definition ofAVFoundationPlayer.mm:615
const ofPixels & getPixels() const
Get a const reference to the underlying ofPixels.
Definition ofAVFoundationPlayer.mm:300
int getTotalNumFrames() const
Get the total number of frames in the currently loaded video.
Definition ofAVFoundationPlayer.mm:702
bool bUpdatePixels
Definition ofAVFoundationPlayer.h:107
bool loadPlayer(std::string name, bool bAsync)
Definition ofAVFoundationPlayer.mm:65
OF_DEPRECATED_MSG("ofAVFoundationPlayer::getTexture() is deprecated, use getTexturePtr() instead.", ofTexture *getTexture())
float getPosition() const
Get the current playhead position of the loaded video.
Definition ofAVFoundationPlayer.mm:597
void play()
Play the video from the current playhead position.
Definition ofAVFoundationPlayer.mm:274
void killTextureCache()
Definition ofAVFoundationPlayer.mm:522
OF_DEPRECATED_MSG("ofAVFoundationPlayer::loadMovie() is deprecated, use load() instead.", bool loadMovie(std::string name))
A base class representing a video player.
Definition ofVideoBaseTypes.h:178
A class representing a 2D rectangle.
Definition ofRectangle.h:87
A wrapper class for an OpenGL texture.
Definition ofTexture.h:253
Definition ofAVFoundationVideoPlayer.h:34
ofPixelFormat
Used to represent the available pixel formats.
Definition ofPixels.h:68
ofLoopType
Used to represent the available video looping modes.
Definition ofVideoBaseTypes.h:11