Skip to main content
warpigs666
Inspiring
December 9, 2018
Answered

Show button when video component stops playing?

  • December 9, 2018
  • 2 replies
  • 820 views

Hi. Is there anyway to use JavaScript in html5 to show a button or symbol once a video component stops play back?

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

    Hi.

    Here is a sample that hopefully will help clarify things for you.

    animate_cc_html5_canvas_video_stops_playing.zip - Google Drive

    Please let me know if you still have any further questions.

    Regards,

    JC

    2 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    December 9, 2018

    Hi.

    Do you mean when the video playback reachs the end? If so, make sure your component's loop property is unchecked and try this:

    var that = this;

    var button = that.yourButton;

    var videoURL = "https://images-tv.adobe.com/avp/vr/15a99ccf-0e7c-4601-b270-87dd82624086/5078a43c-81f9-4a93-836c-815278b83a8e/e9cf12a0-7c4b-414f-a5c9-97ef49340aa9_20160203035417.960x540at1200_h264.mp4";

    function endedHandler(e)

    {

         button.visible = true;

         that.gotoAndStop(1);

    }

    that.stop();

    that.video.on("added", function()

    {

        $("#video")[0].src = videoURL;

        $("#video")[0].addEventListener('ended', endedHandler, false);

    }, that, true);

    Regards,

    JC

    warpigs666
    Inspiring
    December 9, 2018

    Thanks so much, but is there any chance you could write this out for someone who doesn't really know anything about JS (me)? I don't actually understand the "this, that" usage or where to put the names of my video component or button name in the above code... sorry I'm still learning all this...

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    December 10, 2018

    Hi.

    Here is a sample that hopefully will help clarify things for you.

    animate_cc_html5_canvas_video_stops_playing.zip - Google Drive

    Please let me know if you still have any further questions.

    Regards,

    JC

    warpigs666
    Inspiring
    December 9, 2018

    Really I’m just trying to figure out how to do anything once a video component has stopped playing. It doesn’t need to be just show/hide something, I’d also be interested in how to move to the next frame once a video component stops playing if that is easier.