<?php
include_once "../../mainfile.php";

class JwPlayer{
	var $image;
	var $file;
	var $skin;
	var $width;
	var $height;
	var $mode;
  var $display;

	//建構函數
	function JwPlayer($file="",$image="",$width="",$height="",$skin="",$mode="",$display=""){
		$this->width=(empty($width))?480:$width;
		$this->height=(empty($height))?360:$height;
		$this->file=$file;
		$this->image=$image;
		$this->skin=(empty($skin))?XOOPS_URL."/modules/tadtools/mediaplayer/skin/beelden.zip":$skin;
		$this->mode=$mode;
		$this->display=$display;
	}

	//設定自定義設寬度
	function setWidth($width=""){
		$this->width=$width;
	}

	//設定自定義設高度
	function setHeight($height=""){
		$this->height=$height;
	}
	
	//設定自定義影片檔
	function setFile($file=""){
		$this->file=$file;
	}
	
	//設定自定義縮圖
	function setImage($image=""){
		$this->image=$image;
	}

	//設定自定佈景
	function setSkin($skin=""){
		$this->skin=$skin;
	}

	
	//產生播放器
	function render(){
    $playlistfile="";
    if($this->mode=="playlist"){
      $file="playlistfile: '{$this->file}',
      playlist:'{$this->display}',";
    }else{
      $file="file: '{$this->file}',";
    }
    $player="
    <script type='text/javascript' src='".XOOPS_URL."/modules/tadtools/mediaplayer/jwplayer.js'></script>
    <div id='container'>Loading the player ...</div>
    <script type='text/javascript'>
    jwplayer('container').setup({
      autostart: false,
      {$file}
      image: '{$this->image}',
      flashplayer: '".XOOPS_URL."/modules/tadtools/mediaplayer/player.swf',
      volume: 80,
      width: {$this->width},
      height: {$this->height},
      skin: '{$this->skin}'
    });
    </script>";
    
    return $player;
  }

}
?>
