Location: PHPKode > scripts > What's Playing > whats-playing/whatsplaying.class.php
<?

	class whatsplaying
	{
		var $whatsplaying;
		var $text_nowplaying = "Now playing: ";
		var $text_lastplayed = "Last played: ";
		var $colcolors = 2;
		
		function whatsplaying($file="whatsplaying.serialized")
		{
			$fp = fopen(realpath($file), "r");
			$serialized = fread($fp, filesize(realpath($file)));
			fclose($fp);
			$this->whatsplaying = unserialize($serialized);	
		}
		
		function getsonglist()
		{
			return $this->whatsplaying["songs"];
		}
		
		function isnowplaying()
		{
			return $this->whatsplaying["nowplaying"];
		}

		function gettable()
		{
			$r .= "<table border=0 cellpadding=2 cellspacing=0 class=whatsplaying_table>";
			
			if($this->isnowplaying())
			{
				$r .=
				"
					<tr class=whatsplaying_tr_nowplaying>
						<td class=whatsplaying_td_nowplaying>
							<span class=whatsplaying_nowplaying_text>".$this->text_nowplaying."</span>".$this->whatsplaying["songs"][0]."
						</td>
					</tr>
				";
			}
			if(
				(
					$this->isnowplaying()
					&&
					sizeof($this->whatsplaying["songs"]) > 1
				)
				||
				(
					!$this->isnowplaying()
					&&
					sizeof($this->whatsplaying["songs"]) > 0
				)
			)
			{
				$r .=
				"
					<tr class=whatsplaying_tr_lastplayed_header>
						<td class=whatsplaying_td_lastplayed_header>
							<span class=whatsplaying_lastplayed_text>".$this->text_lastplayed."</span>
						</td>
					</tr>
				";
			}
			$colcount = 1;
			for($i=($this->isnowplaying() ? 1 : 0); $i<sizeof($this->whatsplaying["songs"]); $i++)
			{
				$r .=
				"
					<tr class=whatsplaying_tr_lastplayed_$colcount>
						<td class=whatsplaying_td_lastplayed>
						".$this->whatsplaying["songs"][$i]."
						</td>
					</tr>
				";
				$colcount ++;
				if($colcount > $this->colcolors)
					$colcount = 1;
			}
			$r .= "</table>";
			return $r;
		}
	}

?>
Return current item: What's Playing