Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/ofxAVFVideoPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ofxAVFVideoPlayer : public ofBaseVideoPlayer {

ofxAVFVideoPlayer();
~ofxAVFVideoPlayer();


bool load(std::string name);
bool loadMovie(string path);

void closeMovie();
Expand All @@ -34,13 +35,14 @@ class ofxAVFVideoPlayer : public ofBaseVideoPlayer {
OF_DEPRECATED_MSG("Use getTexture()->bind() instead. Ensure decodeMode != OF_QTKIT_DECODE_PIXELS_ONLY.", void bind());
OF_DEPRECATED_MSG("Use getTexture()->unbind() instead. Ensure decodeMode != OF_QTKIT_DECODE_PIXELS_ONLY.", void unbind());

bool isFrameNew(); //returns true if the frame has changed in this update cycle
bool isFrameNew() const; //returns true if the frame has changed in this update cycle

// Returns openFrameworks compatible RGBA pixels.
// Be aware of your current render mode.

unsigned char * getPixels();
ofPixelsRef getPixelsRef();
ofPixels& getPixels();
ofPixels& getPixels() const;
ofPixels& getPixelsRef();

// Returns openFrameworks compatible ofTexture pointer.
// if decodeMode == OF_QTKIT_DECODE_PIXELS_ONLY,
Expand All @@ -67,18 +69,18 @@ class ofxAVFVideoPlayer : public ofBaseVideoPlayer {

// ofQTKitPlayer only supports OF_PIXELS_RGB and OF_PIXELS_RGBA.
bool setPixelFormat(ofPixelFormat pixelFormat);
ofPixelFormat getPixelFormat();
ofPixelFormat getPixelFormat() const;

void draw(float x, float y, float w, float h);
void draw(float x, float y);

float getWidth();
float getHeight();
float getWidth() const;
float getHeight() const;

bool isPaused();
bool isLoaded();
bool isPaused() const;
bool isLoaded() const;
bool isLoading();
bool isPlaying();
bool isPlaying() const;
bool errorLoading();


Expand Down
33 changes: 21 additions & 12 deletions src/ofxAVFVideoPlayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
close();
}

bool ofxAVFVideoPlayer::load(std::string name) {
// included this to get rid of build errors ¯\_(ツ)_/¯
}

bool ofxAVFVideoPlayer::loadMovie(string path) {
bInitialized = false;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
Expand Down Expand Up @@ -97,22 +101,27 @@
[moviePlayer stop];
}

bool ofxAVFVideoPlayer::isFrameNew() {
bool ofxAVFVideoPlayer::isFrameNew() const {
return true;
}

unsigned char* ofxAVFVideoPlayer::getPixels() {
if(!moviePlayer || ![moviePlayer isReady] || !bInitialized) return NULL;
ofPixels& ofxAVFVideoPlayer::getPixels() {
if(!moviePlayer || ![moviePlayer isReady] || !bInitialized) return;

if(bHavePixelsChanged) {
fbo.readToPixels(pixels);
bHavePixelsChanged = false; // Don't read pixels until next update() is called
}

return pixels.getPixels();
return pixels;
}

ofPixelsRef ofxAVFVideoPlayer::getPixelsRef() {

ofPixels& ofxAVFVideoPlayer::getPixels() const {
// included this to get rid of build errors ¯\_(ツ)_/¯
}

ofPixels& ofxAVFVideoPlayer::getPixelsRef() {
getPixels();
return pixels;
}
Expand Down Expand Up @@ -194,7 +203,7 @@

}

ofPixelFormat ofxAVFVideoPlayer::getPixelFormat() {
ofPixelFormat ofxAVFVideoPlayer::getPixelFormat() const {

}

Expand All @@ -208,23 +217,23 @@
fbo.draw(x, y);
}

float ofxAVFVideoPlayer::getWidth() {
float ofxAVFVideoPlayer::getWidth() const {
return [moviePlayer getVideoSize].width;
}

float ofxAVFVideoPlayer::getHeight() {
float ofxAVFVideoPlayer::getHeight() const {
return [moviePlayer getVideoSize].height;
}

bool ofxAVFVideoPlayer::isPaused() {
bool ofxAVFVideoPlayer::isPaused() const {
return [moviePlayer player].rate == 0;
}

bool ofxAVFVideoPlayer::isLoading() {
return [moviePlayer isLoading];
}

bool ofxAVFVideoPlayer::isLoaded() {
bool ofxAVFVideoPlayer::isLoaded() const {
return bInitialized;
}

Expand All @@ -235,7 +244,7 @@
return (![moviePlayer isLoading] && ![moviePlayer isReady]);
}

bool ofxAVFVideoPlayer::isPlaying() {
bool ofxAVFVideoPlayer::isPlaying() const {

}

Expand All @@ -257,4 +266,4 @@

void ofxAVFVideoPlayer::reallocatePixels() {

}
}