Recent Topics

1 Jan 04, 2007 19:25    

Hi,

i'm trying to create a Odeo flash mp3 player plugin for my site.
I took the cvideoGoogle plugin as an example but for some reason it is not working.

i hope someone is able to tell me what is wrong with this code. The file is called _mp3player.plugin.php. I uploaded it to the plugins directory and i'm able to install it. But it isn't parsed..


<?php
/*
 * Plugin Name: mp3player, Version: 0.0.1
 *
 * Author: Njit
 *
 * INSTALLATION: Unzip or Unrar mp3player.zip on plugins folder
 *               login to admin page
 *               Activate the plugin mp3player
 * add this code
 * [mp3player=URL to MP3 File]
 * 
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
class mp3player_plugin extends Plugin{
   var $code = 'mp3player';
   var $name = 'mp3player';
   var $priority = 100;
   var $apply_rendering = 'always';
   var $apply_to_html = true;
   var $apply_to_xml = true;
   var $short_desc = 'add mp3 audio on your page';
   var $long_desc = 'Its simple and fast. You can add mp3 audio on you posts.';
	
	
   function mp3player_plugin()
   {
      $this->short_desc = T_('add mp3 audio on your page');
      $this->long_desc = T_('Its simple and fast. You can add mp3 audio on you posts.');
   }
   function RenderItemAsHtml( & $params ){
   		$content = & $params['data'];
   		$content = $this->getBlockCode($content);
        return true;
   }
   function RenderItemAsXml( & $params ){
   	  $content = & $params['data'];
   	  $content = $this->getBlockCode($content);
      return true;
   }
	//obtain Block Code
   function getBlockCode($content){
		$pattern = "/(\[mp3player=(\-)?+\d+\])/";
        $content_parts = preg_replace_callback($pattern, "addMP3String", $content,-1);
	    return $content_parts;   	     
   }
}
function addMP3String($matches){
		//explode first value
		$block_codec = explode("[mp3player=",$matches[0]);
		//explode second value
		$block_mp3 = explode("]",$block_codec[1]);
		//add code for mp3 player
		$codemp3 = '<embed src= "http://www.odeo.com/flash/audio_player_standard_gray.swf" quality="high" width="300" height="52" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" flashvars= "valid_sample_rate=true&external_url=.$block_mp3[0]." pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>';
		return $codemp3;	
}
?>

2 Jan 05, 2007 09:30

 function RenderItemAsHtml( & $params )
{
	$params[ 'data' ] = preg_replace( '#\[mp3player=(.+?)]#i', '<embed src= "http://www.odeo.com/flash/audio_player_standard_gray.swf"
quality="high" width="300" height="52" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash"
flashvars= "valid_sample_rate=true&external_url=$1" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</embed>', $params[ 'data' ] );
	return true;
}

¥

3 Jan 05, 2007 09:51

Thank you for your post but its not completely clear what to do. Do i have to replace my routine with yours and delete the other function?

Could you paste it as a complete document?

4 Jan 05, 2007 09:59

It was a replacement for your current function, the full code should look something like this :

 <?php
/*
 * Plugin Name: mp3player, Version: 0.0.1
 *
 * Author: Njit
 *
 * INSTALLATION: Unzip or Unrar mp3player.zip on plugins folder
 *               login to admin page
 *               Activate the plugin mp3player
 * add this code
 * [mp3player=URL to MP3 File]
 * 
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
class mp3player_plugin extends Plugin{
   var $code = 'mp3player';
   var $name = 'mp3player';
   var $priority = 100;
   var $apply_rendering = 'always';
   var $apply_to_html = true;
   var $apply_to_xml = true;
   var $short_desc = 'add mp3 audio on your page';
   var $long_desc = 'Its simple and fast. You can add mp3 audio on you posts.';
    
    
   function mp3player_plugin()
   {
      $this->short_desc = T_('add mp3 audio on your page');
      $this->long_desc = T_('Its simple and fast. You can add mp3 audio on you posts.');
   }
   function RenderItemAsHtml( & $params )
   {
      $params[ 'data' ] = preg_replace( '#\[mp3player=(.+?)]#i', '<embed src= "http://www.odeo.com/flash/audio_player_standard_gray.swf" quality="high" width="300" height="52" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" flashvars= "valid_sample_rate=true&external_url=$1" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </embed>', $params[ 'data' ] );
     return true;
   }
   function RenderItemAsXml( & $params ){
      return $this->RenderItemAsHtml( $params );
   }

?>

5 Jan 05, 2007 10:52

I'm getting:


Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in
/data/members/paid/h/u/domainl/htdocs/www/b2/plugins/_mp3player.plugin.php on line 40

line 40 is this the end of the php file..

6 Jan 05, 2007 11:00

Opps, I forgot a } on the line before ?>

¥

7 Jan 05, 2007 11:14

Thanks! It works fine now.
For those who want a different style, you can also use "audio_player_black.swf"


Form is loading...