4 Replies Latest reply on May 13, 2009 6:58 AM by mcsanders

    Playing a subsection of a video

    mcsanders

      Say I have a video clip that is about 1 minute long.  I would like to click on a button and only play a certain subsection of the video; for example from start+10 seconds to start+20 seconds.  Does anyone have an idea on how to do this without embedding cue points in the video?

       

      Thanks in advance.

      mc

        • 1. Re: Playing a subsection of a video
          Barna Biro Level 3

          Hi there,

           

          Well, cue points would be my best hint but since you don't want them then I can really think of a one more solution. You need to add a listener that checks the current playing time of the video and compare it to the time when you want it to stop. Let's say you start the video and want it to stop after 10 seconds ( roughly ). When you start the video, you read the start position time 0:00 and increment it ( add to the value ) the amount of time after which you want it to stop ( let's say 10 seconds ). With an additional listener ( can't remember if you have something built in that can listen for video play progress but if you don't, then simply use a Timer ) you'll check the current video position ( the time that has elapsed ) and compare it to the stop time ( to 0:10 ) when the video's current position is equal to or bigger than the stop time then simply stop the video.

           

          With best regards,

          Barna Biro

          Blog: http://blog.wisebisoft.com

          • 2. Re: Playing a subsection of a video
            mcsanders Level 1

            Thanks for your input.  I really appreciate it.

             

            If I understand what you are saying, that's a good idea if I want to play a piece from the beginning to a stopping point, but what if I want to play a section in the middle?

             

            Also, if I have to use cue points, is there a way to add them to the video after it is loaded without having to add them through the encoder?

            • 3. Re: Playing a subsection of a video
              Barna Biro Level 3

              If you want to play a section from the middle, you do exactly the same thing. But instead of adding 10 seconds to 0:00 you'll add to 2:34 ( or from wherever you want it to start ). You can also store the starting point, so in the end you'll have startPoint = 2:34 , endPoint = 2:44 and after all this is stored, then you can jump to minute 2:34 in the video and start listening for the endPoint from there.

               

              You can use the seek() method provided by the NetStream object to jump to a certain time in the video.

               

              For more info, read up here:

               

              http://livedocs.adobe.com/flex/3/langref/flash/net/NetStream.html

              http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Video_01.html

               

              The method is exactly the same, just that before you set the startPoint and endPoint, you'll use the seek(); method to jump to the startPoint and start playing the video from there. Obviously, that's when you instantiate the listener that compares the current video position to the endPoint. Once the endPoint is reached, stop the video.

               

              With best regards,

              Barna Biro

              Blog: http://blog.wisebisoft.com

               

              EDIT: adding cue points dynamically is possible just that it can get tricky. Read up on the links I provided because they cover most of this. Once you understand how to work with video, you can start solving the problem.

              1 person found this helpful
              • 4. Re: Playing a subsection of a video
                mcsanders Level 1

                Thanks again.  This is very helpful.