     private var nc:NetConnection;
     private var ns:NetStream;
     public var ended:Boolean = false;
+    private var currentState:String = "stopped";
 
     public function HTTPClient(video:Video, urlParsed:Object) {
       this.urlParsed = urlParsed;


      if (!ended && 'NetStream.Buffer.Empty' === event.info.code) {
        dispatchEvent(new ClientEvent(ClientEvent.PAUSED, { 'reason': 'buffering' }));
        return;
      }

      if ('NetStream.Pause.Notify' === event.info.code) {
        dispatchEvent(new ClientEvent(ClientEvent.PAUSED, { 'reason': 'user' }));
        return;
      }
    }

    public function stop():Boolean {
      ns.dispose();
      nc.close();
      this.currentState = "stopped";
      return true;
    }

    public function pause():Boolean {
      if (this.currentState !== 'playing') {
        ErrorManager.dispatchError(800);
        return false;
      }
      ns.pause();
      this.currentState = "paused";
      return true;
    }

    public function resume():Boolean {
      if (this.currentState !== 'paused') {
        ErrorManager.dispatchError(801);
        return false;
      }
      ns.resume();
      return true;
    }
