Swapping out Video Files
in
Core Library Questions
•
8 months ago
Hello
I have created a program that loads multiple instances of the same video. On playback it copies a vertical section of each video to the stage at the correct position (8 sections), essentially re-creating the original clip. The reason for doing this is that each section is controlled by a live audio input allowing me to jump to different times, alter playback speed etc. for each of them individually.
All is working fine, but I am now trying to implement a feature that allows you to select a different video clip to load and this is giving me some playback issues. I can load and replace the video with no problems (program freezes on loading new clip but this is fine) but once loaded the new video plays back slowly and the frame rate drops significantly.
I am guessing this has something to do with the fact that the old videos are not being removed from memory? and am unsure as to how to do this. have had a look through the forums and tried 'System.gc();' but has achieved nothing.
I have posted the section of code that deals with setting up and loading the video below and was wondering if anyone had any suggestions?
- String vidFile = "chile - 151.mov"; //stores current video file path and name
- void initVideo() {
- // Loading the movies into the array
- for (int i = 0; i < myMovies.length; i ++ ) {
- myMovies[i] = new Movie(this, vidFile);
- myMovies[i].loop();
- }
- // Initializing all the elements of the array (video objects)
- for (int i = 0; i < sections.length; i++) {
- sections[i] = new Section(i);
- }
- }
- //called via selectInput() when new video file is selected
- void fileSelected(File selection) {
- if (selection == null) {
- println("Window was closed or the user hit cancel.");
- }
- else {
- vidFile = selection.getAbsolutePath();
- initVideo(); //re-initiate video
- }
- }
Hope this makes sense. Thanks
1