-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadThumbnails.pde
41 lines (37 loc) · 1.22 KB
/
loadThumbnails.pde
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
PImage[] thumbnails;
void checkThumbnails(){
loadThumbnails();
String[] thumbs=loadStrings("data/thumbnails.txt");
thumbnails = new PImage[Playlist.length];
for (int i = 0; i<Playlist.length; i++){
if(!(Playlist[i].substring(0, Playlist[i].length()-4)).equals(thumbs[i].substring(0, thumbs[i].length()-4))){
println("creating thumbnails");
GSMovie tmp=new GSMovie(this,"videos/"+Playlist[i]);
tmp.play();
while(tmp.width<10){//waiting while video not completely loaded
}
tmp.jump(tmp.duration()/2);
tmp.pause();
tmp.resize(128,72);
tmp.save("data/thumbnails/"+Playlist[i].substring(0, Playlist[i].length()-4)+".png");
tmp.stop();
tmp.delete();
}
thumbnails[i]=loadImage("data/thumbnails/"+Playlist[i].substring(0, Playlist[i].length()-4)+".png");
thumbnails[i].resize(45,45);
}
}
void loadThumbnails(){
// Path
String path = sketchPath+"/data/thumbnails/";
// println("Listing all filenames in "+path);
String[] filenames = listFileNames(path);
// println(filenames);
if(filenames==null || filenames.length!=Playlist.length){
filenames = new String[Playlist.length];
for (int i = 0; i<Playlist.length; i++){
filenames[i]=".png";
}
}
saveStrings("data/thumbnails.txt", filenames);
}