Hey
So, working in eclipse, I created a video player within a class that is a little ways down in terms of classes from the main class. The class structure for it is as follows : Main class > contentplayer class > to mediaPlayer superclass > video player and sound player classes that both extend the mediaPlayer super class.
The problem I'm having is that when I load in a new video file, I can't seem to access the available() method. It always comes through as false even when the sound is playing. Taking that out allows me to play the video and the sound but they are out of sync. Can anyone think of away I can get the available method to turn out true? I cant use the movieEvent method of the Movie Class in the Processing video library because the main class as it is now doesn't have access to the Movie Object in the video player. here's some sample code to try to explain what I mean
So, working in eclipse, I created a video player within a class that is a little ways down in terms of classes from the main class. The class structure for it is as follows : Main class > contentplayer class > to mediaPlayer superclass > video player and sound player classes that both extend the mediaPlayer super class.
The problem I'm having is that when I load in a new video file, I can't seem to access the available() method. It always comes through as false even when the sound is playing. Taking that out allows me to play the video and the sound but they are out of sync. Can anyone think of away I can get the available method to turn out true? I cant use the movieEvent method of the Movie Class in the Processing video library because the main class as it is now doesn't have access to the Movie Object in the video player. here's some sample code to try to explain what I mean
- // user uploads a file here all that works and it hits this method with the file name string in video player
- public void loadMedia(String fileName){
currentFileName = fileName;
ScreenManager.setScreenType(2);
mainMovie = new Movie(p, currentFileName);
mainMovie.pause();
if(mainMovie.width > 1){
PApplet.println("ready to play");// this doesnt print out so i dont even know if this is doing anything
mainMovie.play();
}
}
//this method is called from the draw() of the main through the content player to this video player class- public void playMedia(){
PApplet.println(mainMovie.available());
mainMovie.read();
p.beginShape();
p.texture(mainMovie);
p.vertex(0,0, 0,0);
p.vertex(p.width, 0, p.width,0);
p.vertex(p.width, p.height, p.height, p.width);
p.vertex(0, p.height, 0, p.height);
p.endShape(PApplet.CLOSE);
}
// this version works but is out of sync because I can't check to see that a new frame is available
public void playMedia(){- if(mainMovie.available(){
PApplet.println(mainMovie.available());
mainMovie.read();
p.beginShape();
p.texture(mainMovie);
p.vertex(0,0, 0,0);
p.vertex(p.width, 0, p.width,0);
p.vertex(p.width, p.height, p.height, p.width);
p.vertex(0, p.height, 0, p.height);
p.endShape(PApplet.CLOSE); - }
} - //this version doesn't work because mainMovie.available() is never true so the sound plays but no video :(
and I cant use the movieEvent() function because that gets called in the main class and mainMovie is a private variable to this videoPlayer class
1