<?php
/*
Nucleus Plugin WindowsMediaVideo
 
With this plugin you can post a Windows Media Video (wmv) by using the tag <%wmvideo(yourvideo.flv)%>
 
Based on NP_FlashVideo v0.4
 
With help of a code example from the article "Bye Bye Embed" (http://alistapart.com/articles/byebyeembed)
 
v0.1 (2006-07-27): kg 
	- inital realease
 
*/
 
class NP_WindowsMediaVideo extends NucleusPlugin {
 
	var $authorid;
 
	function getName()        { return 'WindowsMediaVideo'; }
	function getAuthor()      { return 'Kai Greve'; }
	function getURL()         { return 'http://kgblog.de/'; }
	function getVersion()     { return '0.1'; }
	function getDescription() { return 'Post a Windows Media Video (wmv) by using the tag <%wmvideo(yourvideo.wmv)%>, <%wmvideo(yourvideo.wmv|autostart)%> or <%wmvideo(yourvideo.wmv)|width|height|autostart%>'; }
 
	function install() {
		$this->createOption('width','Default width','text','320');
		$this->createOption('height','Default height','text','240');
		$this->createOption('autostart','Autostart video','yesno','no');
	}
 
	function getEventList() {
		return array('PreItem');
	}
 
	function unInstall() {
	}
 
	function wmvCode($param) {
		global $CONF;
 
		// explode parameters
		$para=explode('|',$param[1]);
 
		// filename
		$filename=$para[0];
 
		// size
		if (isset($para[1]) && isset($para[2])){
			$width=$para[1];
			$height=$para[2];       
		}
		else {
			$width=$this->getOption('width');
			$height=$this->getOption('height');
		}
 
		// autostart
		$autostart="";
		if (isset($para[1]) && !isset($para[2])){
			$autostart=$para[1];	
		}
		if (isset($para[3])){
			$autostart=$para[3];	
		}
		if ($autostart=="") {
			if ($this->getOption('autostart')=="yes") {
				$autostart="true";
			}
			else {
				$autostart="false";
			}
		}
 
		// url of the windows media video
		if (substr($filename, 0, 7)=="http://") {
			$fileurl=$filename;
		}
		else {
			$fileurl=$CONF['MediaURL'].$this->authorid.'/'.$filename; 
		}
 
		// code for the windows media video
		$code= '<object type="video/x-ms-wmv" data="'.$fileurl.'" width="'.$width.'" height="'.$height.'"><param name="src" value="'.$fileurl.'" /><param name="autostart" value="'.$autostart.'" /><param name="controller" value="true" /></object>';
 
		return $code;
	}
 
	function event_PreItem($data) {
		$this->currentItem = &$data["item"];
		$this->authorid = &$data["item"]->authorid;
		$this->currentItem->body = preg_replace_callback("#<\%wmvideo\((.*?)\)%\>#", array(&$this, 'wmvCode'), $this->currentItem->body);
		$this->currentItem->more = preg_replace_callback("#<\%wmvideo\((.*?)\)%\>#", array(&$this, 'wmvCode'), $this->currentItem->more);
	}
 
	function supportsFeature ($what) {
		switch ($what) {
			case 'SqlTablePrefix':
				return 1;
			default:
				return 0;
		}
	}
}
?>
np_windowsmediavideo_code.txt · Last modified: 2006/07/27 16:31 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki