Browse Source

Attempt to fix video loop problems on RPi

master
Krisjanis Rijnieks 7 years ago
parent
commit
67de16ab91
  1. 15
      src/Sources/VideoSource.cpp

15
src/Sources/VideoSource.cpp

@ -41,11 +41,7 @@ void VideoSource::loadVideo(std::string & filePath){
void VideoSource::setLoop(bool loop){ void VideoSource::setLoop(bool loop){
_loop = loop; _loop = loop;
#ifdef TARGET_RASPBERRY_PI #ifndef TARGET_RASPBERRY_PI
if(_omxPlayer == 0) return;
if(loop) _omxPlayer->enableLooping();
else _omxPlayer->disableLooping();
#else
if(_videoPlayer == 0) return; if(_videoPlayer == 0) return;
if(loop) _videoPlayer->setLoopState(OF_LOOP_NORMAL); if(loop) _videoPlayer->setLoopState(OF_LOOP_NORMAL);
else _videoPlayer->setLoopState(OF_LOOP_NONE); else _videoPlayer->setLoopState(OF_LOOP_NONE);
@ -54,15 +50,17 @@ void VideoSource::setLoop(bool loop){
void VideoSource::clear(){ void VideoSource::clear(){
texture = 0; texture = 0;
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI
OMXPlayerCache::instance()->unload(path); OMXPlayerCache::instance()->unload(path);
#else #else
ofRemoveListener(ofEvents().update, this, &VideoSource::update);
_videoPlayer->stop(); _videoPlayer->stop();
_videoPlayer->close(); _videoPlayer->close();
_videoPlayer.reset(); _videoPlayer.reset();
_videoPlayer = 0; _videoPlayer = 0;
#endif #endif
ofRemoveListener(ofEvents().update, this, &VideoSource::update);
loaded = false; loaded = false;
} }
@ -100,11 +98,6 @@ void VideoSource::stop(){
if(_omxPlayer->getCurrentFrame() >= _omxPlayer->getTotalNumFrames() - 1){ if(_omxPlayer->getCurrentFrame() >= _omxPlayer->getTotalNumFrames() - 1){
_omxPlayer->setPaused(true); _omxPlayer->setPaused(true);
} }
// Make it double safe and pause for sure
if((float)_omxPlayer->getMediaTime() >= (float)_omxPlayer->getDurationInSeconds()){
_omxPlayer->setPaused(true);
}
} }
} }
#endif #endif

Loading…
Cancel
Save