@NYX @enguyen
Hi, this is in direct response to some queries on the posting on the "How to trace a memory leak?"
I've recently made a bunch of updates to jmcvideo. Here is the source code for the various switchVideo methods:
Code:
public void switchVideo(String filename)
{
mp.setSource(VideoUtils.toURI(new File(parent.dataPath(filename))));
mp.play();
}
public void switchVideo(File file)
{
mp.setSource(VideoUtils.toURI(file));
mp.play();
}
public void switchVideo(URL url)
{
mp.setSource(VideoUtils.toURI(url));
mp.play();
}
public void switchVideo(URI uri)
{
mp.setSource(uri);
mp.play();
}
The "mp" variable stands for the current MediaProvider. Since creating a new MediaProvider uses native resources, it may be a better idea to reuse a single MediaProvider via the swtichVideo method when you want to start playing a second movie. The bug that didn't let you use the relative dataPath has been fixed. If you want to switch to a video that is not in the dataPath, simply create a File object that points to the video and use that version. You can also use the URL version for local files ("file://") and remote files ("http://").
For example, if you have two videos both stored in the sketch's data folder, you can call the first normally:
Code:
JMCMovie myMovie = new JMCMovie("movie1.mov");
myMovie.play();
And then at some other time you can switch to a new movie using the switchVideo method:
Code:
myMovie.switchVideo("movie2.mov");
Of course you can just make two separate JMCMovie objects as well.
I'll make sure that the "mp" variable is public in the next update so that you can create your own custom versions of switchVideo in Processing.
Also, I believe I have fixed the memory leak that was present in the last version of jmcvideo.
I'd appreciate any testing/feedback about this and any other issues. Thanks! -Angus