We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I am working on this code using Keystone framework and I keep getting a Null Pointer Exception even though the video files I have labeled on my computer are word for word what I have in my code. I had also made these videos on Adobe Premier and synced the music to all 6 videos, but when I play the code the music does not sync up to the Mask videos which are supposed to be singing along to the music. I'm Confused as to why the 6 videos aren't loading at the same time and therefore causing the videos to be out of sync. I hope this problem can be solved.
Here is my code:
/* Import Keystone Framework */
import deadpixel.keystone.*;
/* Processing Video Framework */
import processing.video.*;
Keystone ks;
CornerPinSurface surface;
CornerPinSurface surface2;
CornerPinSurface surface3;
CornerPinSurface surface4;
CornerPinSurface surface5;
CornerPinSurface surface6;
PGraphics offscreen;
PGraphics offscreen2;
PGraphics offscreen3;
PGraphics offscreen4;
PGraphics offscreen5;
PGraphics offscreen6;
Movie myMovie;
Movie myMovie2;
Movie myMovie3;
Movie myMovie4;
Movie myMovie5;
Movie myMovie6;
void setup() {
size(1200, 600, P3D);
ks = new Keystone(this);
surface = ks.createCornerPinSurface(320, 240, 20);
offscreen = createGraphics(320, 240, P3D);
surface2 = ks.createCornerPinSurface(320, 240, 20);
offscreen2 = createGraphics(320, 240, P3D);
surface3 = ks.createCornerPinSurface(320, 240, 20);
offscreen3 = createGraphics(320, 240, P3D);
surface4 = ks.createCornerPinSurface(320, 240, 20);
offscreen4 = createGraphics(320, 240, P3D);
surface5 = ks.createCornerPinSurface(320, 240, 20);
offscreen5 = createGraphics(320, 240, P3D);
surface6 = ks.createCornerPinSurface(320, 240, 20);
offscreen6 = createGraphics(320, 240, P3D);
myMovie = new Movie(this, "mask1.mov");
//myMovie.loop();
myMovie.pause();
myMovie2 = new Movie(this, "mask2.mov");
//myMovie2.loop();
myMovie2.pause();
myMovie3 = new Movie(this, "mask3.mov");
//myMovie3.loop();
myMovie3.pause();
myMovie4 = new Movie(this, "mask4.mov");
//myMovie4.loop();
myMovie4.pause();
myMovie5 = new Movie(this, "mask5.mov");
// myMovie5.loop();
myMovie5.pause();
myMovie6 = new Movie(this, "mask6.mov");
//myMovie6.loop();
myMovie6.pause();
}
void draw() {
PVector surfaceMouse = surface.getTransformedMouse();
offscreen.beginDraw();
offscreen.background(255);
offscreen.fill(0, 255, 0);
offscreen.image(myMovie,0,0,320,240);
offscreen.endDraw();
offscreen2.beginDraw();
offscreen2.background(255);
offscreen2.fill(0, 255, 0);
offscreen2.image(myMovie2,0,0,320,240);
offscreen2.endDraw();
offscreen3.beginDraw();
offscreen3.background(255);
offscreen3.fill(0, 255, 0);
offscreen3.image(myMovie3,0,0,320,240);
offscreen3.endDraw();
offscreen4.beginDraw();
offscreen4.background(255);
offscreen4.fill(0, 255, 0);
offscreen4.image(myMovie4,0,0,320,240);
offscreen4.endDraw();
offscreen5.beginDraw();
offscreen5.background(255);
offscreen5.fill(0, 255, 0);
offscreen5.image(myMovie5,0,0,320,240);
offscreen5.endDraw();
offscreen6.beginDraw();
offscreen6.background(255);
offscreen6.fill(0, 255, 0);
offscreen6.image(myMovie6,0,0,320,240);
offscreen6.endDraw();
background(0);
surface.render(offscreen);
surface2.render(offscreen2);
surface3.render(offscreen3);
surface4.render(offscreen4);
surface5.render(offscreen5);
surface6.render(offscreen6);
}
void keyPressed() {
switch(key) {
case 'c':
// enter/leave calibration mode, where surfaces can be warped
// and moved
ks.toggleCalibration();
break;
case 'l':
// loads the saved layout
ks.load();
break;
case 's':
// saves the layout
ks.save();
break;
case 'p':
myMovie.play();
myMovie2.play();
myMovie3.play();
myMovie4.play();
myMovie5.play();
myMovie6.play();
break;
}
}
void movieEvent(Movie m) {
m.read();
}
Answers
Which line is highlighted when the NPE is thrown?
Honestly, I'm not seeing any straightforward reason for this (like you not having defined some variable). So likely, it's one of the methods/constructors you've called returning null, which then will throw an NPE, as null does not contain any of methods called (or any methods, for that matter).
As aforementioned, you should be more descriptive, like saying:
We can't run your program b/c we don't have those files. And we're not sëers! [-(
I know that Movie is a subclass of PImage.
I wonder whether its internal pixels array is already instantiated before using play()? :-??