diff options
Diffstat (limited to 'testDir/src')
| -rw-r--r-- | testDir/src/dirscanner.cpp | 47 | ||||
| -rw-r--r-- | testDir/src/dirscanner.h | 4 | ||||
| -rw-r--r-- | testDir/src/main.cpp | 4 | ||||
| -rw-r--r-- | testDir/src/ofApp.cpp | 3 |
4 files changed, 44 insertions, 14 deletions
diff --git a/testDir/src/dirscanner.cpp b/testDir/src/dirscanner.cpp index 34dec9b..f3aa974 100644 --- a/testDir/src/dirscanner.cpp +++ b/testDir/src/dirscanner.cpp @@ -1,9 +1,17 @@ #include "dirscanner.h" void playItem::play(){ - + if (video.isLoaded()){ + video.play(); + ofLogNotice() << "playing video: "<<filename; + } + if (image.isAllocated()){ + ofLogNotice() << "playing still: "<<filename; + } + startTime=ofGetElapsedTimef(); } -bool playItem::load(string filename){ +bool playItem::load(string _filename){ + filename=_filename; ofFile file(filename); string ext=ofToLower(file.getExtension()); loaded=0; @@ -13,7 +21,7 @@ bool playItem::load(string filename){ loaded=1; } } - if (ext=="mkv"||ext=="mov"){ + if (ext=="mp4"||ext=="mov"){ if (video.load(filename)){ ofLogNotice() << "loaded clip: "<<filename; loaded=2; @@ -22,10 +30,23 @@ bool playItem::load(string filename){ return loaded>0; } void playItem::draw(){ + if (image.isAllocated()){ -} -bool playItem::isFinished(){ + //ofEnableAlphaBlending(); + //ofSetColor(255,255,255,1.0); + image.draw(0,0); + //ofDisableAlphaBlending(); + if (ofGetElapsedTimef()-startTime>5.0){ + isFinished=true; + } + } + if (video.isLoaded()){ + video.draw(0,0); + if (video.getIsMovieDone()){ + isFinished=true; + } + } } void dirScanner::scan(){ @@ -45,7 +66,7 @@ void dirScanner::scan(){ int start = ofToInt(d.substr(0,4)); int end = ofToInt(d.substr(5,4)); - if (start&&end){ + if (end){ slots.push_back(timeSlot(dir.getPath(i),start,end)); ofLogNotice() << "directory "<<i<<": "<<start<<" - "<<end<<" "<<dir.getPath(i); @@ -72,10 +93,10 @@ int dirScanner::getSlotForTime(){ void dirPlayer::load(std::string path){ items.clear(); ofDirectory dir(path); - dir.allowExt("mkv"); + dir.allowExt("mp4"); dir.allowExt("mov"); dir.allowExt("jpg"); - // dir.allowExt("png"); + dir.allowExt("png"); dir.listDir(); for(int i = 0; i < dir.size(); i++){ string d=dir.getPath(i); @@ -84,6 +105,9 @@ void dirPlayer::load(std::string path){ items.push_back(item); } } + currentItem=0; + ofLogNotice() << "found "<<items.size()<<" items"; + } void dirPlayer::draw(){ @@ -98,6 +122,11 @@ void dirPlayer::draw(){ } currentslot=slot; } - + if (items[currentItem].isFinished){ + items[currentItem].isFinished=false; + currentItem=(currentItem+1)%items.size(); + items[currentItem].play(); + } + items[currentItem].draw(); }
\ No newline at end of file diff --git a/testDir/src/dirscanner.h b/testDir/src/dirscanner.h index dfc0847..cddd42f 100644 --- a/testDir/src/dirscanner.h +++ b/testDir/src/dirscanner.h @@ -18,6 +18,7 @@ class playItem { public: playItem(){ loaded=0; + isFinished=false; } playItem(std::string _n){ filename=_n; @@ -30,7 +31,7 @@ class playItem { bool load(string filename); void play(); void draw(); - bool isFinished(); + bool isFinished; float startTime; }; @@ -61,4 +62,5 @@ class dirPlayer { dirScanner *scanner; void load(std::string path); void draw(); + int currentItem; };
\ No newline at end of file diff --git a/testDir/src/main.cpp b/testDir/src/main.cpp index c8c5551..120f5a0 100644 --- a/testDir/src/main.cpp +++ b/testDir/src/main.cpp @@ -5,9 +5,9 @@ int main( ){ #ifdef FULLSCREEN - ofSetupOpenGL(256,256,OF_FULLSCREEN); + ofSetupOpenGL(1080,1920,OF_FULLSCREEN); #else - ofSetupOpenGL(256,256,OF_WINDOW); // <-------- setup the GL context + ofSetupOpenGL(1080,1920,OF_WINDOW); // <-------- setup the GL context #endif // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN diff --git a/testDir/src/ofApp.cpp b/testDir/src/ofApp.cpp index d6fdd4b..9ac9e12 100644 --- a/testDir/src/ofApp.cpp +++ b/testDir/src/ofApp.cpp @@ -10,7 +10,7 @@ void ofApp::setup(){ player=dirPlayer(&scanner); - ofSetFrameRate(1); + ofSetFrameRate(5); } //-------------------------------------------------------------- @@ -22,7 +22,6 @@ void ofApp::update(){ //-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255,255,255); - player.draw(); |
