         case "NetConnection.Connect.Success":
           stream = new NetStream(connection);
           stream.bufferTime = 0.5;
-          stream.soundTransform = new SoundTransform(muted ? 0 : 1);
+          stream.client = {};
+          stream.client.onMetaData = function(metadata: Object): void {
+            if (metadata.hasOwnProperty("duration") && metadata["duration"] is Number) {
+              _duration = metadata["duration"];
+            }
+          };
+          stream.soundTransform = new SoundTransform(_muted ? 0 : 1);
           stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
           attachNetStream(stream);
 
-          stream.play(url);
-          if (autoplay) {
-            playing = true;
+          stream.play(_url);
+          if (_autoplay) {
+            _playing = true;
           } else {
-            playing = false;
+            _playing = false;
             pause();
           }
           break;
         case "NetStream.Play.Stop":
-          if (loop) stream.seek(0);
+          if (_loop) stream.seek(0);
           break;
       }
     }

    public function Video(url: String, width: uint, height: uint, autoplay: Boolean = true, loop: Boolean = true, muted: Boolean = true) {
      super(width, height);

      this.url = url;
      this.autoplay = autoplay;
      this.loop = loop;
      this.muted = muted;

      connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      connection.connect(null);
    }

    public function play(): void {
      playing = true;
      stream.resume();
    }

    public function pause(): void {
      playing = false;
      stream.pause();
    }

    public function isPaused(): Boolean {
      return !playing;
    }

    public function mute(): void {
      muted = true;
      stream.soundTransform = new SoundTransform(0);
    }

    public function unmute(): void {
      muted = false;
      stream.soundTransform = new SoundTransform(1);
    }

    public function isMuted(): Boolean {
      return muted;
    }

    private function netStatusHandler(e: NetStatusEvent): void {


  public class Video extends flash.media.Video {

    private var _url: String;
    private var _autoplay: Boolean;
    private var _loop: Boolean;
    private var _muted: Boolean;
    private var _playing: Boolean;
    private var _duration: Number;

    private var stream: NetStream;
    private var connection: NetConnection = new NetConnection();
