From 5a65f6f4205bf07402bb013e445484dd79dd7dcd Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Fri, 10 Aug 2018 17:30:12 +0200 Subject: [PATCH] Attempt to fix VideoSource looping on RPi --- src/Sources/VideoSource.cpp | 10 ++++++++++ src/Sources/VideoSource.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/Sources/VideoSource.cpp b/src/Sources/VideoSource.cpp index 8c828f2..eb08fc2 100644 --- a/src/Sources/VideoSource.cpp +++ b/src/Sources/VideoSource.cpp @@ -9,6 +9,7 @@ bool VideoSource::useHDMIForAudio = false; VideoSource::VideoSource(){ loadable = true; loaded = false; + _loop = true; type = SourceType::SOURCE_TYPE_VIDEO; #ifdef TARGET_RASPBERRY_PI _omxPlayer = 0; @@ -37,6 +38,7 @@ void VideoSource::loadVideo(std::string & filePath){ } void VideoSource::setLoop(bool loop){ + _loop = loop; #ifdef TARGET_RASPBERRY_PI if(_omxPlayer == 0) return; if(loop) _omxPlayer->enableLooping(); @@ -90,6 +92,14 @@ void VideoSource::stop(){ _videoPlayer->update(); } } +#else + void VideoSource::update(ofEventArgs & args){ + if(!_loop && _omxPlayer != 0){ + if(_omxPlayer->getGurrentFrame() >= _omxPlayer->getTotalNumFrames() - 1){ + _omxPlayer->setPaused(true); + } + } + } #endif } // namespace piMapper diff --git a/src/Sources/VideoSource.h b/src/Sources/VideoSource.h index faee4b5..edfd6bb 100644 --- a/src/Sources/VideoSource.h +++ b/src/Sources/VideoSource.h @@ -41,6 +41,8 @@ class VideoSource : public BaseSource { unique_ptr _videoPlayer; bool _initialVolumeSet; #endif + + bool _loop; };