 							",videoWidth:" + _videoWidth +
 							",videoHeight:" + _videoHeight +							
 							"}";
-			
+
 			_element.sendEvent(eventName, values);			
 		}		
 	}
-}
-		
+}
				}
				_timer.start();
				_isPaused = false;
				_isLoaded = true;	
				sendEvent(HtmlMediaEvent.PLAYING);						
			}

		}			
		
		public function pause():void {
			_stream.pause();
			_isPaused = true;
			_timer.stop();			
			
			_isPaused = true;
			sendEvent(HtmlMediaEvent.PAUSED);
		}		
		
		public function setCurrentTime(pos:Number):void {
			_stream.seek(pos);
			sendEvent(HtmlMediaEvent.SEEKED);
		}
				
		public function setVolume(volume:Number):void {
			_soundTransform = new SoundTransform(volume);
			_stream.soundTransform = _soundTransform;
			_volume = volume;
			
			_isMuted = (_volume == 0);
			
			sendEvent(HtmlMediaEvent.VOLUMECHANGE);
		}

		
		public function setMuted(muted:Boolean):void {			
			
			if (_isMuted == muted)
				return;
	
			if (muted) {
				_oldVolume = _stream.soundTransform.volume;
				setVolume(0);
			} else {
				setVolume(_oldVolume);
			}
			
			_isMuted = muted;
		}

		
		private function sendEvent(eventName:String) {
			
			// calculate this to mimic HTML5
			_bufferedTime = _bytesLoaded / _bytesTotal + _duration;			
			
			// build JSON
			var values:String = 
							"{duration:" + _duration + 

	import flash.media.Video;
	import flash.media.SoundTransform;
	import flash.utils.Timer;

	import FlashMediaElement;
	import HtmlMediaEvent;

	public class VideoElement extends Sprite implements IMediaElement 
	{
		private var _currentUrl:String = "";
		private var _autoplay:Boolean = true;

        private var _connection:NetConnection;
        private var _stream:NetStream;
        private var _video:Video;
		private var _element:FlashMediaElement;
		private var _soundTransform;
		private var _oldVolume:Number = 1;

		// event values
		private var _duration:Number = 0;
		private var _framerate:Number;
		private var _isPaused:Boolean = true;
		private var _isEnded:Boolean = false;
		private var _volume:Number = 1;
		private var _isMuted:Boolean = false;	

		private var _bytesLoaded:Number = 0;
		private var _bytesTotal:Number = 0;		
		private var _bufferedTime:Number = 0;		

		private var _videoWidth:Number = -1;
		private var _videoHeight:Number = -1;

		private var _timer:Timer;
		
		private var _isRTMP:Boolean = false;
		private var _isConnected:Boolean = false;
		private var _playWhenConnected:Boolean = false;
		private var _hasStartedPlaying:Boolean = false;


		public function get video():Video {
			return _video;
		}

		public function get videoHeight():Number {
			return _videoHeight;
		}

		public function get videoWidth():Number {
			return _videoWidth;
		}


		public function duration():Number {		
			return _duration;
		}

		public function currentTime():Number {		
			return _stream.time;
		}			

		// (1) load()
		// calls _connection.connect(); 
		// waits for NetConnection.Connect.Success
		// _stream gets created


		public function VideoElement(element:FlashMediaElement, autoplay:Boolean, timerRate:Number) 
		{
			_element = element;
			_autoplay = autoplay;

			_video = new Video();
			addChild(_video);

            _connection = new NetConnection();
            _connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            _connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
			//_connection.connect(null);	

			_timer = new Timer(timerRate);
			_timer.addEventListener("timer", timerHandler);

		}

		private function timerHandler(e:TimerEvent) {

			_bytesLoaded = _stream.bytesLoaded;
			_bytesTotal = _stream.bytesTotal;

			sendEvent(HtmlMediaEvent.TIMEUPDATE);

			trace("bytes", _bytesLoaded, _bytesTotal);
