1 Reply Latest reply on Jul 19, 2011 8:42 PM by kglad

    NetStream Video Control button issue

    demetriusmcclain

      The stop button plays as expected.  The play/pause button plays as expected.  The issue is when you press pause which will cause the play button to appear, then press stop.  the video automatically plays and it shouldn't. I have bolded the control button script for convenience.

       

       

      var nc:NetConnection = new NetConnection();
      nc.connect(null);

      var ns:NetStream = new NetStream(nc);

      theVideo.attachVideo(ns);

      ns.play("LOB2_0644_new.flv");

       

      stop_mc.onRelease = function(){
      playpause_mc.gotoAndStop("playing");
      ns.seek(0);
      ns.pause();
      }

      playpause_mc.onRelease = function(){
      ns.pause();
        if (this._currentframe == 1)
          {
              this.gotoAndStop("playing");
              movie_mc.play();
          }
          else
          {
              this.gotoAndStop("paused");
              movie_mc.stop();
          } // end else if
      } // End of the function

      var videoInterval = setInterval(videoStatus,100);
      var amountLoaded:Number;
      var duration:Number;

      ns["onMetaData"] = function(obj){
      duration = obj.duration;
      }

      function videoStatus(){
      amountLoaded = ns.bytesLoaded / ns.bytesTotal;
      loader.loadbar._width = amountLoaded * 424;
      loader.scrub._x = ns.time / duration * 424;
      }

      var scrubInterval;

      loader.scrub.onPress = function(){
      clearInterval(videoInterval);
      scrubInterval = setInterval(scrubit,10);
      this.startDrag(false,0,this._y,424,this._y);

      }

      loader.scrub.onRelease = loader.scrub.onReleaseOutside = function(){
      clearInterval(scrubInterval);
      videoInterval = setInterval(videoStatus,100);
      this.stopDrag();
      }

      function scrubit(){
      ns.seek(Math.floor((loader.scrub._x/424)*duration));
      }

      _root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
      vSound.attachAudio(ns);

      var so:Sound = new Sound(vSound);

      so.setVolume(100);

        • 1. Re: NetStream Video Control button issue
          kglad Adobe Community Professional & MVP

          before executing gotoAndStop("playing") check if playpause_mc is already on the "playing" frame.   if it is, do nothing.  if it's not, execute your gotoAndStop().

           

          also, you probably want:

           

             else
              {

          ns.play();
                  this.gotoAndStop("paused");
                  movie_mc.stop();
              } // end else if

          1 person found this helpful