diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 52b9691..f2f929d 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -488,9 +488,12 @@ void Application::setVideoSource(std::string fileName){ if(ofIsStringInString(loadedVideos[i], fileName)){ if(getSurfaceManager()->getSelectedSurface() != 0){ BaseSource * source = getSurfaceManager()->getSelectedSurface()->getSource(); - VideoSource * video = dynamic_cast(source); - video->stop(); - + + if(source->getType() == SOURCE_TYPE_VIDEO){ + VideoSource * video = dynamic_cast(source); + video->stop(); + } + getCmdManager()->exec( new SetSourceCmd( SourceType::SOURCE_TYPE_VIDEO, @@ -505,6 +508,32 @@ void Application::setVideoSource(std::string fileName){ } } +void Application::setImageSource(std::string fileName){ + vector loadedImages = getMediaServer()->getImageNames(); + for(auto i = 0; i < loadedImages.size(); i++){ + if(ofIsStringInString(loadedImages[i], fileName)){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + BaseSource * source = getSurfaceManager()->getSelectedSurface()->getSource(); + + if(source->getType() == SOURCE_TYPE_VIDEO){ + VideoSource * video = dynamic_cast(source); + video->stop(); + } + + getCmdManager()->exec( + new SetSourceCmd( + SourceType::SOURCE_TYPE_IMAGE, + getMediaServer()->getImagePaths()[i], + getSurfaceManager()->getSelectedSurface(), + &Gui::instance()->getSourcesEditorWidget())); + }else{ + getCmdManager()->exec(new SelNextSurfaceCmd(getSurfaceManager())); + } + break; + } + } +} + void Application::addGridRow(){ if(getSurfaceManager()->getSelectedSurface() != 0){ if(getSurfaceManager()->getSelectedSurface()->getType() == diff --git a/src/Application/Application.h b/src/Application/Application.h index 68628a5..1715d69 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -131,6 +131,7 @@ class Application { void setNextSource(); void setFboSource(std::string sourceId); void setVideoSource(std::string fileName); + void setImageSource(std::string fileName); void addGridRow(); void addGridColumn(); void removeGridRow(); diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index cb21888..5f235e2 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -190,6 +190,10 @@ void ofxPiMapper::setVideoSource(std::string fileName){ _application.setVideoSource(fileName); } +void ofxPiMapper::setImageSource(std::string fileName){ + _application.setImageSource(fileName); +} + void ofxPiMapper::reboot(){ _application.reboot(); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 038255d..704fbb3 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -87,6 +87,7 @@ class ofxPiMapper { void setNextSource(); void setFboSource(std::string sourceId); void setVideoSource(std::string fileName); + void setImageSource(std::string fileName); // System commands void reboot();