<?php
	
	/**
	 * JwPlayer	
	 * @author istrone
	 */
	class JwPlayer extends CWidget {
				
	    //public $serial = null; // /aWN3bU2J4EihB/eii/mGv1EGu6qIPs7KDCtM6UKclSXdWf4
	    public $serial = "/aWN3bU2J4EihB/eii/mGv1EGu6qIPs7KDCtM6UKclSXdWf4";
	    	  
		public $flvName;
		
		public $rtmpPath;		//	rtmp://istrone.com/jwplayer
		
		public $width = 550;
		
		public $height = 400 ;
		
		public $id = 'media';

		private $_path ;

		public $autoStart = false;
		
		public function init(){
		    $this->id .= rand();
			$this->_path =  dirname(__FILE__);
			?>
			<script type="text/javascript" src="<?php echo CHtml::asset($this->_path.'/jwplayer.js')?>"></script>
			<?php 
			parent::init();
		}
		
		public function run(){
			$path =  dirname(__FILE__);
			?>
			<div id="<?php echo $this->id;?>"></div>
			<script type="text/javascript">
			<?php if($this->serial != null) echo("jwplayer.key=\"$this->serial\";"); ?>
			jwplayer("<?php echo $this->id?>").setup({
					autostart: <?php echo $this->autoStart?'true':'false'?> ,
					flashplayer: "<?php echo CHtml::asset($this->_path.'/player.swf')?>",
					file:'<?php echo $this->flvName;?>',
					width:<?php echo $this->width?>,
					height:<?php echo $this->height?>,
				});
				</script>
			<?php 
		}
		
	}