4 Replies Latest reply on Mar 5, 2013 11:33 AM by CEItim

    video replay button

    CEItim Level 1

      I've been following Schrene's example for implementing multiple videos and it works beautifully. This forum has been a tremendous resource, so thanks to all of you!

       

      I have a button that I've imported into Edge. I would like it to replay the currently playing video from the beginning on a button press. Does anyone know of any jQuery code that would replay a  video from the beginning?

       

      Thanks!

        • 1. Re: video replay button
          TimJaramillo Level 4

          Hi there,

           

          Not sure what your setup is, but the below code gets a video by div id, resets the video's currentTime to 0, and plays- effectively replaying the vid.

           

          var myVideo = document.getElementById("myVideoId");

          myVideo.currentTime = 0;

          myVideo.play();

          • 2. Re: video replay button
            CEItim Level 1

            Thanks, that works great for one video, but I'm trying to program a single button that can replay many different videos. All of my videos have a class of 'OSA', so I tried both this code:

             

            var myVideo = $(".OSA");

            myVideo.currentTime = 0;

            myVideo.play();

             

            and this code, and neither work. Is there any way to do this?

             

            var myVideo = document.getElementsByClassName("OSA");

            myVideo.currentTime = 0;

            myVideo.play();

            • 3. Re: video replay button
              TimJaramillo Level 4

              Gotcha.

               

              Add a separate div id for each video. On click of your button that initializes the play state for each video, set a variable to store the "activeVideo" id. Then, use that "activeVideo" variable with the code I gave you.

               

              var myVideo = document.getElementById("activeVideo");

              myVideo.currentTime = 0;

              myVideo.play();

              • 4. Re: video replay button
                CEItim Level 1

                Oh, ok, that's easy enough! Great!