2 Replies Latest reply on Oct 9, 2011 5:29 PM by adninjastrator

    play / pause problem

    Venkom

      if i click 'Play' Button video playing normally, after i click 'Pause' button video pause,  next i click 'Play' Button video playing from starting point.

       

      what is the problem

       

      solution pls......

       

      Code:

       

      var video:String = "http://www.hagane.us/as/flv/video.flv"
        
      var nc:NetConnection = new NetConnection();
      nc.connect(null);
      
      var ns:NetStream = new NetStream(nc);
      
      theVideo.attachVideo(ns);
      ns.play(video);
      
      ns.onStatus = function(info){
                if(info.code == "NetStream.Play.Stop") {
                          ns.seek();
                          ns.close();
                          mid_play._visible = true;
                }
      }
      
      
      //Button Control Functions
      
      
      play_btn.onRelease = function () {
        
                                                        ns.play(video);
                                                        mid_play._visible = false;
                                                        }
        
      mid_play.onRelease = function () {
        
                                                        ns.play(video);
                                                        mid_play._visible = false;
                                                        }
        
      pause_btn.onRelease = function (){
        
                                                        ns.pause();
                                                        mid_play._visible = true;
                                                        }
        
      stop_btn.onRelease = function (){
        
                                                        ns.close();
                                                        mid_play._visible = true;
                                                        }
      
        • 1. Re: play / pause problem
          Ned Murphy Adobe Community Professional & MVP

          You should look in the help documentation regarding both the pause and the play methods of the NetStream class.  You can probably solve this yourself in doing so if you take the time to read what they involve.

           

          The pause method info indicates:  "The first time you call this method (without sending a parameter), it pauses play; the next time, it resumes play. You might want to attach this method to a button that the user presses to pause or resume playback."

           

          That says you might try using pause() again in your mid_play button instead of play() because calling it a second time will resume play.

           

          If you need to use the play method for some reason (I don't see why you would), the play method has more arguments it can take, one being the "start" time (at what time into the video to start it playing).  The class also has a time property that you can read and assign to a variable to help remember where you stopped it.  So if you save the time value when you pause the video you can restart it using that time value as a secong argument.... ns.play(video, atTime);

          • 2. Re: play / pause problem
            adninjastrator Level 4

            I agree with Ned, put the pause action on the Play button:

            play_btn.onRelease = function() {

            ns.pause();

            }

            This will toggle between play and pause.

            Best wishes,

            Adninjastrator

            1 person found this helpful