From 6ae491eea38055ebe3ba1154f0e916d7bbf95040 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 22 May 2017 21:31:33 +0100 Subject: directory reader in test case --- testDir/src/dirscanner.cpp | 71 ++++++++++++++++++++++++++++++++++++ testDir/src/dirscanner.h | 58 ++++++++++++++++++++++++++++++ testDir/src/main.cpp | 17 +++++++++ testDir/src/ofApp.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++ testDir/src/ofApp.h | 34 ++++++++++++++++++ 5 files changed, 269 insertions(+) create mode 100644 testDir/src/dirscanner.cpp create mode 100644 testDir/src/dirscanner.h create mode 100644 testDir/src/main.cpp create mode 100644 testDir/src/ofApp.cpp create mode 100644 testDir/src/ofApp.h (limited to 'testDir/src') diff --git a/testDir/src/dirscanner.cpp b/testDir/src/dirscanner.cpp new file mode 100644 index 0000000..feb29c1 --- /dev/null +++ b/testDir/src/dirscanner.cpp @@ -0,0 +1,71 @@ +#include "dirscanner.h" + +void playItem::play(){ + +} +void playItem::draw(){ + +} +bool playItem::isFinished(){ + +} + +void dirScanner::scan(){ + /* + parse directories and create structure + showing which folder to check at which time + */ + slots.clear(); + + ofDirectory dir(rootdir); + + dir.allowExt(""); //get directories + + dir.listDir(); + for(int i = 0; i < dir.size(); i++){ + string d=dir.getName(i); + int start = ofToInt(d.substr(0,4)); + int end = ofToInt(d.substr(5,4)); + + if (start&&end){ + slots.push_back(timeSlot(dir.getPath(i),start,end)); + ofLogNotice() << "item "<=railwaytime){ + return i; + } + } + return -1; +} + +void dirPlayer::load(){ + +} + +void dirPlayer::draw(){ + int slot=scanner->getSlotForTime(); + if (slot!=currentslot){ + if (slot>-1){ + ofLogNotice() << "entering slot "<slots[slot].path; + } + else { + ofLogNotice() << "leaving slots"; + } + currentslot=slot; + } + + +} \ No newline at end of file diff --git a/testDir/src/dirscanner.h b/testDir/src/dirscanner.h new file mode 100644 index 0000000..f78c6d5 --- /dev/null +++ b/testDir/src/dirscanner.h @@ -0,0 +1,58 @@ +#pragma once + +#include "ofMain.h" + +class timeSlot { + public: + timeSlot(std::string _p,int _s,int _e){ + path=_p; + start=_s; + end=_e; + } + string path; + int start; + int end; +}; + +class playItem { + public: + playItem(std::string _n){ + filename=_n; + } + string filename; + ofImage image; + ofVideoPlayer video; + void play(); + void draw(); + bool isFinished(); + float startTime; +}; + +class dirScanner { + //todo: compare each item in vector for reload + public: + dirScanner(std::string _d=""){ + rootdir=_d; + } + int getSlotForTime(); + string rootdir; + void scan(); + vector slots; +}; + +class dirPlayer { + public: + dirPlayer(){ + currentslot=-1; + } + dirPlayer(dirScanner *_s){ + scanner=_s; + dirPlayer(); + } + vector items; + string playdir; + int currentslot; + dirScanner *scanner; + void load(); + void draw(); +}; \ No newline at end of file diff --git a/testDir/src/main.cpp b/testDir/src/main.cpp new file mode 100644 index 0000000..c8c5551 --- /dev/null +++ b/testDir/src/main.cpp @@ -0,0 +1,17 @@ +#include "ofMain.h" +#include "ofApp.h" + +//======================================================================== +int main( ){ + +#ifdef FULLSCREEN + ofSetupOpenGL(256,256,OF_FULLSCREEN); +#else + ofSetupOpenGL(256,256,OF_WINDOW); // <-------- setup the GL context +#endif + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp( new ofApp()); + +} diff --git a/testDir/src/ofApp.cpp b/testDir/src/ofApp.cpp new file mode 100644 index 0000000..d6fdd4b --- /dev/null +++ b/testDir/src/ofApp.cpp @@ -0,0 +1,89 @@ +#include "ofApp.h" + + +//-------------------------------------------------------------- +void ofApp::setup(){ + + scanner=dirScanner(ofFilePath().getUserHomeDir()+"/Dropbox/menugrab"); + + scanner.scan(); + + player=dirPlayer(&scanner); + + ofSetFrameRate(1); +} + +//-------------------------------------------------------------- +void ofApp::update(){ + //ofBackground(255); +} + + +//-------------------------------------------------------------- +void ofApp::draw(){ + ofSetColor(255,255,255); + + + player.draw(); + +} + +//-------------------------------------------------------------- +void ofApp::keyPressed(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseEntered(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseExited(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void ofApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void ofApp::dragEvent(ofDragInfo dragInfo){ + +} +//-------------------------------------------------------------- +void ofApp::exit() +{ + +} diff --git a/testDir/src/ofApp.h b/testDir/src/ofApp.h new file mode 100644 index 0000000..2b6ed7d --- /dev/null +++ b/testDir/src/ofApp.h @@ -0,0 +1,34 @@ +#pragma once + +#include "ofMain.h" + +#include "dirscanner.h" + + + +class ofApp : public ofBaseApp{ + + public: + + void setup(); + void update(); + void draw(); + + void keyPressed(int key); + void keyReleased(int key); + void mouseMoved(int x, int y); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void mouseEntered(int x, int y); + void mouseExited(int x, int y); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + void exit(); + + dirScanner scanner; + dirPlayer player; +}; + + -- cgit v1.2.3 From e49c8555552c76b526a798f16ec5327fe443141a Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 25 May 2017 00:21:51 +0100 Subject: load logic --- testDir/src/dirscanner.cpp | 28 ++++++++++++++++++++++++---- testDir/src/dirscanner.h | 8 +++++++- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'testDir/src') diff --git a/testDir/src/dirscanner.cpp b/testDir/src/dirscanner.cpp index feb29c1..fc233d5 100644 --- a/testDir/src/dirscanner.cpp +++ b/testDir/src/dirscanner.cpp @@ -2,6 +2,12 @@ void playItem::play(){ +} +bool playItem::load(string filename){ + ofFile file(filename); + string ext=file.getExtension(); + ofLogNotice() << "item "<-1){ ofLogNotice() << "entering slot "<slots[slot].path; + load(scanner->slots[slot].path); } else { - ofLogNotice() << "leaving slots"; + ofLogNotice() << "leaving slot"; } currentslot=slot; } diff --git a/testDir/src/dirscanner.h b/testDir/src/dirscanner.h index f78c6d5..dfc0847 100644 --- a/testDir/src/dirscanner.h +++ b/testDir/src/dirscanner.h @@ -16,12 +16,18 @@ class timeSlot { class playItem { public: + playItem(){ + loaded=0; + } playItem(std::string _n){ filename=_n; + playItem(); } string filename; ofImage image; ofVideoPlayer video; + int loaded; //0- none, 1- image, 2- mov + bool load(string filename); void play(); void draw(); bool isFinished(); @@ -53,6 +59,6 @@ class dirPlayer { string playdir; int currentslot; dirScanner *scanner; - void load(); + void load(std::string path); void draw(); }; \ No newline at end of file -- cgit v1.2.3 From 7a201017da4b0aedd79bb93747c855fe63b5ede9 Mon Sep 17 00:00:00 2001 From: tim Date: Sun, 28 May 2017 22:12:27 +0100 Subject: video playback issue --- testDir/src/dirscanner.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'testDir/src') diff --git a/testDir/src/dirscanner.cpp b/testDir/src/dirscanner.cpp index fc233d5..34dec9b 100644 --- a/testDir/src/dirscanner.cpp +++ b/testDir/src/dirscanner.cpp @@ -5,9 +5,21 @@ void playItem::play(){ } bool playItem::load(string filename){ ofFile file(filename); - string ext=file.getExtension(); - ofLogNotice() << "item "<0; } void playItem::draw(){ @@ -60,13 +72,13 @@ int dirScanner::getSlotForTime(){ void dirPlayer::load(std::string path){ items.clear(); ofDirectory dir(path); - dir.allowExt("mp4"); + dir.allowExt("mkv"); dir.allowExt("mov"); dir.allowExt("jpg"); // dir.allowExt("png"); dir.listDir(); for(int i = 0; i < dir.size(); i++){ - string d=dir.getName(i); + string d=dir.getPath(i); playItem item; if (item.load(d)){ items.push_back(item); -- cgit v1.2.3 From a0e8fefd1bf241b805c4542421bdbc6a4447fdc3 Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 30 May 2017 00:50:56 +0100 Subject: no alpha or movs --- testDir/src/dirscanner.cpp | 47 +++++++++++++++++++++++++++++++++++++--------- testDir/src/dirscanner.h | 4 +++- testDir/src/main.cpp | 4 ++-- testDir/src/ofApp.cpp | 3 +-- 4 files changed, 44 insertions(+), 14 deletions(-) (limited to 'testDir/src') 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: "<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 "<