diff --git a/src/Application/ProjectionMappingState.cpp b/src/Application/ProjectionMappingState.cpp index ea2f8cf..f333cad 100644 --- a/src/Application/ProjectionMappingState.cpp +++ b/src/Application/ProjectionMappingState.cpp @@ -170,7 +170,12 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar break; case ' ': - app->getCmdManager()->exec(new DeselectSurfaceCmd(app->getSurfaceManager())); + if(app->getSurfaceManager()->getSelectedSurface()->getSource()->getType() == + SourceType::SOURCE_TYPE_VIDEO){ + app->getCmdManager()->exec( + new ToggleAnimatedSourceCmd( + app->getSurfaceManager()->getSelectedSurface())); + } break; case OF_KEY_TAB: diff --git a/src/Application/ProjectionMappingState.h b/src/Application/ProjectionMappingState.h index 7fbbdee..8c0e840 100644 --- a/src/Application/ProjectionMappingState.h +++ b/src/Application/ProjectionMappingState.h @@ -22,6 +22,7 @@ #include "DeselectSurfaceCmd.h" #include "SetNextSourceCmd.h" #include "DuplicateSurfaceCmd.h" +#include "ToggleAnimatedSourceCmd.h" #include "SurfaceType.h" #include "Gui.h" diff --git a/src/Application/TextureMappingState.cpp b/src/Application/TextureMappingState.cpp index 40158b6..56a0037 100644 --- a/src/Application/TextureMappingState.cpp +++ b/src/Application/TextureMappingState.cpp @@ -30,8 +30,12 @@ void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args) break; case ' ': - app->getCmdManager()->exec( - new DeselectTexCoordCmd(app->getGui()->getTextureEditor())); + if(app->getSurfaceManager()->getSelectedSurface()->getSource()->getType() == + SourceType::SOURCE_TYPE_VIDEO){ + app->getCmdManager()->exec( + new ToggleAnimatedSourceCmd( + app->getSurfaceManager()->getSelectedSurface())); + } break; case OF_KEY_TAB: diff --git a/src/Application/TextureMappingState.h b/src/Application/TextureMappingState.h index dba6837..b18610d 100644 --- a/src/Application/TextureMappingState.h +++ b/src/Application/TextureMappingState.h @@ -9,6 +9,7 @@ #include "DeselectTexCoordCmd.h" #include "SetNextSourceCmd.h" #include "SelNextSurfaceCmd.h" +#include "ToggleAnimatedSourceCmd.h" namespace ofx { namespace piMapper { diff --git a/src/Sources/BaseSource.h b/src/Sources/BaseSource.h index f6e0157..43f4ad5 100644 --- a/src/Sources/BaseSource.h +++ b/src/Sources/BaseSource.h @@ -20,6 +20,7 @@ class BaseSource { int getType(); string & getPath(); virtual void clear(){} + virtual void togglePause(){} // TODO: add virtual increaseReferenceCount and decreaseReferenceCount methods // and make the variable protected diff --git a/src/Sources/VideoSource.cpp b/src/Sources/VideoSource.cpp index 1658627..6ac76b3 100644 --- a/src/Sources/VideoSource.cpp +++ b/src/Sources/VideoSource.cpp @@ -51,6 +51,14 @@ void VideoSource::clear(){ loaded = false; } +void VideoSource::togglePause(){ + #ifdef TARGET_RASPBERRY_PI + omxPlayer->togglePause(); + #else + videoPlayer->setPaused(!videoPlayer->isPaused()); + #endif +} + #ifndef TARGET_RASPBERRY_PI void VideoSource::update(ofEventArgs & args){ if(videoPlayer != 0){ diff --git a/src/Sources/VideoSource.h b/src/Sources/VideoSource.h index 39ab87e..cce9aba 100644 --- a/src/Sources/VideoSource.h +++ b/src/Sources/VideoSource.h @@ -25,6 +25,7 @@ class VideoSource : public BaseSource { string & getPath(); void loadVideo(string & path); void clear(); + void togglePause(); #ifndef TARGET_RASPBERRY_PI void update(ofEventArgs & args);