4 Replies Latest reply on Sep 9, 2015 9:36 AM by -david

    Trigger Action at the end of Video


      I see that this question has been asked and answered a few times here, but, for the life of me, I just can’t get this to work in my composition.


      I want to trigger an action when a video is done playing. My talents lean more towards the design side than the programming side, so a lot of this is new to me.


      I have a video group named “eot_sast_vd” in a symbol named “MovieAndBG_Sym,” which is the only symbol on my stage.

      I’ve added alerts in the code to help me troubleshoot the issues.



      I have tried:


      var myVideo = document.getElementById('eot_sast_vd');

      alert(myVideo); // always comes up “Null”

      myVideo.addEventListener("ended", function(){

      alert("in the function"); //never comes up



      Then the whole composition comes to a grinding halt and nothing further happens.



      Also, I’ve Tried


      var vid = sym.$(‘eot_sast_vd’);

      alert(vid) // displays “ [object Object] “

      var vidEnd = $(vid).children().first();

      alert(vidEnd) // displays “ [object Object] “

      $(vidEnd).bind('ended', function ()  

      alert(“I am now in the function”) //never comes up



      Then the composition, again, comes to a grinding halt and nothing further happens.


      In addition, I’ve tried adding both these lines of codes to the stage’s “Composition Ready,” and “Creation Complete.”

      Also the symbol “MovieAndBG_Sym’s” “Creation Complete” and even a timeline trigger on it’s timeline.


      Any help would be greatly appreciated.

        • 1. Re: Trigger Action at the end of Video
          Robyn_cpl Level 2


          I can see what you are trying to do in your code the only thing I can maybe see could be a issue is that your video group is inside a symbol. (Just from my own experience I've never added it to a symbol)


          The way I've managed to get a video ended is:

          var vidCtr = sym.$('INSERT_VIDEO GROUP NAME HERE');
          vidCtr.html('<video style="width:900px;height:500px;" controls autoplay" ><source src=WWW.ENTERURLOF VIDEO HERE.mp4></video>');

          var vid = $(vidCtr).children().first();
          $(vid).bind('ended', function () 


          Hope this helps with your code

          • 2. Re: Trigger Action at the end of Video
            jbowden Adobe Employee

            Hi RWB,


            Any reason why you wouldn't want to import the video in Animate and then directly address it as a video element? It's very likely a scoping issue (e.g., the video is not part of the Stage timeline) as Robyn mentioned.


            To address a video element, you must include the array notation, e.g., sym.$(‘eot_sast_vd’)[0] would address a video element on the same timeline named "eot_sast_vd".

            Otherwise, your addEventListener code looks correct - but you need to address the video element array, as I mentioned previously.




            • 3. Re: Trigger Action at the end of Video
              RW8 Level 1

              This did the trick!

              I was missing the [0], and that's all it took.

              Thanks for all the help!

              • 4. Re: Trigger Action at the end of Video

                Hi jbowden,


                The video is playing but the function wont execute when it finished..  (No alert and no video hiding)


                I have a symbol called videoPlayer on the stage.


                Heres my code :





                var vid = sym.$("videoPlayer");

                vid.html('<video width ="300" height ="168" src = "Video/MyVideo.mp4" type = "video/mp4" controls autoplay></video>');


                var vidEnd = $(vid).children().first();

                $(vidEnd).bind('ended', function ()


                alert("Video Ended");





                I dont really understant where to put the [0] on my code...


                Can you please help me figure it ?