plugins:audioplayer:audioplayer_code

NP_AudioPlayer.php Source Code

<?php
/*
	Name:NP_AudioPlayer
	License:GPL
	History:
		0.1a: (2008-04-14) First Release.
*/
 
class NP_AudioPlayer extends NucleusPlugin {
	function getName() { return 'NP_AudioPlayer'; }
	function getAuthor() { return 'floors'; }
	function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:audioplayer'; }
	function getVersion() { return '0.1a'; }
	function getDescription() { return 'A single-file mp3 player designed to be both easy to set up and extremely customisable.'; }
	function supportsFeature($what) { switch($what) { case 'SqlTablePrefix': return 1; default: return 0; } }
 
 
 
	function install() {
		$this->createOption('AudioPlayerURI','Flash Media Player URI','text','http://');
		$this->createOption('AudioPlayerjsURI','Javascript URI','text','http://');
		$this->createOption('playerWidth','Default Width','text','290','numerical=true');
		$this->createOption('playerHeight','Default Height','text','24','numerical=true');
	}
 
 
 
	function getEventList() {return array('PreItem');}
	function event_PreItem($data) {
		$this->currentItem = &$data["item"]; 
		$this->currentItem->body = preg_replace_callback("/<\%media\((.*)\)%\>/Us", array(&$this, 'AudioPlayer'), $this->currentItem->body);
		$this->currentItem->more = preg_replace_callback("/<\%media\((.*)\)%\>/Us", array(&$this, 'AudioPlayer'), $this->currentItem->more);
	}
 
 
 
	function AudioPlayer($matches){
		global $CONF;
		$farray = array();
		$farray = explode("|",$matches[1]);
 
		$filename = $farray[0];
		$text = $farray[1];
		$width = (int) $farray[2];
		$height = (int) $farray[3];
 
		$searchdot = strrpos($filename,".");
		$tail = substr($filename,$searchdot,strlen($filename)-$searchdot+1);
 
		if($tail == ".mp3"){
			if($width == 0){$width = $this->getOption('playerWidth');}
			if($height == 0){$height = $this->getOption('playerHeight');}
			if(!strstr($filename,'/')) {$media = $this->currentItem->authorid;}
			$media = htmlspecialchars($CONF['MediaURL']. $media);
 
			$text = '
<span class="audioPlayerArea">
<script type="text/javascript" src="'.$this->getOption('AudioPlayerjsURI').'"></script>
<object type="application/x-shockwave-flash" data="'.$this->getOption('AudioPlayerURI').'" id="'.$filename.'" height="'.$height.'" width="'.$width.'">
<param name="movie" value="'.$this->getOption('AudioPlayerURI').'" />
<param name="FlashVars" value="playerID=1&amp;bg=0x0D1C57&amp;leftbg=0x0D1C57&amp;lefticon=0x9999FF&amp;rightbg=0x0D1C57&amp;rightbghover=0x330066&amp;righticon=0x9999FF&amp;righticonhover=0xffffff&amp;text=0x42B4EE&amp;slider=0x42B4EE&amp;track=0xFFFFFF&amp;border=0x666666&amp;loader=0x9999FF&amp;loop=yes&amp;autostart=no&amp;soundFile='.$media.'/'.$filename.'" />
<param name="quality" value="high" />
<param name="menu" value="false" />
<param name="wmode" value="transparent" />
'.$media.'/'.$filename.'
</object>
</span>
			';
			} else {
			$text = <<<EOD
<%media($filename|$text|$width|$height)%>
EOD;
		}
		return $text;
 
 
 
	}
}
?>
 
plugins/audioplayer/audioplayer_code.txt · 最終更新: 2011/03/23 21:28 (外部編集)