diff options
| author | Tim Redfern <tim@eclectronics.org> | 2015-04-12 22:20:30 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2015-04-12 22:20:30 +0100 |
| commit | 8c86c8e56d5948f44ba7524284824bbc6eff952b (patch) | |
| tree | 704dc88be2f22c69b4d16838092bc83cf692a75b /liveengine/src/playlist.cpp | |
Diffstat (limited to 'liveengine/src/playlist.cpp')
| -rwxr-xr-x | liveengine/src/playlist.cpp | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/liveengine/src/playlist.cpp b/liveengine/src/playlist.cpp new file mode 100755 index 0000000..683cd3c --- /dev/null +++ b/liveengine/src/playlist.cpp @@ -0,0 +1,126 @@ +#include "playlist.h"
+
+playlist::playlist()
+{ + name=""; + thumbnail.allocate(128,128,GL_RGB); + thumbnailed=false;
+} + +void playlist::load(string _name){ + //printf("loading %s\n",_name.c_str()); + + + if( !XML.loadFile(_name) ){
+ printf("unable to load %s check data/ folder\n",_name.c_str());
+ }else { + printf("starting loader thread\n"); + loadimg(); //how to do this from the worker thread??? + startThread(false, false); //blocking, verbose + } + + + +} + +void playlist::threadedFunction(){ + if( lock() ){ + loadLayers(); + unlock(); + } +}
+ +void playlist::loadLayers(){ + int numLayers=0; + layers.clear(); + name=XML.getAttribute("playlist", "name", ""); + float speed=XML.getAttribute("playlist", "speed", 0); + if(XML.pushTag("playlist")) {
+ numLayers=XML.getNumTags("svglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("svglayer", "file", "",i);
+ printf("loading %s: \n",s.c_str());
+ layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(XML.getAttribute("svglayer", "file", "",i));
+ } + thumbnailed=false;
+ } + numLayers=XML.getNumTags("movlayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("movlayer", "file", "",i);
+ printf("loading %s: \n",s.c_str()); + int note=XML.getAttribute("movlayer", "note", 0,i); + int endnote=XML.getAttribute("movlayer", "endnote", 0,i);
+ layers[note]=new videolayer(XML.getAttribute("movlayer", "file", "",i),note,endnote,speed); + if (endnote>note) { + for (int j=note+1;j<endnote;j++) { + layers[j]=layers[note]; + } + }
+ } + thumbnailed=false;
+ } + numLayers=XML.getNumTags("imglayer"); + if(numLayers) { + for (int i=0;i<numLayers;i++) { + string s=XML.getAttribute("imglayer", "files", "",i); + printf("loading %s: \n",s.c_str()); + int note=XML.getAttribute("imglayer", "note", 0,i); + int endnote=XML.getAttribute("imglayer", "endnote", 0,i); + float rate=XML.getAttribute("imglayer", "rate", 0.0,i); + int frames=XML.getAttribute("imglayer", "frames", 0,i); + int start=XML.getAttribute("imglayer", "start", 1,i); + layers[note]=new imglayer(s,frames,start,rate,note,endnote); + if (endnote>note) { + for (int j=note+1;j<=endnote;j++) { + layers[j]=layers[note]; + } + } + } + thumbnailed=false; + } + XML.popTag();
+ } + +} + +void playlist::makeThumbnail(){ + if (layers.size()) { + thumbnail.begin(); + ofBackground(0,0,0); + ofPushMatrix(); + ofTranslate(64,64); + ofScale(0.2,0.2,0.2); + ofTranslate(-64,-64); + map<int,layer*>::iterator i=layers.begin(); + i->second->draw(1.0,64,64,0.0); + ofPopMatrix(); + thumbnail.end(); + thumbnailed=true; + } +} + + +void playlist::loadimg(){ + int numLayers=0; + layers.clear(); + if(XML.pushTag("playlist")) {
+ numLayers=XML.getNumTags("imglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("imglayer", "file", "",i);
+ printf("%s: ",s.c_str());
+ layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
+ }
+ }
+ else printf("no IMG layers loaded!\n"); + XML.popTag();
+ } + +} +
+playlist::~playlist()
+{
+ //dtor
+}
|
