• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Unload a video with PreloadJS

Community Expert ,
Dec 12, 2017 Dec 12, 2017

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();

}

Marlon Ceballos.

Views

618

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 17, 2017 Dec 17, 2017

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);

Votes

Translate

Translate
LEGEND ,
Dec 12, 2017 Dec 12, 2017

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:

Re: How to put animation over video in HTML5 canvas

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 15, 2017 Dec 15, 2017

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".

Marlon Ceballos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2017 Dec 17, 2017

Copy link to clipboard

Copied

LATEST

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines