From 0ef4e1f8b5bef5da84382eea6db562e4db3faff8 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Thu, 2 Aug 2018 13:51:47 +0300 Subject: [PATCH] Add ofxPiMapper::setVideoSource(fileName) --- src/Application/Application.cpp | 23 +++++++++++++++++++++++ src/Application/Application.h | 1 + src/ofxPiMapper.cpp | 4 ++++ src/ofxPiMapper.h | 1 + 4 files changed, 29 insertions(+) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 89bd67b..52b9691 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -482,6 +482,29 @@ void Application::setFboSource(std::string sourceId){ } } +void Application::setVideoSource(std::string fileName){ + vector loadedVideos = getMediaServer()->getVideoNames(); + for(auto i = 0; i < loadedVideos.size(); i++){ + if(ofIsStringInString(loadedVideos[i], fileName)){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + BaseSource * source = getSurfaceManager()->getSelectedSurface()->getSource(); + VideoSource * video = dynamic_cast(source); + video->stop(); + + getCmdManager()->exec( + new SetSourceCmd( + SourceType::SOURCE_TYPE_VIDEO, + getMediaServer()->getVideoPaths()[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 0546e4e..68628a5 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -130,6 +130,7 @@ class Application { void duplicateSurface(); void setNextSource(); void setFboSource(std::string sourceId); + void setVideoSource(std::string fileName); void addGridRow(); void addGridColumn(); void removeGridRow(); diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 5645204..cb21888 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -186,6 +186,10 @@ void ofxPiMapper::setFboSource(std::string sourceId){ _application.setFboSource(sourceId); } +void ofxPiMapper::setVideoSource(std::string fileName){ + _application.setVideoSource(fileName); +} + void ofxPiMapper::reboot(){ _application.reboot(); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index fec4a2f..038255d 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -86,6 +86,7 @@ class ofxPiMapper { // Sources, selected surface void setNextSource(); void setFboSource(std::string sourceId); + void setVideoSource(std::string fileName); // System commands void reboot();