3 Replies Latest reply on May 5, 2006 11:39 AM by Newsgroup_User

    loading one video when the previous one is finished

    rodolfo1216 Level 1
      Here's what I'd like to do: I've got about 10 video clips (each about 15 secs in length), and I'd like to make it possible to have the user select 2 or 3 of then and then click "Play". The swf then plays one clip, then when that clip is finished it loads the next automatically. I'm not sure if I want to use the flv component or not, but in any case, how do I script this so that the system knows when to load the next video?

      Thanks!

      Michael
        • 1. Re: loading one video when the previous one is finished
          Level 7
          Michael,

          > Here's what I'd like to do: I've got about 10 video clips (each
          > about 15 secs in length), and I'd like to make it possible to have
          > the user select 2 or 3 of then and then click "Play". The swf
          > then plays one clip, then when that clip is finished it loads the
          > next automatically.

          This goal can be broken down into at least two sub-goals: a) storing
          user choices in a list and b) using that list to play videos. I recommend
          going with external FLVs files for something like this. It will reduce the
          footprint of your SWF file; after all, why include all videos internally if
          the user may only want to see a few (or none!)?

          Let's start with how to load external FLV files. I recently blogged on
          this. Start with that and see if you can successfully load two or more
          videos sequentially. As you get your bearings, start with a hard coded
          list. In ActionScript, your "list" will be an Array instance.

          Look up the "Array class" entry in the ActionScript 2.0 Language
          Reference to make sense of the following sample code.

          var myList:Array = new Array();
          myList.push("one.flv");
          myList.push("two.flv");
          myList.push("three.flv");

          This gives you an array with three elements. Arrays start at zero, so
          element one can be retrieved like this: myList[0]; element two can be
          retrieved like this: myList[1]; and so on. The expression myList[0]
          returns a string, since element zero contains a string. This expression may
          be substituted for "one.flv" (or whatever your video is named) and used in
          place of the actual name when you script ActionScript load the FLV file.

          Check out this article, and look in the comments section to see a
          proposed solution for noting when the video has finished playing.

          http://www.quip.net/blog/2006/flash/how-to-load-external-video

          You could create a variable to hold a number, then increment that number
          as each clip finishes. That would allow you to step through your array of
          video files.

          e.g.
          var currentVideo:Number = 0;
          myList[currentVideo];

          currentVideo++; // value is now 1, etc.

          When you get this far, we can figure out a way to allow the user to
          specify what the array should be. If you don't get this far, come back with
          questions.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: loading one video when the previous one is finished
            rodolfo1216 Level 1
            David,

            Thanks so much! Came to my rescue again. Okay, I've worked though your blog on loading external flv's and I like it very much, but I do have a question there: how can you control the loaded video? That is, can you stop and rewind the loaded video?

            I'll work through your suggestions above regarding arrays next.

            Thanks again!

            Michael
            • 3. Re: loading one video when the previous one is finished
              Level 7
              Michael,

              > Thanks so much! Came to my rescue again.

              Glad to help. Thanks!

              > I've worked though your blog on loading external flv's and
              > I like it very much, but I do have a question there: how can
              > you control the loaded video? That is, can you stop and
              > rewind the loaded video?

              You can, definitely. Using the Video object is a bit more convoluted
              than others (such as MovieClip), because the FLV file is actually loaded by
              the NetStream instance and is used in cahoots with NetConnection. Normally,
              when you want to manipulate an object, you deal directly with is, as
              outlined in the "Objects: Your ActionScript Building Blocks" article on my
              site. In this case, the Video instance is little more than a visual
              container. Look to the Video class entry of the AS Language Reference for
              details on how to affect the dimensions of the video. Look to the NetStream
              class entry for details on how to pause/play, etc. your video. What you
              want will be under the Method summary. If you go by the sample code on my
              site, you'll invoke those methods on the ns instance -- of course, your
              mileage may vary, depending on what you name the isntance.

              > I'll work through your suggestions above regarding arrays next.

              You betcha.


              David
              stiller (at) quip (dot) net
              Dev essays: http://www.quip.net/blog/
              "Luck is the residue of good design."