From 8c86c8e56d5948f44ba7524284824bbc6eff952b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 12 Apr 2015 22:20:30 +0100 Subject: initial commit --- liveengine/src/playlist.cpp | 126 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 liveengine/src/playlist.cpp (limited to 'liveengine/src/playlist.cpp') 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;inote) { + for (int j=note+1;jnote) { + 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::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