4 Replies Latest reply on Mar 22, 2007 11:00 AM by Swarfega

    Play/pause button actionscript

    Swarfega
      Hi I was wondering how to make a video playable again once the full the duration of the video has played. I press play and nothing happens. For the record my play button is also used as a pause button.

      Here is the actionscript I'm using:

      on (release){
      ns.pause();
      if (stopped)
      {
      ns.seek(0)
      ns.play();
      stopped=false;
      }
      }
        • 1. Re: Play/pause button actionscript
          Level 7
          Swarfega,

          > Hi I was wondering how to make a video playable again
          > once the full the duration of the video has played.

          You can seek to the beginning and play.

          > I press play and nothing happens. For the record my play
          > button is also used as a pause button.

          If this is based on code I suggested earlier in this thread, than the
          play button is actually (technically) a pause button; it's just that the
          NetStream.pause() method toggles play.

          > Here is the actionscript I'm using:
          >
          > on (release){
          > ns.pause();
          > if (stopped)
          > {
          > ns.seek(0)
          > ns.play();
          > stopped=false;
          > }
          > }

          That stopped variable is new. It looks to me like you're taking little
          bits and pieces of various people's suggestions and patching them together
          without really knowing what they do. While there's nothing "wrong" or "bad"
          about that, it does tend to make coding endeavors harder than they might be
          otherwise, in light of new considerations each time.

          Did you visit the tutorial I posted in the other thread on how to
          determine the end of an FLV file?


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Play/pause button actionscript
            Swarfega Level 1
            Well I'm not rreally sure what the if statement does a whole if I'm honest. I do Understand the different parts of it though. I got that staement from that tutorial. I tried downloading the fla file you had but it's incomplete. Do I amend it myself so it will show the different interactive symbols?

            seek goes to the exact second in the video
            play plays the fil when it hads been paused.
            stopped(false) means that the option for the video to be stopped has been set off.
            • 3. Re: Play/pause button actionscript
              Level 7
              Swarfega,

              > Well I'm not rreally sure what the if statement does a
              > whole if I'm honest.

              Honest helps us both. ;)

              In your most recent code snippit ...

              on (release) {
              ns.pause();
              if (stopped) {
              ns.seek(0);
              ns.play();
              stopped = false;
              }
              }

              ... the if() statement tests the value of a variable named stopped. The way
              ActionScript 1.0 and 2.0 work, if the stopped variable doesn't exist, then
              the if() statement will basically interpret that as a value of false. So,
              the first time this code is encountered, the NetStream instance (ns) will
              pause, and then the if() statement will ... well, it won't do anything,
              because stopped doesn't yet exist -- that is, it doesn't yet register as
              true.

              The next time this code is encountered, it will do the same thing,
              because stopped is never set to true. If stopped has been initialized
              somewhere as true, then the if() statement will natrually perform the
              methods in its own block, then set the value of stopped to false.

              > I do Understand the different parts of it though. I got that
              > staement from that tutorial.

              Gotcha. Okay, I only glanced through it ... it's not something I wrote
              or experimented with, just something that, at a glance, might give you the
              answer you're looking for.

              > I tried downloading the fla file you had but it's incomplete.

              What FLA is that?

              > Do I amend it myself so it will show the different interactive
              > symbols?

              I'm not sure what FLA you mean.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Play/pause button actionscript
                Swarfega Level 1
                It was just the fla file that you could download from that tutorial webpage that you directed me to. So anyway, is there a line of code that can do this, or is it more complicated than that?