when i play nine mp4s using video library,the nineth mp4 can't play as other eight mp4.

edited September 2017 in Arduino
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.

  • edited September 2017

    If you load the b7 movie into endmovie[7] AND endmovie[8]:

    endmovie[0] = new Movie(this,"b0.mp4");
    endmovie[1] = new Movie(this,"b1.mp4");
    endmovie[2] = new Movie(this,"b2.mp4");
    endmovie[3] = new Movie(this,"b3.mp4");
    endmovie[4] = new Movie(this,"b4.mp4");
    endmovie[5] = new Movie(this,"b5.mp4");
    endmovie[6] = new Movie(this,"b6.mp4");
    endmovie[7] = new Movie(this,"b7.mp4");
    endmovie[8] = new Movie(this,"b7.mp4");
    

    ...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.

  • @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

  • 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.

  • import processing.video.*;  
    import processing.serial.*; 
    Serial myPort;
    int[] valr={1021,1021,1021,1021,1021,1021,1021,1021,1021,1021};
    Movie[] endmovie = new Movie[10];
    void setup(){
      noCursor();
      fullScreen(1);
      for(int i = 0;i<10;i++){
        endmovie[i] = new Movie(this,"transit.mov");
      }
      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+20,height/3);
      image(endmovie[2],width*2/3,0,width/3,height/3);
      image(endmovie[3],0,height/3,width/3,height/3+20);
      image(endmovie[4],width/3,height/3,width/3+20,height/3+20);
      image(endmovie[5],width*2/3,height/3,width/3,height/3+205);
      image(endmovie[6],0,height*2/3,width/3,height/3);
      image(endmovie[7],width/3,height*2/3,width/3+20,height/3);
      image(endmovie[8],width*2/3,height*2/3,width/3,height/3);
      image(endmovie[9],0,0,0,0);
    for(int i = 0;i<10;i++){
    
      endmovie[i].play();
       if(valr[i]>500){
        endmovie[i].speed(2.0);
       }else{ 
        endmovie[i].speed(-2.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<10;i++){
         valr[i]=int(rec[i]);
       }  
      }  
    }  
    

    here are codes for processing

  •  int inPin[10] = {A0,A1,A2,A3,A4,A5,A6,A7,A8,A9};
     int valt[10]={1021,1021,1021,1021,1021,1021,1021,1021,1021,1021};
    void setup(){
      for (int j=0;j<10;j++){
        pinMode(inPin[j],INPUT_PULLUP);//
      }
      Serial.begin(9600);//
    }
     void   loop(){
      for(int i=0;i<10;i++){
        valt[i] = analogRead(inPin[i]);
          Serial.print(valt[i]);
          if(i!=9){
            Serial.print(","); 
          }
        }
      Serial.print("\n"); 
     }
    

    here are codes for arduino( mega)

Sign In or Register to comment.