21 Replies Latest reply on Jan 15, 2010 1:36 PM by Robert Reinhardt

    Video Start at Specified Point

    seansks

      Hi, I'm hoping to learn how to make a video start playing at a specified point in the  middle of the video rather than from the beginning. Not sure if it's something that easily can be done in Dreamweaver or if it's involved with the flash settings, but any help would be greatly appreciated. Thanks!

        • 1. Re: Video Start at Specified Point
          John Hall Level 4

          I wouldn't know how to do it in Dreamweaver as I've not used it to post videos. In Flash, it depends on whether you're using the FLVPlayback class or straight netstream. The FLVPlayback class allows you to seek to a specified time.

          1 person found this helpful
          • 2. Re: Video Start at Specified Point
            seansks Level 1

            Thanks for responding, much appreciated! This is what's plugged in for the video so far. Any idea on what could be done? I'm not all too familiar with flash.

             

            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0, 0,0" width="160" height="120" id="FLVPlayer">  <param name="movie" value="FLVPlayer_Progressive.swf" />  <param name="salign" value="lt" />  <param name="quality" value="high" />  <param name="scale" value="noscale" />  <param name="loop" value="true">  <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_2&streamName=ELIProductVideo &autoPlay=false&autoRewind=true" />  loadMovieNum ("movie.swf",10) <embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Corona_Skin_2&streamName=ELIProduc tVideo&autoPlay=false&autoRewind=true" quality="high" scale="noscale" loop="true" width="160" height="120" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFl ash" /> </object>

            • 3. Re: Video Start at Specified Point
              seansks Level 1

              John, or anyone else -

              Would you be able to explain how to do this in Flash? I'm familiar with actionscript now and FLVPlayback. It would be greatly appreciated.

              • 4. Re: Video Start at Specified Point
                kglad Adobe Community Professional & MVP

                you can use the flvplayback's seek() method to start play at any time in the flv.

                1 person found this helpful
                • 5. Re: Video Start at Specified Point
                  seansks Level 1

                  Thanks for getting back to me on this. I'm familiar, but still learning actionscript. could you by any chance show an example of what I would paste in to actionscript for the seek() method to start play atsay... 52 seconds. Thanks!

                  • 6. Re: Video Start at Specified Point
                    kglad Adobe Community Professional & MVP

                    if your flvplayback instance is flv, use:

                     

                    flv.seek(52);

                    • 7. Re: Video Start at Specified Point
                      seansks Level 1

                      right now in my action script (3.0) I have this coding, since I needed the video to loop and not start until pressed play:

                       

                      = = = = =

                       

                      import fl.video.*;
                      my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, rewind);
                      function rewind(eventObject:VideoEvent):void {
                      my_FLVPlybk.autoRewind = true;
                      my_FLVPlybk.play();
                      }

                       

                      = = = = =

                       

                      i tried making it this, but it did not work:

                       

                      = = = = =

                       

                      import fl.video.*;
                      my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, rewind);
                      function rewind(eventObject:VideoEvent):void {
                      my_FLVPlybk.autoRewind = true;
                      my_FLVPlybk.play();

                      my_FLVPlybk.flv.seek(52);
                      }

                       

                      = = = = =

                       

                      do you know how i should format this to make it work? again thank you so much for helping out, I think I'm getting very close to completing this.

                      • 8. Re: Video Start at Specified Point
                        kglad Adobe Community Professional & MVP

                        you indicated you were using as2 in your html.  make sure your publish settings are correct for the code you're using.

                         

                        you should use:

                         

                        my_FLVPlybk.seek(52);

                         

                        • 9. Re: Video Start at Specified Point
                          seansks Level 1

                          kglad - thanks again for responding. actually I referenced that i was using action script 3. that's what my settings were set for at least.  with that, my actionscript code for looping works fine, but when I add my_FLVPlybk.seek(52); , and then test it out, nothing shows up. i changed it to action script 2 to see if that would do anything, but still same issue. Please advise, much appreciated.

                          - Sean

                          • 10. Re: Video Start at Specified Point
                            kglad Adobe Community Professional & MVP

                            the html code you posted is a flash player version that doesn't support as3.   the first explicit mention of your actionscript version is message 7 where you posted and mentioned as3.

                             

                            anyway, make sure you're publishing for as3 and use the html file published by flash, otherwise none of your code will work.

                             

                            and, i'm not sure where you're testing but if you try and seek to 52 seconds into your flv, you must be sure that much video has been loaded.

                            • 11. Re: Video Start at Specified Point
                              seansks Level 1

                              kglad - thanks again for getting back on this.

                               

                              sorry, that html code can be disregarded. that was lifted from dreamweaver when I thought the issue could be edited in that program through HTML (I realized that was impossible! ha). now the focus is what to plug in with action script in flash. to make sure all the info is put out there to get this to work in it's current setting - right now the publishing settings are for as3 and as mentioned before were set up to loop at the end with this (my_FLVPlybk is the instance) -

                               

                              = = = = =

                               

                              import fl.video.*;
                              my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, rewind);
                              function rewind(eventObject:VideoEvent):void {
                              my_FLVPlybk.autoRewind = true;
                              my_FLVPlybk.play();
                              }

                               

                              = = = = =

                               

                              but when i add in my_FLVPlybk.seek(52); as it is shown below, it does nothing different. I'm testing this by going to File > Publish Preview > HTML. I made sure the video was loaded fully before pressing play but it just begins at the start.

                               

                              = = = = =

                               

                              import fl.video.*;
                              my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, rewind);
                              function rewind(eventObject:VideoEvent):void {
                              my_FLVPlybk.autoRewind = true;
                              my_FLVPlybk.play();
                              my_FLVPlybk.seek(52);
                              }

                               

                              = = = = =

                               

                              If this will help - the video is located currently to be tested on this page - http://www.edlevinjewelry.com/indexTEST.html

                              How would I use the html file published by flash when I'm just implementing the video onto the page, not the flash html?

                               

                              Again - Thank you for helping out with this, it's greatly appreciated.

                              - Sean

                              • 12. Re: Video Start at Specified Point
                                kglad Adobe Community Professional & MVP

                                1.   use:

                                 

                                import fl.video.*;
                                my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, rewind);
                                function rewind(eventObject:VideoEvent):void {
                                    my_FLVPlybk.seek(52);
                                    my_FLVPlybk.play();
                                }

                                 

                                 

                                2.  unless you're streaming your video, you must use a video with keyframes (ie, cuepoints).   ie, use the addASCuePoint() method.

                                • 13. Re: Video Start at Specified Point
                                  seansks Level 1

                                  a break-through! it worked... almost 100% ha!

                                   

                                  I had to move the my_FLVPlybk.seek(52); to the beginning. When it was at the bottom originally it started at 52 seconds after the first loop.

                                   

                                  import fl.video.*;
                                      my_FLVPlybk.seek(52);
                                  my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, rewind);
                                  function rewind(eventObject:VideoEvent):void {

                                      my_FLVPlybk.play();
                                  }

                                   

                                   

                                  Now the only issue is off of what you mentioned to me earlier about how 52 seconds of the video has to be loaded.

                                  If i were to go to that site for the first time: http://www.edlevinjewelry.com/indexTEST.html

                                  and let the video load all the way, it still starts at the beginning.

                                  If i were to refresh the page though, it jumps to the 52 second point.

                                   

                                  Any ideas on how to solve this, make it not load the beginning and immediately know where to go. I have a feeling it might have to do with keyframes and cuepoints that you mentioned. Any way you could brief me on that or pass along resources. Again... ThankYou! you have been so helpful.

                                  • 14. Re: Video Start at Specified Point
                                    Robert Reinhardt Level 2

                                    An alternative would be to listen for the fl.video.VideoProgressEvent.PROGRESS event, and look at the bytesLoaded/bytesTotal of the video file being loaded. The Event.COMPLETE event is usually associated with the finishing of playback, not loading. Because it sounds like you're using a specific video for this implementation, you know the duration already of the video being loaded, correct? So, you could do something like:

                                     

                                    import fl.video.MetadataEvent;

                                    import fl.video.VideoProgressEvent;

                                     

                                    // other imports for your code here...

                                     

                                    var fp:FLVPlayback = insert_your_instance_name_here;

                                    fp.addEventListener(VideoProgressEvent.PROGRESS, videoProgressHandler, false, 0, true);

                                    fp.addEventListener(MetadataEvent.METADATA_RECEIVED, metaDataHandler, false, 0, true);

                                    fp.autoPlay = false;

                                     

                                    var startSeekTime:Number = 52;

                                    var videoDuration:Number;

                                    var videoSeeked:Boolean = false;

                                     

                                    function metaDataHandler(event:MetadataEvent):void {

                                         if(event.info.duration != null){

                                              videoDuration =event.info.duration;

                                         }   

                                    }

                                     

                                    function videoProgressHandler(event:VideoProgressEvent):void {

                                         var fp:FLVPlayback = event.currentTarget as FLVPlayback;

                                         var bytesLoaded:Number = event.bytesLoaded;

                                         var bytesTotal:Number = event.bytesTotal;

                                         if( !isNaN(videoDuration)){

                                              if( (bytesLoaded/bytesTotal) >= ( (startSeekTime+10)/videoDuration) && !videoSeeked ){

                                                   videoSeeked = true;

                                                   fp.seek(startSeekTime);

                                                   fp.play();

                                              }

                                         }

                                     

                                    }

                                     

                                    You'll notice that I added ten seconds to the startSeekTime value, to allow some video to buffer past the initial seek point as well. I didn't test this code, but the concept should work just fine.

                                     

                                    HTH.

                                     

                                    -Robert R.

                                     

                                    --

                                    Robert Reinhardt

                                    Creator, videoRx.com

                                    Author, original Flash Bible series and Video for Adobe Flash CS4 Professional Studio Techniques

                                    http://blogs.flashsupport.com/robert

                                    • 15. Re: Video Start at Specified Point
                                      seansks Level 1

                                      Robert- That definitely helped with the issue. It is recognizing it now on the first load to jump ahead once it's reached that loading point. My only issue now is - I wanted the video to not start playing until the user presses play. Since adding this new code, the autoplay is functioning even though its set in the Component Inspector to not do this. Any ideas? Thanks again

                                      • 16. Re: Video Start at Specified Point
                                        Robert Reinhardt Level 2

                                        So, in the Component Inspector, you have already specified autoPlay = false? (You should if you haven't.) If that's the case, simply remove the fp.p

                                        lay() I had in my code for the event handler. Then, it won't play--just seek.

                                         

                                        HTH.

                                         

                                        -Robert

                                         

                                        --

                                        Robert Reinhardt

                                        Creator, videoRx.com

                                        http://www.videoRx.com

                                        • 17. Re: Video Start at Specified Point
                                          seansks Level 1

                                          Robert - That did it! Thanks!!

                                           

                                          Not to drag this out - but just as confirmation, is there no way to have it so that the video starts loading at 52 seconds so it doesn't have that wait time in between while it loads up to that point? This is what it's at right now - http://www.edlevinjewelry.com/indexTEST.html

                                           

                                          You mentioned, "an alternative would be to listen for the fl.video.VideoProgressEvent.PROGRESS event, and look at the bytesLoaded/bytesTotal of the video file being loaded." What would that do exactly? Was there a place I was supposed to plug in numbers for bytesLoaded/bytesTotal?

                                           

                                          Thanks again for all the help.

                                          - Sean

                                          • 18. Re: Video Start at Specified Point
                                            Robert Reinhardt Level 2

                                            There are two ways to start loading/streaming at 52 seconds:

                                             

                                            1. Use Flash Media Server (or a hosted account somewhere like http://www.influxis.com). Flash Media Server uses RTMP, instead of HTTP, to stream video "packets" instead of serving the entire video file.

                                             

                                            2. Use "pseudo-streaming" techniques with server-side scripting. YouTube.com, for example, does this. It can serve a video file over HTTP in chunks, therefore letting you seek/start at a specific point. Stefan Richter talks about this technique in a blog post on his site at flashcomguru.com. You can also look at xmoovStream, http://stream.xmoov.com/.

                                             

                                            RE: bytesLoaded/bytesTotal, if you've implement my handler that I included in my example, you're already using bytesLoaded/bytesTotal. The event supplies that data--not you directly. Make sense?

                                             

                                            -Robert

                                             

                                            --

                                             

                                            Robert Reinhardt

                                            Creator, videoRx.com

                                            http://www.videoRx.com

                                            • 19. Re: Video Start at Specified Point
                                              seansks Level 1

                                              Yes, makes sense now - Thank you again, helped out greatly. have a great day.

                                              • 20. Re: Video Start at Specified Point
                                                seansks Level 1

                                                Actually, one problem I see now is that when the video starts playing the second or third  time, it starts from the beginning for me rather than the designated point in  the middle.Any idea why this would be occuring?

                                                - Sean

                                                • 21. Re: Video Start at Specified Point
                                                  Robert Reinhardt Level 2

                                                  So you essentially want to keep skipping the first 52 seconds for every playback/repeat? Why do you even have that 52 seconds in there? The Event.COMPLETE handler that Mr. K posted earlier in this thread should make sure that the seek() goes back to your 52 second point in time.

                                                   

                                                  -Robert