Skip to main content
Participating Frequently
March 21, 2018
Answered

Remove Video from HTML5 Ad

  • March 21, 2018
  • 2 replies
  • 1433 views

I am a designer, NOT a coder, but I make html5 banners all the time. This project needs to lead off with video in the ad, and then play the rest of the animation.

I dug around and found a bit of code to load the video:

video = document.createElement('video');

video.src = 'GameMockUp_Clip.mp4'; video.autoplay =true; video.controls=false;

video.volume = 0; var Video = new createjs.Bitmap(video); stage.addChild(Video);

and it works! Now I need to remove the video, but I can't get it to go away. It plays on top of the rest of the animation.

I tried the logical solution:

stage.removeChild(Video);

but this does not work. Help! Time is an issue as of course the client needs this "yesterday". -_-

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Yes exactly!


    See if this works:

    var that = this;

    var video = document.createElement('video');

    video.src = 'GameMockUp_Clip.mp4';

    video.autoplay = true;

    video.controls = false;

    video.volume = 0;

    var canvasVideo = new createjs.Bitmap(video);

    stage.addChild(canvasVideo);

    setTimeout(function()

    {

        stage.removeChild(canvasVideo);

        that.play();

    }, 5000);

    2 replies

    Colin Holgate
    Inspiring
    March 21, 2018

    You hopefully have your issue solved by now, but in case what you said:

    stage.addChild(Video);

    is what was really there, make sure you match the original name. You said 'Video' when I think you mean 'video'.

    JoãoCésar17023019
    Community Expert
    Community Expert
    March 21, 2018

    Hi.

    This works here.

    var video = document.createElement('video');

    video.src = 'GameMockUp_Clip.mp4';

    video.autoplay = true;

    video.controls = false;

    video.volume = 0;

    var canvasVideo = new createjs.Bitmap(video);

    stage.addChild(canvasVideo);

    setTimeout(function()

    {

        stage.removeChild(canvasVideo);

    }, 2000);

    Please double check your variable names and let us know.

    Regards,

    JC

    ChopwerkAuthor
    Participating Frequently
    March 21, 2018

    João this does work...kind of.  The video plays and then removes itself, however, I'm a time line animator, and I need the the animation to play off the timeline after 5000ms. It seems to be stuck after the video is removed...

    JoãoCésar17023019
    Community Expert
    Community Expert
    March 21, 2018

    Do you need the video to be removed after 5 seconds and then the timeline should continue playing?