9 Replies Latest reply on Mar 17, 2016 9:08 AM by diegos93050643
      • 1. Re: Is there a way to detect the end of a video?
        elainecc Adobe Employee

        Hi, ae_komatsu-

         

        Yes, the YouTube JavaScript API gives you access to an event that will fire when your video finishes playing.

        https://developers.google.com/youtube/js_api_reference#Events

         

        Look at onStateChange.

         

        Thanks,

         

        -Elaine

        1 person found this helpful
        • 2. Re: Is there a way to detect the end of a video?
          TonyEllisMedia Level 1

          Elaine,

           

          Does this process work for ipads?

          They have an example but it seems to be for flash.

          I am still learning and I guess that I am not comfortable on how and what syntax I need to be placing my script in the actions panel in Adobe Edge.

          I have also been having a problem of when I load youtube videos on a timeline and hit play on one and then go to my next video the old video is still playing in the background.

           

          (I know the sxyntax is not right)

          I want:

          onstartclipevent

          var = truckvideos

          truckvideos.playvideo1"mylocalipad/trucks/video1"

          if video1 statecomplete

          stopAllideoactions and audio

          gotoAndplay ("whateversymbol");

           

          var = dozervideos

          truckvideos.playvideo1"mylocalipad/dozer/video1"

          if video1 statecomplete

          stopvideoactions and audio

          gotoAndplay ("whateversymbol");

           

           

          var = excavatorvideos

          excavatorvideos.playvideo1"mylocalipad/excavator/video1"

          if video1 statecomplete

          stopvideoactions and audio

          gotoAndplay ("whateversymbol");

           

          var = loadervideos

          loadervideos.playvideo1"mylocalipad/trucks/video1"

          if video1 statecomplete

          stopvideoactions and audio

          gotoAndplay ("whateversymbol");

           

          Does this make sense?

          -Tony

          • 3. Re: Is there a way to detect the end of a video?
            RavenDesign Level 1

            For youtube the code would be something like this:

             

            view-source:calkaweb.herobo.com/video.html

             

            for HTML5 videos for youtube replace &version=3 with &html5=1 in the youtube URL

             

            I have no idea how to impletent the youtube code into Edge tho other than an iframe but that wouldn't work I've tried :

             

            http://forums.adobe.com/thread/1285212

             

            You would need to place all of the youtube codes into edge in order for it to work but I duno how to do that and no1 answered the question in the thread I made about it.

             

             

             

            as for MP4/HTML5 video you can use

             

            var video = document.getElementsByTagName('video')[0];

                video
            .onended = function(e) {
                 
            /*Do Something*/
               
            }

            1 person found this helpful
            • 4. Re: Is there a way to detect the end of a video?
              bryann design Level 1

              I just saw this on stack overflow and it worked! I wanted to add tracking and a bigPlay button again when it ended so the user has a better experience.

              Detect when an HTML5 video finishes - Stack Overflow

               

              //actions for when video is done player (hide/show stuff, play animation, etc.)

              var video = document.getElementsByTagName('video')[0];

               

                video.onended = function(e) {

               

                // Show an element

                sym.$("play_button").show();

               

               

                };

              • 5. Re: Is there a way to detect the end of a video?
                joel_pau Level 5

                Yes but using Edge API: Adobe Edge Animate CC JavaScript API

                Code is:

                sym.$("my_video_element")[0].onended = function(e){ console.log(e, e.type, e.target) };

                or

                var video = sym.$("my_video_element")[0];

                video.onended = function(e){ console.log(e, e.type, e.target) };

                • 6. Re: Is there a way to detect the end of a video?
                  joel_pau Level 5

                  Simpler ideas:

                   

                  1) Code.

                   

                  sym.$("my_video_element").bind( "ended", function(e){ doSomething }) ;


                  2) Edge UI.

                   

                  You can customize and get:videoEventEdgeUI.jpg

                  How shall we do it?

                  • First step: you select your video element and add a click event as shown below:

                  ElementsPanel1.jpg

                  • Second step: you click on "Full code" to replace click by ended as shown below:

                  mediaEvent.jpg

                  • Third step: clicking on the "Full Code" button again.
                  • 7. Re: Is there a way to detect the end of a video?
                    diegos93050643 Level 1

                    Hey @joel_pau, that looks good.

                     

                    I'm trying to play a another video automatically after the first video ended. I know that your post is the solution but I'm not getting this to work

                     

                    bf.png

                     

                    I am getting this but what does the "{ console.log(e, e.type, e.target) };" do?

                    and where shall I put the code you posted:

                    sym.$("my_video_element").bind( "ended", function(e){ PLAY THE OTHER VIDEO }) ;    ????

                     

                    I would really appreciate an answer!

                    Thanks!

                    • 8. Re: Is there a way to detect the end of a video?
                      ddhayles Level 3

                      This should do the same as the code others have written, but you can give it a go.

                       

                      Put this in your document.compositionReady and make sure both your videos are on the root timeline:

                       

                      sym.$("video1")[0].addEventListener("ended", function(){

                           sym.$("video1").hide();

                           sym.$("video2")[0].play();

                        }, false);

                      • 9. Re: Is there a way to detect the end of a video?
                        diegos93050643 Level 1

                        Dear ddhayles,

                         

                        thank you so much for this. It is like you said, I just didnt get it on the first attept... my fault. But finally I got this working.

                        Virtual Beers to the whole Community! You guys are awesome!

                         

                        Diego