4 Replies Latest reply on Apr 19, 2006 9:55 AM by Newsgroup_User

    Stuck on the switch statement

    livingcontrast
      Anyone know how I might go about the following code correctly? I need to avoid loops, so it's a little tricky for me. Need control over playing one movie, then the next, then the next. Eventually, I each case may have a video to play, text to display, or another swf to load.

      Thank you!


      == "Code-ish"

      var connection_nc:NetConnection = new NetConnection();
      connection_nc.connect(null);
      var stream_ns:NetStream = new NetStream(connection_nc);
      my_video.attachVideo(stream_ns)

      var videosArray = ["../videos/video1.flv", "../videos/video2.flv", "../videos/video3.flv"]

      switch(videosArray) {
      case 1 :
      stream_ns.play(videosArray[0]);
      break;
      // when video is done, move onto next case
      case 2 :
      stream_ns.play(videosArray[1]);
      break;
      // when video is done, move onto next case
      case 3 :
      stream_ns.play(videosArray[2]);
      break;
      // when video is done, move onto next case
      };
        • 1. Stuck on the switch statement
          FlashTastic Level 1
          You'll need to detect when the FLV has ended, and then call a function to play the next video.
          Typically, you have to wait until the buffer is flushed until you can safely start playing the next video, this code should help you out some.

          You could also add your switch statement into the point where the next video is played, switching the indexCounter variable and performing actions based on that.

          Cheers,
          FlashTastic


          • 2. Re: Stuck on the switch statement
            Level 7
            FlashTastic,

            > You'll need to detect when the FLV has ended, and then call
            > a function to play the next video.

            That sounds exactly right.

            > Typically, you have to wait until the buffer is flushed until you
            > can safely start playing the next video, this code should help
            > you out some.

            Is this reliable? I do not doubt your advice ... I'm asking because I'm
            not sure myself. The NetStream.onStatus event seems to be the only
            indicator, since neither the Video class nor the NetConnection class over an
            onComplete (or the like). I worry that the buffer might be flushed under
            circumstances other than the end of a video. What does your experience say?
            The only other way I can think of is to supply the known length of the video
            and compare that repeatedly against the NetStream.time property.


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


            • 3. Re: Stuck on the switch statement
              FlashTastic Level 1
              Hi David,

              I've used both methods myself, I usually use the NetStream.time method when I have a seek bar built into the app although I find it can be a bit unreliable when using FMS (v1.5) recorded FLVs under a minute long.

              I know that there can be a problem with the metadata in FLVs recorded with older versions of FMS where the stream length is reported improperly (which has since been fixed), but since I haven't run into anything that generates a sequence of events in the same order (stop, empty, flush) I would say it's reliable.

              Cheers,
              FlashTastic

              • 4. Re: Stuck on the switch statement
                Level 7
                Great!

                Thanks for the insight. I appreciate that.


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

                "FlashTastic" <webforumsuser@macromedia.com> wrote in message
                news:e25oh9$47f$1@forums.macromedia.com...
                > Hi David,
                >
                > I've used both methods myself, I usually use the NetStream.time method
                > when I
                > have a seek bar built into the app although I find it can be a bit
                > unreliable
                > when using FMS (v1.5) recorded FLVs under a minute long.
                >
                > I know that there can be a problem with the metadata in FLVs recorded with
                > older versions of FMS where the stream length is reported improperly
                > (which has
                > since been fixed), but since I haven't run into anything that generates a
                > sequence of events in the same order (stop, empty, flush) I would say it's
                > reliable.
                >
                > Cheers,
                > FlashTastic
                >
                >
                >