Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Getting sound but no picture?

$
0
0
The video appears to be playing as I am getting the sound when I run the sketch but no picture, I thought it might be the background but changing it with a trial and error approach has no effect. Any ideas?

  1. import processing.video.*;
  2. Movie myMovie;

  3. int passedTime;
  4. int savedTime;
  5. int totalTime = 10000;

  6. int rainNum = 100;
  7. ArrayList rain = new ArrayList();
  8. ArrayList splash = new ArrayList();
  9. float current;
  10. float reseed = random(0, .2);

  11. void setup()
  12. {
  13.  
  14.   myMovie = new Movie(this, "lightning3.mov");
  15.   
  16.   size(600, 600, P3D);
  17.   colorMode(HSB, 100);
  18.  background(0);
  19.   rain.add(new Rain());
  20.   current = millis();
  21.   
  22. }
  23. void draw()
  24. {
  25.   savedTime = millis();
  26.   
  27.  // background (0);
  28.   
  29.   if (passedTime < totalTime) {
  30.     
  31.     myMovie.loop();
  32.   
  33. image(myMovie,0,0);
  34.  delay (25);
  35.   
  36.   }
  37.   
  38.   else {
  39.   
  40.   strokeWeight(9);
  41.   stroke(255, 2, 2);
  42.   line (width/2.0, 0, 100, 
  43.   width/2.0, 0, 200 );
  44.   if ((millis()-current)/1>reseed && 
  45.     rain.size()<150)
  46.   {
  47.     rain.add(new Rain());
  48.     float reseed = random(0, .2);
  49.     current = millis();
  50.   }
  51.   for (int i=0 ; i<rain.size() ; i++)
  52.   {
  53.     Rain rainT = (Rain) rain.get(i);
  54.     rainT.calculate();
  55.     rainT.draw();
  56.     if (rainT.position.y>height)
  57.     {
  58.       for (int k = 0 ; k<random(5,10) ; k++)
  59.       {
  60.         splash.add(new Splash(rainT.position.x, height, rainT.position.z));
  61.       }
  62.       rain.remove(i);
  63.       float rand = random(0, 100);
  64.       if (rand>10&&rain.size()<150)
  65.         rain.add(new Rain());
  66.     }
  67.   }
  68.   for (int i=0 ; i<splash.size() ; i++)
  69.   {
  70.     Splash spl = (Splash) splash.get(i);
  71.     spl.calculate();
  72.     spl.draw();
  73.     if (spl.position.y>height)
  74.       splash.remove(i);
  75.   }
  76.   }
  77.   

  78. }

  79. // ==========================================
  80. public class Rain
  81. {
  82.   PVector position, pposition, speed;
  83.   float col;
  84.   public Rain()
  85.   {
  86.     position = new PVector(random(0, width), -500, random(0, 800));
  87.     pposition = position;
  88.     speed = new PVector(0, 0);
  89.     col = random(30, 100);
  90.   }
  91.   void draw()
  92.   {
  93.     stroke(100, col);
  94.     strokeWeight(2);
  95.     line(position.x, position.y, position.z, pposition.x, pposition.y, position.z);
  96.     //ellipse(position.x,position.y,5,5);
  97.   }
  98.   void calculate()
  99.   {
  100.     pposition = new PVector(position.x, position.y);
  101.     gravity();
  102.   }
  103.   void gravity()
  104.   {
  105.     speed.y += .2;
  106.     speed.x += .01;
  107.     position.add(speed);
  108.   }
  109. }
  110. public class Splash
  111. {
  112.   PVector position, speed;
  113.   public Splash(float x, float y, float z)
  114.   {
  115.     float angle = random(PI, TWO_PI);
  116.     float distance = random(1, 5);
  117.     float xx = cos(angle)*distance;
  118.     float yy = sin(angle)*distance;
  119.     position = new PVector(x, y, z);
  120.     speed = new PVector(xx, yy);
  121.   }
  122.   public void draw()
  123.   {
  124.     strokeWeight(1);
  125.     stroke(100, 50);
  126.     fill(100, 100);
  127.     // ellipse(position.x, position.y, 2, 2 );
  128.     point(position.x, position.y, position.z );
  129.   }
  130.   void calculate()
  131.   {
  132.     gravity();
  133.     speed.x*=0.98;
  134.     speed.y*=0.98;
  135.     position.add(speed);
  136.   }
  137.   void gravity()
  138.   {
  139.     speed.y+=.2;
  140.   }
  141. }





Viewing all articles
Browse latest Browse all 1768

Trending Articles