Hi,
I was wondering how to import and use some of the libraries that come
with processing specifically the video library (
http://processing.org/
reference/libraries/video/index.html) as I have run into difficulties
trying to get it to work.
I have copied the video.jar file which comes with processing and
placed it in a folder named video in the same directory as my .py
file. I can manage to import it without it throwing any errors but
it's not letting me create an instance of a Movie.
This is the example given in the reference for processing of how to
setup a movie (
http://processing.org/reference/libraries/video/
Movie.html):
import processing.video.*;
Movie myMovie;
void setup() {
size(200, 200, P2D);
myMovie = new Movie(this, "totoro.mov");
myMovie.loop();
}
This is what I have in pyprocessing, trying to recreate it:
import video
def setup():
size(600, 600, P2D)
m = None
m = Movie(this, "y.mp4") #y.mp4 is my movie file
However it's throwing an error. NameError: global name 'Movie' is not
defined. So I must be doing something wrong, the constructor according
to the reference is as follows:
Movie(parent, filename)
So I'm using the correct convention but I don't think that's what's
causing the error.
Some of the things I have tried:
To create an empty movie and then fill in the fields, but that too
causes the same NameError.
Inserting global Movie at the start of setup() doesn't change
anything either
Neither does moving the code from setup() to draw() or even it's
own function. I can't manage to find anything on Google either that
solves the issue.
Changing the way to import the module instead of using import
video, I tried using from video import * but nothing changed.
I think it has to be something to do with the way I'm trying to
initialise the movie file, but I can't figure it out.
A bit of other info that may be causing the error: I have my movie
clip in the same directory as my .pyp sketch and .mp4 is a compatible
file type as I can get it to run in processing although the audio does
cut out after 2 seconds in processing for some odd reason but not the
issue I'm worried about currently.
Also can you use the keyword this in python to specify the file
location?
Thanks in advance,
Benjamin McFetridge