From a7bd5cf4159fbe639a253b39231de9fbe97e7cd7 Mon Sep 17 00:00:00 2001 From: Charles Veasey Date: Thu, 24 Apr 2014 01:33:15 -0600 Subject: [PATCH 01/14] Add bind / unbind methods --- src/ofxWMFVideoPlayer.cpp | 19 +++++++++++++++++++ src/ofxWMFVideoPlayer.h | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 1b89887..ad9a848 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -169,6 +169,25 @@ void ofxWMFVideoPlayer::forceExit() + } + + void ofxWMFVideoPlayer::bind() { + + + _player->m_pEVRPresenter->lockSharedTexture(); + _tex.bind(); + + + + } + void ofxWMFVideoPlayer::unbind() { + + + _tex.unbind(); + _player->m_pEVRPresenter->unlockSharedTexture(); + + + } diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 0875c1e..75faebb 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -38,6 +38,7 @@ class ofxWMFVideoPlayer { bool _sharedTextureCreated; ofTexture _tex; + BOOL InitInstance(); @@ -49,7 +50,6 @@ class ofxWMFVideoPlayer { CPlayer* _player; int _id; - ofxWMFVideoPlayer(); ~ofxWMFVideoPlayer(); @@ -78,8 +78,8 @@ class ofxWMFVideoPlayer { void setLoop(bool isLooping); bool isLooping() { return _isLooping; } - - + void bind(); + void unbind(); From 9808b8c93b8d58437c5eec7bc05068046981a45a Mon Sep 17 00:00:00 2001 From: Ben McChesney Date: Thu, 19 Jun 2014 09:52:16 -0700 Subject: [PATCH 02/14] Changed methods around to make it more of a 1 to 1 replacement for ofVideoPlayer --- src/ofxWMFVideoPlayer.cpp | 36 ++++++++++++++++++++++++++++++++++-- src/ofxWMFVideoPlayer.h | 20 ++++++++------------ 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 1b89887..36cdb38 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -202,8 +202,22 @@ void ofxWMFVideoPlayer:: update() { return; } +bool ofxWMFVideoPlayer::getIsMovieDone( ) +{ + bool bIsDone = false ; + if ( getPosition() >= 0.99f ) + bIsDone = true ; + return bIsDone ; +} +void ofxWMFVideoPlayer::setPaused( bool bPause ) +{ + if ( bPause == true ) + pause() ; + else + play() ; +} void ofxWMFVideoPlayer:: play() { @@ -223,9 +237,27 @@ void ofxWMFVideoPlayer:: pause() _player->Pause(); } +void ofxWMFVideoPlayer::setLoopState( ofLoopType loopType ) +{ + switch ( loopType ) + { + case OF_LOOP_NONE : + setLoop( false ) ; + break ; + case OF_LOOP_NORMAL : + setLoop( true ) ; + break; + default : + ofLogError ( "ofxWMFVideoPlayer::setLoopState LOOP TYPE NOT SUPPORTED" ) << loopType << endl ; + break ; + } +} -float ofxWMFVideoPlayer:: getPosition() { - return _player->getPosition(); +float ofxWMFVideoPlayer:: getPosition() +{ + return ( _player->getPosition() / getDuration() ); + //this returns it in seconds + // return _player->getPosition(); } float ofxWMFVideoPlayer:: getDuration() { diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 0875c1e..44f0883 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -62,6 +62,7 @@ class ofxWMFVideoPlayer { void play(); void stop(); void pause(); + void setPaused( bool bPause ) ; float getPosition(); float getDuration(); @@ -78,21 +79,16 @@ class ofxWMFVideoPlayer { void setLoop(bool isLooping); bool isLooping() { return _isLooping; } + void setLoopState( ofLoopType loopType ) ; + bool getIsMovieDone( ) ; + void draw(int x, int y , int w, int h); + void draw(int x, int y) { draw(x,y,getWidth(),getHeight()); } - - - - - - void draw(int x, int y , int w, int h); - void draw(int x, int y) { draw(x,y,getWidth(),getHeight()); } - - - HWND getHandle() { return _hwndPlayer;} - LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + HWND getHandle() { return _hwndPlayer;} + LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - static void forceExit(); + static void forceExit(); }; \ No newline at end of file From a7c8819b8eefbfeccf4559dd212abee5249b9152 Mon Sep 17 00:00:00 2001 From: Charles Veasey Date: Wed, 9 Jul 2014 14:23:14 -0600 Subject: [PATCH 03/14] Add loadEvent --- src/ofxWMFVideoPlayer.cpp | 26 ++++++++++++++++++++++++-- src/ofxWMFVideoPlayer.h | 6 ++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index ad9a848..6dfffd4 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -98,6 +98,9 @@ void ofxWMFVideoPlayer::forceExit() bool ofxWMFVideoPlayer:: loadMovie(string name) { + loadEventSent = false; + bLoaded = false; + if (!_player) { ofLogError("ofxWMFVideoPlayer") << "Player not created. Can't open the movie."; return false; @@ -146,7 +149,7 @@ void ofxWMFVideoPlayer::forceExit() _width = _player->getWidth(); _height = _player->getHeight(); - _tex.allocate(_width,_height,GL_RGBA,true); + _tex.allocate(_width,_height,GL_RGB,true); _player->m_pEVRPresenter->createSharedTexture(_width, _height,_tex.texData.textureID); } @@ -175,6 +178,7 @@ void ofxWMFVideoPlayer::forceExit() _player->m_pEVRPresenter->lockSharedTexture(); + _tex.setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER); _tex.bind(); @@ -268,13 +272,31 @@ void ofxWMFVideoPlayer::setLoop(bool isLooping) { _isLooping = isLooping; _play //----------------------------------- - // Handler for Media Session events. void ofxWMFVideoPlayer::OnPlayerEvent(HWND hwnd, WPARAM pUnkPtr) { HRESULT hr = _player->HandleEvent(pUnkPtr); + PlayerState state; + + if (_player->GetState() == 3) + { + + if (!loadEventSent){ + bLoaded = true; + ofNotifyEvent(videoLoadEvent,bLoaded,this); + loadEventSent = true; + } + cout << "success" << endl; + } + if (FAILED(hr)) { + if (!loadEventSent){ + bLoaded = false; + ofNotifyEvent(videoLoadEvent,bLoaded,this); + loadEventSent = true; + } + ofLogError("ofxWMFVideoPlayer", "An error occurred."); } } diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 75faebb..9932819 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -37,17 +37,18 @@ class ofxWMFVideoPlayer { bool _sharedTextureCreated; - ofTexture _tex; BOOL InitInstance(); void OnPlayerEvent(HWND hwnd, WPARAM pUnkPtr); - + bool loadEventSent; + bool bLoaded; public: CPlayer* _player; + ofTexture _tex; int _id; @@ -81,6 +82,7 @@ class ofxWMFVideoPlayer { void bind(); void unbind(); + ofEvent videoLoadEvent; From 8e5def5579b7413853d302a8417a35aa84de4c9a Mon Sep 17 00:00:00 2001 From: Gal Sasson Date: Mon, 14 Jul 2014 12:50:14 -0400 Subject: [PATCH 04/14] allocate RGB texture instead of RGBA --- src/ofxWMFVideoPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 6dfffd4..548b4a0 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -134,7 +134,7 @@ void ofxWMFVideoPlayer::forceExit() _width = _player->getWidth(); _height = _player->getHeight(); - _tex.allocate(_width,_height,GL_RGBA,true); + _tex.allocate(_width,_height,GL_RGB,true); _player->m_pEVRPresenter->createSharedTexture(_width, _height,_tex.texData.textureID); _sharedTextureCreated = true; From 475467fd11ab42ddf67c3c3afebcc83191eb450e Mon Sep 17 00:00:00 2001 From: Gal Sasson Date: Mon, 14 Jul 2014 17:31:42 -0400 Subject: [PATCH 05/14] release textures in destructor --- src/ofxWMFVideoPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 548b4a0..86f9bf8 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -68,8 +68,8 @@ ofxWMFVideoPlayer::ofxWMFVideoPlayer() : _player(NULL) ofxWMFVideoPlayer::~ofxWMFVideoPlayer() { if (_player) { + if (_sharedTextureCreated) _player->m_pEVRPresenter->releaseSharedTexture(); _player->Shutdown(); - //if (_sharedTextureCreated) _player->m_pEVRPresenter->releaseSharedTexture(); SafeRelease(&_player); } From 47a401159f900063169bd74302433ac2f39c0ff9 Mon Sep 17 00:00:00 2001 From: Gal Sasson Date: Mon, 14 Jul 2014 18:51:20 -0400 Subject: [PATCH 06/14] clean log messages --- src/ofxWMFVideoPlayer.cpp | 1 - src/ofxWMFVideoPlayerUtils.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 86f9bf8..56bc052 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -286,7 +286,6 @@ void ofxWMFVideoPlayer::OnPlayerEvent(HWND hwnd, WPARAM pUnkPtr) ofNotifyEvent(videoLoadEvent,bLoaded,this); loadEventSent = true; } - cout << "success" << endl; } if (FAILED(hr)) diff --git a/src/ofxWMFVideoPlayerUtils.cpp b/src/ofxWMFVideoPlayerUtils.cpp index a6ae1d4..8913fb1 100644 --- a/src/ofxWMFVideoPlayerUtils.cpp +++ b/src/ofxWMFVideoPlayerUtils.cpp @@ -598,7 +598,7 @@ HRESULT CPlayer::HandleEvent(UINT_PTR pEventPtr) GetEventObject (pEvent,&topology); WORD nodeCount; topology->GetNodeCount(&nodeCount); - cout << "Topo set and we have " << nodeCount << " nodes" << endl; + ofLog(ofLogLevel::OF_LOG_VERBOSE, "Video topography set with %d nodes", nodeCount); SafeRelease(&topology); break; From 85af58de192a83ae9b3477321a9cdda9709f3096 Mon Sep 17 00:00:00 2001 From: Isaac Gierard Date: Fri, 19 Sep 2014 22:16:34 +0000 Subject: [PATCH 07/14] adding methods to implment ofBaseVideoPlayer --- src/ofxWMFVideoPlayer.cpp | 28 +++++++++++++++++++++++++++- src/ofxWMFVideoPlayer.h | 16 ++++++++++++++-- src/ofxWMFVideoPlayerUtils.cpp | 2 +- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 36cdb38..0eb61b6 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -20,7 +20,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); ofxWMFVideoPlayer* findPlayers(HWND hwnd) { - for each (PlayerItem e in g_WMFVideoPlayers) + for (PlayerItem e : g_WMFVideoPlayers) { if (e.first == hwnd) return e.second; } @@ -211,6 +211,32 @@ bool ofxWMFVideoPlayer::getIsMovieDone( ) return bIsDone ; } +bool ofxWMFVideoPlayer::isLoaded(){ + if(_player == NULL){ return false; } + PlayerState ps = _player->GetState(); + return ps == PlayerState::Paused || ps == PlayerState::Stopped || ps == PlayerState::Started; +} + +unsigned char * ofxWMFVideoPlayer::getPixels(){ + if(_tex.isAllocated()){ + _tex.readToPixels(_pixels); + return _pixels.getPixels(); + } + return NULL; +} + +bool ofxWMFVideoPlayer::setPixelFormat(ofPixelFormat pixelFormat){ + return (pixelFormat == OF_PIXELS_RGB); +} + +ofPixelFormat ofxWMFVideoPlayer::getPixelFormat(){ + return OF_PIXELS_RGB; +} + +bool ofxWMFVideoPlayer::isFrameNew(){ + return true;//TODO fix this +} + void ofxWMFVideoPlayer::setPaused( bool bPause ) { if ( bPause == true ) diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 44f0883..c51c6d9 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -17,7 +17,7 @@ class ofxWMFVideoPlayer; class CPlayer; -class ofxWMFVideoPlayer { +class ofxWMFVideoPlayer : public ofBaseVideoPlayer { private: static int _instanceCount; @@ -38,7 +38,8 @@ class ofxWMFVideoPlayer { bool _sharedTextureCreated; ofTexture _tex; - + ofPixels _pixels; + BOOL InitInstance(); @@ -82,6 +83,17 @@ class ofxWMFVideoPlayer { void setLoopState( ofLoopType loopType ) ; bool getIsMovieDone( ) ; + bool isLoaded(); + + unsigned char * getPixels(); + ofPixels& getPixelsRef(){ return _pixels; } + ofTexture * getTexture(){ return &_tex; }; + bool setPixelFormat(ofPixelFormat pixelFormat); + ofPixelFormat getPixelFormat(); + + bool isFrameNew(); + + void draw(int x, int y , int w, int h); void draw(int x, int y) { draw(x,y,getWidth(),getHeight()); } diff --git a/src/ofxWMFVideoPlayerUtils.cpp b/src/ofxWMFVideoPlayerUtils.cpp index a6ae1d4..b3177bd 100644 --- a/src/ofxWMFVideoPlayerUtils.cpp +++ b/src/ofxWMFVideoPlayerUtils.cpp @@ -1371,7 +1371,7 @@ float CPlayer::getPosition() { MFTIME longPosition = 0; hr = pClock->GetTime(&longPosition); if (SUCCEEDED(hr)) - position = (float)longPosition / 10000000.0; + position = float(longPosition / 10000000.0); } SafeRelease(&pClock); return position; From 77a18a9ceb4a4621e9731e0f5fc06f2285df9f7c Mon Sep 17 00:00:00 2001 From: Gal Sasson Date: Tue, 16 Dec 2014 14:42:52 -0800 Subject: [PATCH 08/14] set normalized position --- src/ofxWMFVideoPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index f25196d..fc2f8e4 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -327,7 +327,7 @@ float ofxWMFVideoPlayer:: getDuration() { void ofxWMFVideoPlayer::setPosition(float pos) { - _player->setPosition(pos); + _player->setPosition(pos * getDuration()); } void ofxWMFVideoPlayer::setVolume(float vol) From 27f95862b35fce4e9b72d4bc2cc94d6f21a39af6 Mon Sep 17 00:00:00 2001 From: Gal Sasson Date: Tue, 16 Dec 2014 14:45:06 -0800 Subject: [PATCH 09/14] RefCounterObject is RefCounterObject_ as an ugly patch to overcome ambiguity with Poco::RefCounterObject --- src/presenter/Presenter.cpp | 4 ++-- src/presenter/Presenter.h | 2 +- src/presenter/common/ClassFactory.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/presenter/Presenter.cpp b/src/presenter/Presenter.cpp index a060e3d..3c916ae 100644 --- a/src/presenter/Presenter.cpp +++ b/src/presenter/Presenter.cpp @@ -128,12 +128,12 @@ HRESULT EVRCustomPresenter::QueryInterface(REFIID riid, void ** ppv) ULONG EVRCustomPresenter::AddRef() { - return RefCountedObject::AddRef(); + return RefCountedObject_::AddRef(); } ULONG EVRCustomPresenter::Release() { - return RefCountedObject::Release(); + return RefCountedObject_::Release(); } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/presenter/Presenter.h b/src/presenter/Presenter.h index 09bcab2..ec471ad 100644 --- a/src/presenter/Presenter.h +++ b/src/presenter/Presenter.h @@ -70,7 +70,7 @@ enum FRAMESTEP_STATE class EVRCustomPresenter : BaseObject, - RefCountedObject, + RefCountedObject_, // COM interfaces: public IMFVideoDeviceID, public IMFVideoPresenter, // Inherits IMFClockStateSink diff --git a/src/presenter/common/ClassFactory.h b/src/presenter/common/ClassFactory.h index ef9f728..61095c4 100644 --- a/src/presenter/common/ClassFactory.h +++ b/src/presenter/common/ClassFactory.h @@ -206,14 +206,14 @@ namespace MediaFoundationSamples // RefCountedObject // You can use this when implementing IUnknown or any object that uses reference counting. - class RefCountedObject + class RefCountedObject_ { protected: volatile long m_refCount; public: - RefCountedObject() : m_refCount(1) {} - virtual ~RefCountedObject() + RefCountedObject_() : m_refCount(1) {} + virtual ~RefCountedObject_() { assert(m_refCount == 0); } From ef1d666bdf29abfe27a71f73a657e66f7d099ccc Mon Sep 17 00:00:00 2001 From: Jack O'Shea Date: Mon, 24 Jul 2017 11:47:18 -0400 Subject: [PATCH 10/14] Now compiling. Mainly fixed unimplemented ofBaseVideoPlayer virtual functions --- src/ofxWMFVideoPlayer.cpp | 27 ++++------ src/ofxWMFVideoPlayer.h | 111 +++++++++++++++++++------------------- 2 files changed, 65 insertions(+), 73 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index fc2f8e4..ff62ff7 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -199,15 +199,14 @@ void ofxWMFVideoPlayer::forceExit() } -bool ofxWMFVideoPlayer:: isPlaying() { +bool ofxWMFVideoPlayer:: isPlaying() const { return _player->GetState() == Started; } -bool ofxWMFVideoPlayer:: isStopped() { +bool ofxWMFVideoPlayer:: isStopped() const { return (_player->GetState() == Stopped || _player->GetState() == Paused); } -bool ofxWMFVideoPlayer:: isPaused() -{ +bool ofxWMFVideoPlayer:: isPaused() const { return _player->GetState() == Paused; } @@ -246,29 +245,21 @@ bool ofxWMFVideoPlayer::getIsMovieDone( ) return bIsDone ; } -bool ofxWMFVideoPlayer::isLoaded(){ +bool ofxWMFVideoPlayer::isLoaded() const { if(_player == NULL){ return false; } PlayerState ps = _player->GetState(); return ps == PlayerState::Paused || ps == PlayerState::Stopped || ps == PlayerState::Started; } -unsigned char * ofxWMFVideoPlayer::getPixels(){ - if(_tex.isAllocated()){ - _tex.readToPixels(_pixels); - return _pixels.getPixels(); - } - return NULL; -} - bool ofxWMFVideoPlayer::setPixelFormat(ofPixelFormat pixelFormat){ return (pixelFormat == OF_PIXELS_RGB); } -ofPixelFormat ofxWMFVideoPlayer::getPixelFormat(){ +ofPixelFormat ofxWMFVideoPlayer::getPixelFormat() const { return OF_PIXELS_RGB; } -bool ofxWMFVideoPlayer::isFrameNew(){ +bool ofxWMFVideoPlayer::isFrameNew() const { return true;//TODO fix this } @@ -343,7 +334,7 @@ void ofxWMFVideoPlayer::setVolume(float vol) } -float ofxWMFVideoPlayer::getVolume() +float ofxWMFVideoPlayer::getVolume() const { return _player->getVolume(); } @@ -355,8 +346,8 @@ float ofxWMFVideoPlayer::getFrameRate() return _frameRate; } -float ofxWMFVideoPlayer::getHeight() { return _player->getHeight(); } -float ofxWMFVideoPlayer::getWidth() { return _player->getWidth(); } +float ofxWMFVideoPlayer::getHeight() const { return _player->getHeight(); } +float ofxWMFVideoPlayer::getWidth() const { return _player->getWidth(); } void ofxWMFVideoPlayer::setLoop(bool isLooping) { _isLooping = isLooping; _player->setLooping(isLooping); } diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index a74c0a8..119a4a1 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -7,27 +7,28 @@ #include "ofMain.h" + #include "ofxWMFVideoPlayerUtils.h" #include "EVRPresenter.h" -class ofxWMFVideoPlayer; +//class ofxWMFVideoPlayer; class CPlayer; class ofxWMFVideoPlayer : public ofBaseVideoPlayer { private: + static int _instanceCount; - - + HWND _hwndPlayer; - + BOOL bRepaintClient; - - + + int _width; int _height; @@ -38,87 +39,87 @@ class ofxWMFVideoPlayer : public ofBaseVideoPlayer { float _currentVolume; bool _sharedTextureCreated; - + ofTexture _tex; ofPixels _pixels; BOOL InitInstance(); - - void OnPlayerEvent(HWND hwnd, WPARAM pUnkPtr); - bool loadEventSent; - bool bLoaded; + void OnPlayerEvent(HWND hwnd, WPARAM pUnkPtr); + + bool loadEventSent; + bool bLoaded; - float _frameRate; + float _frameRate; public: + CPlayer* _player; int _id; - + ofxWMFVideoPlayer(); ~ofxWMFVideoPlayer(); - bool loadMovie(string name); - //bool loadMovie(string name_left, string name_right) ; - void close(); - void update(); - - void play(); - void stop(); - void pause(); - void setPaused( bool bPause ) ; + bool load(string name) { return loadMovie(name); } + bool loadMovie(string name); + + void close(); + void update(); - float getPosition(); - float getDuration(); - float getFrameRate(); + void play(); + void stop(); + void pause(); + void setPaused( bool bPause ) ; - void setPosition(float pos); + float getPosition(); + float getDuration(); + float getFrameRate(); - void setVolume(float vol); - float getVolume(); + void setPosition(float pos); - float getHeight(); - float getWidth(); + void setVolume(float vol); + float getVolume() const; - bool isPlaying(); - bool isStopped(); - bool isPaused(); + float getHeight() const; + float getWidth() const; - void setLoop(bool isLooping); - bool isLooping() { return _isLooping; } + bool isPlaying() const; + bool isStopped() const; + bool isPaused() const; - void bind(); - void unbind(); - - ofEvent videoLoadEvent; + bool isLoaded() const; + void setLoop(bool isLooping); + bool isLooping() { return _isLooping; } + void bind(); + void unbind(); - void setLoopState( ofLoopType loopType ) ; - bool getIsMovieDone( ) ; + ofEvent videoLoadEvent; - bool isLoaded(); - - unsigned char * getPixels(); - ofPixels& getPixelsRef(){ return _pixels; } - ofTexture * getTexture(){ return &_tex; }; - bool setPixelFormat(ofPixelFormat pixelFormat); - ofPixelFormat getPixelFormat(); + void setLoopState( ofLoopType loopType ) ; + bool getIsMovieDone( ) ; - bool isFrameNew(); + ofPixels& getPixelsRef() { return _pixels; } + ofPixels& getPixels() { return _pixels; } + const ofPixels& getPixels() const { return _pixels; }; + ofTexture * getTexture(){ return &_tex; }; + bool setPixelFormat(ofPixelFormat pixelFormat); + ofPixelFormat getPixelFormat() const; + bool isFrameNew() const; - void draw(int x, int y , int w, int h); - void draw(int x, int y) { draw(x,y,getWidth(),getHeight()); } + void draw(int x, int y , int w, int h); + void draw(int x, int y) { draw(x,y,getWidth(),getHeight()); } - HWND getHandle() { return _hwndPlayer;} - LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + HWND getHandle() { return _hwndPlayer;} + LRESULT WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - static void forceExit(); + static void forceExit(); -}; \ No newline at end of file +}; From 8ba9037c56a65cebf830b6988e140467ac3c6a7e Mon Sep 17 00:00:00 2001 From: Jack O'Shea Date: Mon, 24 Jul 2017 17:22:33 -0400 Subject: [PATCH 11/14] Upated frame getters --- src/ofxWMFVideoPlayer.cpp | 21 +++++++++++++++------ src/ofxWMFVideoPlayer.h | 11 +++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index ff62ff7..d7e8a0f 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -160,6 +160,11 @@ void ofxWMFVideoPlayer::forceExit() } _waitForLoadedToPlay = false; + _frameRate = _player->getFrameRate(); + _duration = _player->getDuration(); + + _totalNumFrames = _duration * _frameRate; + return false; @@ -305,15 +310,15 @@ void ofxWMFVideoPlayer::setLoopState( ofLoopType loopType ) } } -float ofxWMFVideoPlayer:: getPosition() +float ofxWMFVideoPlayer::getPosition() const { return ( _player->getPosition() / getDuration() ); //this returns it in seconds // return _player->getPosition(); } -float ofxWMFVideoPlayer:: getDuration() { - return _player->getDuration(); +float ofxWMFVideoPlayer::getDuration() const { + return _duration; } void ofxWMFVideoPlayer::setPosition(float pos) @@ -339,13 +344,17 @@ float ofxWMFVideoPlayer::getVolume() const return _player->getVolume(); } -float ofxWMFVideoPlayer::getFrameRate() +float ofxWMFVideoPlayer::getFrameRate() const { - if (!_player) return 0.0f; - if (_frameRate == 0.0f) _frameRate = _player->getFrameRate(); return _frameRate; } + +int ofxWMFVideoPlayer::getTotalNumFrames() const +{ + return _totalNumFrames; +} + float ofxWMFVideoPlayer::getHeight() const { return _player->getHeight(); } float ofxWMFVideoPlayer::getWidth() const { return _player->getWidth(); } diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 119a4a1..4a82ede 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -53,9 +53,11 @@ class ofxWMFVideoPlayer : public ofBaseVideoPlayer { float _frameRate; + float _duration; + int _totalNumFrames; - public: +public: CPlayer* _player; @@ -75,9 +77,10 @@ class ofxWMFVideoPlayer : public ofBaseVideoPlayer { void pause(); void setPaused( bool bPause ) ; - float getPosition(); - float getDuration(); - float getFrameRate(); + float getPosition() const; + float getDuration() const; + float getFrameRate() const; + int getTotalNumFrames() const; void setPosition(float pos); From 5bccd2cd0d86f3b94b6eb85ca8c1a6c9f3ed3372 Mon Sep 17 00:00:00 2001 From: Jack O'Shea Date: Tue, 25 Jul 2017 15:42:14 -0400 Subject: [PATCH 12/14] Improved getMovieIsDone() --- src/ofxWMFVideoPlayer.cpp | 14 ++++++++++---- src/ofxWMFVideoPlayer.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index d7e8a0f..0465c9c 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -63,6 +63,8 @@ ofxWMFVideoPlayer::ofxWMFVideoPlayer() : _player(NULL) _wantToSetVolume = false; _currentVolume = 1.0; _frameRate = 0.0f; + _duration = 0.f; + _totalNumFrames = 0.f; } @@ -243,11 +245,10 @@ void ofxWMFVideoPlayer:: update() { bool ofxWMFVideoPlayer::getIsMovieDone( ) { - bool bIsDone = false ; - if ( getPosition() >= 0.99f ) - bIsDone = true ; + int currentFrame = getCurrentFrame(); + int finalFrame = _totalNumFrames - (_frameRate / 5.f); - return bIsDone ; + return (currentFrame >= finalFrame); } bool ofxWMFVideoPlayer::isLoaded() const { @@ -312,11 +313,16 @@ void ofxWMFVideoPlayer::setLoopState( ofLoopType loopType ) float ofxWMFVideoPlayer::getPosition() const { + cout << _player->getPosition() / getDuration() << endl; return ( _player->getPosition() / getDuration() ); //this returns it in seconds // return _player->getPosition(); } +int ofxWMFVideoPlayer::getCurrentFrame() const { + return getPosition() * _totalNumFrames; +} + float ofxWMFVideoPlayer::getDuration() const { return _duration; } diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 4a82ede..0ff2012 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -80,6 +80,7 @@ class ofxWMFVideoPlayer : public ofBaseVideoPlayer { float getPosition() const; float getDuration() const; float getFrameRate() const; + int getCurrentFrame() const; int getTotalNumFrames() const; void setPosition(float pos); From 5410b65e1558922179323b3e9f04860ebe419fec Mon Sep 17 00:00:00 2001 From: Jack O'Shea Date: Tue, 25 Jul 2017 16:02:26 -0400 Subject: [PATCH 13/14] Fixed never ending setVolume in update() and removed debug cout --- src/ofxWMFVideoPlayer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index 0465c9c..f20a9d9 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -237,7 +237,7 @@ void ofxWMFVideoPlayer:: update() { if ((_wantToSetVolume)) { - _player->setVolume(_currentVolume); + setVolume(_currentVolume); } return; @@ -313,7 +313,6 @@ void ofxWMFVideoPlayer::setLoopState( ofLoopType loopType ) float ofxWMFVideoPlayer::getPosition() const { - cout << _player->getPosition() / getDuration() << endl; return ( _player->getPosition() / getDuration() ); //this returns it in seconds // return _player->getPosition(); From eb021cdcfaa4fbb08bfe7b1fd5d60e4a09d82cd9 Mon Sep 17 00:00:00 2001 From: Jack O'Shea Date: Thu, 27 Jul 2017 11:06:15 -0400 Subject: [PATCH 14/14] Made getIsMovieDone const in conformance with ofBaseVideoPlayer --- src/ofxWMFVideoPlayer.cpp | 2 +- src/ofxWMFVideoPlayer.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ofxWMFVideoPlayer.cpp b/src/ofxWMFVideoPlayer.cpp index f20a9d9..eec22e3 100644 --- a/src/ofxWMFVideoPlayer.cpp +++ b/src/ofxWMFVideoPlayer.cpp @@ -243,7 +243,7 @@ void ofxWMFVideoPlayer:: update() { return; } -bool ofxWMFVideoPlayer::getIsMovieDone( ) +bool ofxWMFVideoPlayer::getIsMovieDone() const { int currentFrame = getCurrentFrame(); int finalFrame = _totalNumFrames - (_frameRate / 5.f); diff --git a/src/ofxWMFVideoPlayer.h b/src/ofxWMFVideoPlayer.h index 0ff2012..c375f7b 100644 --- a/src/ofxWMFVideoPlayer.h +++ b/src/ofxWMFVideoPlayer.h @@ -106,15 +106,18 @@ class ofxWMFVideoPlayer : public ofBaseVideoPlayer { ofEvent videoLoadEvent; void setLoopState( ofLoopType loopType ) ; - bool getIsMovieDone( ) ; + bool getIsMovieDone() const; ofPixels& getPixelsRef() { return _pixels; } ofPixels& getPixels() { return _pixels; } - const ofPixels& getPixels() const { return _pixels; }; - ofTexture * getTexture(){ return &_tex; }; + ofTexture& getTexture(){ return _tex; }; bool setPixelFormat(ofPixelFormat pixelFormat); ofPixelFormat getPixelFormat() const; + const ofTexture & getTexture() const { return _tex; }; + const ofPixels & getPixels() const { return _pixels; }; + + bool isFrameNew() const; void draw(int x, int y , int w, int h);