1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#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();
printf("unlocking thread\n");
}
}
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
}
|