diff --git a/src/ofxAVFVideoPlayer.h b/src/ofxAVFVideoPlayer.h index a28ada0..2038b9b 100644 --- a/src/ofxAVFVideoPlayer.h +++ b/src/ofxAVFVideoPlayer.h @@ -20,7 +20,8 @@ class ofxAVFVideoPlayer : public ofBaseVideoPlayer { ofxAVFVideoPlayer(); ~ofxAVFVideoPlayer(); - + + bool load(std::string name); bool loadMovie(string path); void closeMovie(); @@ -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, @@ -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(); diff --git a/src/ofxAVFVideoPlayer.mm b/src/ofxAVFVideoPlayer.mm index 06da751..e53a7cb 100644 --- a/src/ofxAVFVideoPlayer.mm +++ b/src/ofxAVFVideoPlayer.mm @@ -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]; @@ -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; } @@ -194,7 +203,7 @@ } -ofPixelFormat ofxAVFVideoPlayer::getPixelFormat() { +ofPixelFormat ofxAVFVideoPlayer::getPixelFormat() const { } @@ -208,15 +217,15 @@ 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; } @@ -224,7 +233,7 @@ return [moviePlayer isLoading]; } -bool ofxAVFVideoPlayer::isLoaded() { +bool ofxAVFVideoPlayer::isLoaded() const { return bInitialized; } @@ -235,7 +244,7 @@ return (![moviePlayer isLoading] && ![moviePlayer isReady]); } -bool ofxAVFVideoPlayer::isPlaying() { +bool ofxAVFVideoPlayer::isPlaying() const { } @@ -257,4 +266,4 @@ void ofxAVFVideoPlayer::reallocatePixels() { -} \ No newline at end of file +}