Copy link to clipboard
Copied
Hi. I have uploaded a video using the VideoLoader class of PreloadJS. Can I "unload" that video? I want to remove it and release the memory. Thanks.
var carga = new createjs.VideoLoader("new-year.mp4");
carga.load();
carga.addEventListener("complete", cargado);
var vid;
function cargado(evt) {
vid = evt.result;
var video = new createjs.Bitmap(vid);
stage.addChild(video);
vid.play();
}
The video element should be automatically garbage-collected when no variables are left that reference it. So this should wipe the slate clean:
vid = null;
video.image.src = null;
video.image = null;
video.parent.removeChild(video);
Copy link to clipboard
Copied
I'm not sure how to answer your question, but putting the load() command before you've assigned your load complete event listener is just begging for trouble.
Why are you even using the Loader class? You can create a bitmap video object directly, as demonstrated here:
Copy link to clipboard
Copied
Hi. Thank you for the advice about the position of the load() method.
I'm using the VideoLoader class because I need to load several videos at the same time and because I need use the listener. My problem is I can't remove the video after load, seems it exist in a "separate layer".
Copy link to clipboard
Copied
The video element should be automatically garbage-collected when no variables are left that reference it. So this should wipe the slate clean:
vid = null;
video.image.src = null;
video.image = null;
video.parent.removeChild(video);