We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import processing.video.*;
import processing.serial.*;
Serial myPort;
int[] valr={1021,1021,1021,1021,1021,1021,1021,1021,1021};
Movie[] endmovie = new Movie[9];
void setup(){
fullScreen();
for(int i = 0;i<9;i++){
endmovie[i] = new Movie(this,"b"+i+".mp4");
}
myPort = new Serial(this,Serial.list()[0], 9600);
myPort.bufferUntil('\n'); //buffer until meet '\n', then call the event listener
}
void draw(){
image(endmovie[0],0,0,width/3,height/3);
image(endmovie[1],width/3,0,width/3,height/3);
image(endmovie[2],width*2/3,0,width/3,height/3);
image(endmovie[3],0,height/3,width/3,height/3);
image(endmovie[4],width/3,height/3,width/3,height/3);
image(endmovie[5],width*2/3,height/3,width/3,height/3);
image(endmovie[6],0,height*2/3,width/3,height/3);
image(endmovie[7],width/3,height*2/3,width/3,height/3);
image(endmovie[8],width*2/3,height*2/3,width/3,height/3);
for(int i = 0;i<9;i++){
endmovie[i].play();
if(valr[i]>500){
endmovie[i].speed(1.0);
}else{
endmovie[i].speed(-1.0);
}
}
}
void movieEvent(Movie m){
m.read();
}
void serialEvent(Serial p) {
String inString = p.readString();
print(inString);
if(inString!=null){
String[] rec= split(inString, ',');
for(int i=0;i<9;i++){
valr[i]=int(rec[i]);
}
}
}
Answers
Edit post, highlight code, press Ctrl-o to format.
If you load the b7 movie into endmovie[7] AND endmovie[8]:
...does endmovie[8] play correctly? In other words, is the problem with b8.mp4, or is the problem with not having enough resources to play nine movies?
There could also be something going on with the serial events that you are sending to set valr[8] being incorrect, and this making that movie unresponsive (e.g. the values never drop below 500).
I am sure valr[8] is right and b8 is same with other 8 mp4s . as for whether my computer has enough resources to play nine movies,i am not sure.but i run this sketch in other two computers,then same problem happened. An error message was popped up: JNA:could not detach thread. I don't know what's it mean.
Try searching the web and the forum for the error message:
@Ryan===
how are your videos? (duration, weight, size)???
As for me, using 9 .mov (transit.mov from the video example) and setting size to 1024/768 (so !fullscreen) i can see that my computer (osx, 8MO RAM, macbookpro) is unable to show all the videos; it takes a long time to display six or seven.
The only way i have found to display 9 is using PGraphics and launching the process in setup() not with play() but with loop(); Yet with this solution also it takes a very long time to show something...
Perhaps using videos with size pre-calculated will speed the whole...Not sure about that, i have to try but i agree that it is only an ugly workaround, if it works!
@Ryan===
tried according the size width && height to the videos size (and using pgraphics): it works much more faster.
@akenatom thank you for you help, I will try.
@jeremydouglass thank you for your help.I will try my best to find what's wrong with my sketch
Also posted to issues: https://github.com/processing/processing/issues/5253
I have solved the problem that nine movies play at the time.These days,I came across an interesting thing , when I played 9 or 10 or more movies in the
sketch, the last movie always can't play normally.So I played 10 movies ,but made the tenth movie's size is 0.Then I got nine movies played as I wanted them do. codes are here.
here are codes for processing
here are codes for arduino( mega)