diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 05a1973..084b01b 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -652,5 +652,17 @@ void Application::toggleLayerPanel(){ } } +void Application::restart(){ + _mediaServer.restart(); +} + +void Application::pause(){ + _mediaServer.pause(); +} + +void Application::resume(){ + _mediaServer.resume(); +} + } // namespace piMapper } // namespace ofx diff --git a/src/Application/Application.h b/src/Application/Application.h index 34028af..ff5e449 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -155,6 +155,11 @@ class Application { void reboot(); void shutdown(); + // video play control + void restart(); + void pause(); + void resume(); + protected: void setState(ApplicationBaseMode * st); diff --git a/src/MediaServer/MediaServer.cpp b/src/MediaServer/MediaServer.cpp index dada7d1..d9dd739 100644 --- a/src/MediaServer/MediaServer.cpp +++ b/src/MediaServer/MediaServer.cpp @@ -57,6 +57,32 @@ void MediaServer::draw(){ } } +void MediaServer::restart() { + typedef map ::iterator it_type; + for(it_type i = loadedSources.begin(); i != loadedSources.end(); i++){ + if(i->second->getType() == SourceType::SOURCE_TYPE_VIDEO){ + static_cast (i->second)->restart(); + } + } +} +void MediaServer::pause() { + typedef map ::iterator it_type; + for(it_type i = loadedSources.begin(); i != loadedSources.end(); i++){ + if(i->second->getType() == SourceType::SOURCE_TYPE_VIDEO){ + static_cast (i->second)->pause(); + } + } +} +void MediaServer::resume() { + typedef map ::iterator it_type; + for(it_type i = loadedSources.begin(); i != loadedSources.end(); i++){ + if(i->second->getType() == SourceType::SOURCE_TYPE_VIDEO){ + static_cast (i->second)->resume(); + } + } +} + + int MediaServer::getNumImages(){ return imageWatcher.getFilePaths().size(); diff --git a/src/MediaServer/MediaServer.h b/src/MediaServer/MediaServer.h index 51bf721..8962895 100644 --- a/src/MediaServer/MediaServer.h +++ b/src/MediaServer/MediaServer.h @@ -52,6 +52,10 @@ class MediaServer { void update(); void draw(); + void restart(); + void pause(); + void resume(); + int getNumVideos(); int getNumImages(); int getNumFboSources(); // new diff --git a/src/Sources/VideoSource.cpp b/src/Sources/VideoSource.cpp index fc0df92..72e1092 100644 --- a/src/Sources/VideoSource.cpp +++ b/src/Sources/VideoSource.cpp @@ -106,5 +106,29 @@ void VideoSource::stop(){ } #endif +void VideoSource::restart(){ + #ifdef TARGET_RASPBERRY_PI + _omxPlayer->restartMovie(); + #else + _videoPlayer->setPosition(0); + _videoPlayer->play(); + #endif +} + +void VideoSource::pause() { + #ifdef TARGET_RASPBERRY_PI + _omxPlayer->setPaused(true); + #else + _videoPlayer->setPaused(true); + #endif +} +void VideoSource::resume() { + #ifdef TARGET_RASPBERRY_PI + _omxPlayer->setPaused(false); + #else + _videoPlayer->setPaused(false); + #endif +} + } // namespace piMapper } // namespace ofx diff --git a/src/Sources/VideoSource.h b/src/Sources/VideoSource.h index d0cea99..f1af7d3 100644 --- a/src/Sources/VideoSource.h +++ b/src/Sources/VideoSource.h @@ -30,6 +30,9 @@ class VideoSource : public BaseSource { void togglePause(); void stop(); void update(ofEventArgs & args); + void restart(); + void pause(); + void resume(); private: diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index e8bb1e4..e2131e3 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -284,3 +284,15 @@ ofx::piMapper::Mode ofxPiMapper::getMode(){ void ofxPiMapper::toggleLayerPanel(){ _application.toggleLayerPanel(); } + +void ofxPiMapper::restart() { + _application.restart(); +} + +void ofxPiMapper::pause() { + _application.pause(); +} + +void ofxPiMapper::resume() { + _application.resume(); +} diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 1271dd8..2797f46 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -94,6 +94,11 @@ class ofxPiMapper { void reboot(); void shutdown(); + // video play control + void restart(); + void pause(); + void resume(); + private: ofx::piMapper::Application _application; };