Page 1 of 1

NEW RT: {MP3_PLAYER}

Posted: Wed 23. Aug 2006, 11:37
by antonumia
Hi,
I've just made my first RT for a bare bones flash mp3 player.

It inserts an IFRAME containing the player and allows for soundfile links to be added elsewhere on the page using a second RT.

see an early version at http://www.hypo.io/index.php?audio_n3t

I have 2 questions:

At the moment I'm using a separate directory at the phpwcms root for the player files and a php file in frontend_render.

1. Where would be the best place to put my player directory?

2. I've fudged the php from Marcus Obst's no_spam RT.

Issue 1: I have to send {MP3_PLAYER:dummytext:dummytext} in order to get the code to work when I just really would like to send {MP3_PLAYER} to insert the player
I'm sending {MP3_PLAYER:FILENAME.MP3:LINKTEXT} for the links.

Issue 2:Marcus's $str .= sprintf("%%%X",$b); hex link is probably overkill for this.

Would anyone like to give me a hand to tidy it up so I can post the whole thing?

thanks

anton

RT php in frontend_render:

Code: Select all

function insert_player($mail,$alt='') { 
      $str = "";
         
 if (substr_count($mail, "mp3") == 0) {

// just insert the player
 	$str = '<IFRAME src="external/player.php" name="mp3play" width="201" height="21" frameborder="0"></IFRAME>';          
      return $str; 
	}
	else
		{
		//just insert the link
      $a = unpack("C*", $mail); 
      foreach ($a as $b) 
      $str .= sprintf("%%%X", $b); 
   $str = "<a href=\"external/player.php?file=" . $str . "\" target=\"mp3play\">" . $alt . "</a>"  ; 
		return $str;
	}
} 

if( ! ( strpos($content["all"],'{MP3_PLAYER')==false ) ) { 

            $content["all"] = preg_replace('/\{MP3_PLAYER:([\w|@|.|\-|_|\+]+)\}/','{MP3_PLAYER:$1:$1}',$content["all"]); 
        $content["all"] = preg_replace('/\{MP3_PLAYER:([\w|@|.|\-|_|\+]+):(.*?)\}/e','insert_player("$1","$2")',$content["all"]); 
}    


Posted: Sun 27. Aug 2006, 16:43
by marcus@localhorst
as I understand right, u need this function urlencode() to make the url safe?!
best marcus