Recent Topics

1 Mar 04, 2008 17:29    

Hi there;

Well, I'm not sure how to make a plugin render a javascript code... I'd like to make my plugin XHTML valid. To do so, I need to replace "object" with SWFObject declaration.

It looks like this:

<div id="player">This text will be replaced</div>

<script type="text/javascript">
var so = new SWFObject('http://www.domain.com/plugins/mediaplayer.swf','mpl','470','255','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addVariable('width','470');
so.addVariable('height','255');
so.addVariable('file','/upload/movie.flv');
so.write('player');
</script>

My question is: is there a possibility to put it into a function like this:

function RenderItemAsHtml( & $params )
	{
		$content = & $params['data'];

		// flash:
		$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<object type="application/x-shockwave-flash" data="'.$this->get_plugin_url().'mediaplayer.swf" width="\\2" height="\\3" /><param name="movie" value="'.$this->get_plugin_url().'mediaplayer.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value="height=\\3&width=\\2&file=\\1&image=\\4&displayheight=\\3&showstop=true" /></object>', $content );

		return true;
	}

I'm sorry if it's a basic question...

thanks for any help.

2 Mar 04, 2008 18:02

Hmm, another of my question would be: is it possible for a plugin to render HTML in the <HEAD> area of the page? Or are we forced to edit HTML-Header in skins folder?

... and a stupid question: why can't I put a plugin into a folder? If I do so, b2evo doesn't see it... are there any special kinds of plugins that get displayed when in folders?

3 Mar 04, 2008 18:15

gupik wrote:

Hmm, another of my question would be: is it possible for a plugin to render HTML in the <HEAD> area of the page? Or are we forced to edit HTML-Header in skins folder?

http://doc.b2evolution.net/HEAD/plugins/Plugin.html#methodSkinBeginHtmlHead

There are possibilities without the hook also. The hook injects stuff at the very beginning of the <head> section. You may not always want that.

Good luck

4 Mar 04, 2008 18:19

1) yes ... if you need help then just holler with a tad more clarification of your problem

2) yes ... use SkinBeginHtmlHead()

;)

¥

*edit*
bugger
/me suffers from EdB syndrome :roll:

5 Mar 04, 2008 18:19

gupik wrote:

... and a stupid question: why can't I put a plugin into a folder? If I do so, b2evo doesn't see it... are there any special kinds of plugins that get displayed when in folders?

The folder needs a specific name /YOURPLUGIN_plugin/ with inside it the file _YOURPLUGIN.plugin.php. Look for similarities in all other plugins folders

Good luck

7 Mar 04, 2008 21:00

ALMOST got it...

Just I need my plugin to display THE SAME random string in both RenderItemAsHtml and SkinBeginHtmlHead....

argh... being a noob really hurts.

The variable I want to use is:

$movieid = md5(mt_rand());

... but how to make the plugin "accept" the variable? (I get error "undefined variable or sth when I type it just like that)

9 Mar 04, 2008 21:27

OK... thanks :) I'll try it.

... and how to get a blog folder path? (http://www.domain.com/blog/). I already know the this->get_plugin_url(), but I think it's not enough and some js must be called through a full address...

OK, I'll show you something:

I get the error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/yot/ftp/blog/plugins/jwplayer_plugin/_jwplayer.plugin.php on line 51

The code:


/**
	 * Perform rendering
	 *
	 * @see Plugin::RenderItemAsHtml()
	 */

	$movieid = md5(mt_rand());

	function RenderItemAsHtml( & $params )
	{
		$content = & $params['data'];

		// flash:
		$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '
<object id="'.$this->$movieid.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="\\2" height="\\3">
		<param name="movie" value="'.$this->get_plugin_url().'mediaplayer.swf" />
		<param name="allowfullscreen" value="true" />
		<param name="allowscriptaccess" value="always" />
		<param name="flashvars" value="height=\\3&width=\\2&file=\\1&image=\\4&displayheight=\\3&showstop=true" />
        					
</object>', $content );

		return true;
	}


	function SkinBeginHtmlHead( $params = array() )
	{	
		echo '<script type="text/javascript" src="'.$this->get_plugin_url().'swobject.js"></script>'."\n";
		echo '<script type="text/javascript">'."\n";
		echo 'swfobject.registerObject("'.$this->$movieid.'", "9.0.0", "'.$this->get_plugin_url().'expressInstall.swf");'."\n";
		echo '</script>'."\n";
	}

What wrong here? It just doesn't like
$movieid = md5(mt_rand());

Because line 51 it's exactly this line.

10 Mar 04, 2008 22:28

Still, I'd want to insert this code:

<div id="player">This text will be replaced</div>

<script type="text/javascript">
var so = new SWFObject('http://www.domain.com/plugins/mediaplayer.swf','mpl','470','255','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addVariable('width','470');
so.addVariable('height','255');
so.addVariable('file','/upload/movie.flv');
so.write('player');
</script>

into this:

function RenderItemAsHtml( & $params )
   {
      $content = & $params['data'];

      // flash:
      $content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '

HERE GOES THE JAVASCRIPT

', $content );

      return true;
   }

What I really mean is: the " ; " marks are a bit irritating. :) They break the function. What should it look like to be properly read? Should I insert before any " ; " the /n ot /t... there was something like that...

11 Mar 04, 2008 22:58

gupik wrote:

OK... thanks :) I'll try it.

... and how to get a blog folder path? (http://www.domain.com/blog/). I already know the this->get_plugin_url(), but I think it's not enough and some js must be called through a full address...

OK, I'll show you something:

I get the error:

Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/yot/ftp/blog/plugins/jwplayer_plugin/_jwplayer.plugin.php on line 51

The variable is outside a function. Get it inside.

The plugin fodler path is $plugins_path. You must global it first:

global $plugins_path;


before you can use it.
Do have a look at other plugins. Have a particular good look at the code from the video plugin.

Good luck

12 Mar 04, 2008 23:04

OK, but just as I said, I need the same randomed variable in both RenderItemAsHtml and SkinBeginHtmlHead. If I just enter here and there $movieid = md5(mt_rand()); , I'll get two strings. They must be the same to make things work...

And what about putting javascript into RenderItemAsHtml?

For some odd reason $plugins_path returns not Http://... but the system folders, like home/domain/ftp/...blabla. So this doesn't help.

Thanks for help :)

13 Mar 04, 2008 23:13

gupik wrote:

OK, but just as I said, I need the same randomed variable in both RenderItemAsHtml and SkinBeginHtmlHead. If I just enter here and there $movieid = md5(mt_rand()); , I'll get two strings. They must be the same to make things work...

function generateRandom ()
{
   $foo = md5(mt_rand());
   return $foo;
}


First occasion:

$movieid = generateRandom();


second and subsequent occasion:

$this->movieid;

Or something like that.

Good luck

14 Mar 04, 2008 23:18

Thank you very much! :D *hugz*

Now I only need to make RenderItemAsHtml display javascript...

(BTW... I'm a girl, so don't get that hugz too seriously :P)

15 Mar 04, 2008 23:29

gupik,

You must escape all special characters like ' and " in the javascript code. I think this will do:

&lt;script type=\"text\/javascript\"&gt;
var so = new SWFObject(\'http:\/\/www.domain.com\/plugins\/mediaplayer.swf\',\'mpl\',\'470\',\'255\',\'8\');
so.addParam(\'allowscriptaccess\',\'always\');
so.addParam(\'allowfullscreen\',\'true\');
so.addVariable(\'width\',\'470\');
so.addVariable(\'height\',\'255\');
so.addVariable(\'file\',\'\/upload\/movie.flv\');
so.write(\'player\');
&lt;\/script&gt;

16 Mar 04, 2008 23:53

Yeah, I have just figured it out. ^^ I thought that " ; " sign will cause problems, but it doesn't...

BTW, your randomizing function still doesn't work... this time it gives me an error "Call to undefined function". Isn't it strange? We have just defined it...

My code looked like this:


function generateRandom ()
{
   $foo = md5(mt_rand());
   return $foo;
} 


function RenderItemAsHtml( & $params )
	{
		$content = & $params['data'];
		$movieid = generateRandom(); 

		// flash:
		$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '
<div id="'.$movieid.'">Media Player</div>

...blabla

17 Mar 05, 2008 00:04

$movieid = $this->generateRandom();

18 Mar 05, 2008 01:28

Thanks! :D

And the last question:

Putting the lines of code one under another by hitting "Enter" make the render function display "<br />" in the code. How to make a line break without "<br />"?

Thanks :D

19 Mar 05, 2008 01:36

echo "\n"


The \n *must* be within double quotes, so if you are echoing in single qoutes, you *must* concatenate. Example:

echo ( 'sometext' . "\n" . 'someothertext' );

Does it all work as expected?

20 Mar 05, 2008 01:44

emm... well... I still mean the function RenderItemAsHtml. :) I'd like the javascript to be nicely displayed with linebreaks...

If I hit just "enter", I get BRs... and they shouldn't be displayed in this script. >>

<div id="wbytVHuynZWhCynztIRRHvNxr">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>
<script type="text/javascript"> <br />
 // <![CDATA[ <br />
var so = new SWFObject('/plugins/jwplayer_plugin/mediaplayer.swf','mpl','400','300','8');so.addParam('allowscriptaccess','always');so.addParam('allowfullscreen','true');so.addVariable('width','400');so.addVariable('height','300');so.addVariable('showstop','true');so.addVariable('file','http://www.manjikai.com/podcast/audio/y-podcast-2007-04-17-81464.flv');so.addVariable('image','/splash/splash-manji.jpg');so.addVariable('displayheight','300');so.write('wbytVHuynZWhCynztIRRHvNxr'); <br /> // ]]> <br />
 </script> <br />
The movie above uses custom splash image. </center><p></p>

Is there a solution?

21 Mar 05, 2008 01:49

'&lt;script type=\"text\/javascript\"&gt;'."\n".
'var so = new SWFObject(\'http:\/\/www.domain.com\/plugins'\/mediaplayer.swf\',\'mpl\',\'470\',\'255\',\'8\');'."\n".
'so.addParam(\'allowscriptaccess\',\'always\');'."\n".
'so.addParam(\'allowfullscreen\',\'true\');'."\n".
'so.addVariable(\'width\',\'470\');'."\n".
'so.addVariable(\'height\',\'255\');'."\n".
'so.addVariable(\'file\',\'\/upload\/movie.flv\');'."\n".
'so.write(\'player\');'."\n".
'&lt;\/script&gt;'."\n"'

22 Mar 05, 2008 02:13

unfortunately, it still displays <br /> .... maybe \t\n?

Hmm...

23 Mar 05, 2008 02:29

I beat javascript to death with good old fashioned echo. In other words, I did not try to actually directly write javascript. Like so:

echo '<script type="text/javascript">'."\n";
echo '//<![CDATA['."\n";
echo 'var CommentTags = new Array();'."\n";
echo 'var CommentLinks = new Array();'."\n";
echo 'var CommentOpenTags = new Array();'."\n";
echo 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
echo 'this.id = id;'."\n";
echo 'this.display = display;'."\n";
echo 'this.tagStyle = tagStyle;'."\n";
echo 'this.tagStart = tagStart;'."\n";
echo 'this.tagEnd = tagEnd;'."\n";
echo 'this.tit = tit;'."\n";
echo 'this.open = open;'."\n";
echo '}'."\n";

Ocassionally you come across something that you have to escape, but I found that in general this was pretty slick. AND it works :) Though for my purposes I do believe there is a much sweeter method to get 'er done. Live, learn, leave the junk behind without ever actually cleaning up yah?

24 Mar 05, 2008 02:36

Hi gupik,

The <br/> things come from the breaks (Enter) in the code. You should use my code in one line but I won't reproduce that here. EdB' s solution overcomes this problem and therefore is probably what you are looking for.

Good luck

25 Mar 05, 2008 02:44

Yeah, I have put it in one line, and guess what... :D

I'll try again, maybe magic happens...

... BTW, if I think a good way, echo can't be used in renderItemAsHtml...?

26 Mar 05, 2008 03:02

True dat, but this will:

$my_script = '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var CommentTags = new Array();'."\n";
$my_script .= 'var CommentLinks = new Array();'."\n";
$my_script .= 'var CommentOpenTags = new Array();'."\n";
$my_script .= 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
$my_script .= 'this.id = id;'."\n";
$my_script .= 'this.display = display;'."\n";
$my_script .= 'this.tagStyle = tagStyle;'."\n";


Obviously you continue until $my_script holds the entire script you need, then use it as you see fit. In my creative commons license, in the RenderItemAsHtml function, I build up pretty much the entire replacement string that way. It's not javascript in that case, but it *is* html (and an RDF equivalent), and javascript is pretty much html with a bad reputation.

27 Mar 05, 2008 03:08

Hmm... I'll try to figure it out... If I blow up my brain, I'll let you know :)

28 Mar 05, 2008 03:13

Not much to it really.

$a_variable = 'a string of characters ';


So now add another string of characters to it. Two ways, the second of which is nicer:

$a_variable = $a_variable.'another string of characters ';

OR

$a_variable .= 'another string of characters ';

The [[dot equals]] basically means "add this to the end of whatever the variable is". Groovy eh?

29 Mar 05, 2008 03:19

gupik,

In your code this translates as follows:

function RenderItemAsHtml( & $params )
   {
      $content = & $params['data'];

$my_script = '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var CommentTags = new Array();'."\n";
$my_script .= 'var CommentLinks = new Array();'."\n";
$my_script .= 'var CommentOpenTags = new Array();'."\n";
$my_script .= 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
$my_script .= 'this.id = id;'."\n";
$my_script .= 'this.display = display;'."\n";
$my_script .= 'this.tagStyle = tagStyle;'."\n"; 

      // flash:
      $content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );

      return true;
   }


But replace with your actual data

30 Mar 05, 2008 03:29

Dammit... things are a bit complicated for me if the function has this construction:


$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', ' BLABLA JAVA ', $content );

... help? :/

This java just doesn't want to display the flash object when in IE... I think I need to add CDATA to make it display properly... and these tags need linebreaks :(

31 Mar 05, 2008 03:34

you might try \r\n in stead of \n
I don't hive you much chance but being Internet Explorer, who knows.

32 Mar 05, 2008 04:09

Afwas wrote:

gupik,

In your code this translates as follows:

function RenderItemAsHtml( & $params )
   {
      $content = & $params['data'];

$my_script = '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var CommentTags = new Array();'."\n";
$my_script .= 'var CommentLinks = new Array();'."\n";
$my_script .= 'var CommentOpenTags = new Array();'."\n";
$my_script .= 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
$my_script .= 'this.id = id;'."\n";
$my_script .= 'this.display = display;'."\n";
$my_script .= 'this.tagStyle = tagStyle;'."\n"; 

      // flash:
      $content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );

      return true;
   }


But replace with your actual data

Nooo.... it still displays that freakin' <br />!!!

My code:

function RenderItemAsHtml( & $params )
	{
		$content = & $params['data'];
		$movieid = $this->strrand(25); 

$my_script = '<div id="'.$movieid.'">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>'."\n";
$my_script .= '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var so = new SWFObject(\''.$this->get_plugin_url().'mediaplayer.swf\',\'mpl\',\'\\2\',\'\\3\',\'8\');'."\n";
$my_script .= 'so.addParam(\'allowscriptaccess\',\'always\');'."\n";
$my_script .= 'so.addParam(\'allowfullscreen\',\'true\');'."\n";
$my_script .= 'so.addVariable(\'width\',\'\\2\');so.addVariable(\'height\',\'\\3\');'."\n";
$my_script .= 'so.addVariable(\'showstop\',\'true\');so.addVariable(\'file\',\'\\1\');'."\n";
$my_script .= 'so.addVariable(\'image\',\'\\4\');so.addVariable(\'displayheight\',\'\\3\');'."\n";
$my_script .= 'so.write(\''.$movieid.'\');'."\n";  
$my_script .= '// ]]>'."\n"; 
$my_script .= ' </script>'."\n"; 

		// flash:	
	$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );

...O_O

PS. I'll be near commiting a suicide when we'll finally figue it out... but IE still won't display it as it should, LOL... but I saw an example on the site which IE properly read... so there's hope...

I admire you, really :)

33 Mar 05, 2008 04:15

Gupik,

You must do the escape trick (\) with every quote and /. You didn't escape the first three and last two lines of $my_script.

What is the exact output you get? Can you copy/paste it here for us to have a look at it?

34 Mar 05, 2008 04:18

Here it is:

<div id="HPVekPBsrekacTAWTOWyAIRXI">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>
<script type="text/javascript">
//<![CDATA[<br />
var so = new SWFObject('/plugins/jwplayer_plugin/mediaplayer.swf','mpl','400','300','8');<br />
so.addParam('allowscriptaccess','always');<br />
so.addParam('allowfullscreen','true');<br />
so.addVariable('width','400');so.addVariable('height','300');<br />
so.addVariable('showstop','true');so.addVariable('file','http://www.manjikai.com/podcast/audio/y-podcast-2007-04-17-81464.flv');<br />
so.addVariable('image','/splash/splash-manji.jpg');so.addVariable('displayheight','300');<br />
so.write('HPVekPBsrekacTAWTOWyAIRXI');<br />
// ]]><br />
 </script>

35 Mar 05, 2008 04:24

Another thing you can do to "clean up" the look of the code is ... well heck I'll show you one line and you'll see:

$my_script .= 'so.addParam(\'allowscriptaccess\',\'always\');'."\n";

Changes to this:

$my_script .= "so.addParam('allowscriptaccess','always');"."\n";

Technically speaking I could go one step further and do this:

$my_script .= "so.addParam('allowscriptaccess','always');\n";

hey... Do you have spaces after your "\n"; bits? If so you might consider removing them just to see.

Anyway all I did was replace ' with " around the bits to add to the so.addParam bit so that I would not have to escape all the 's that are part of each line.

36 Mar 05, 2008 04:29

gupik,

You do use a text editor like notepad++ or crimson editor or Scintilla or whatever and *not* a html editor?

37 Mar 05, 2008 04:48

I wrote it like this:

function RenderItemAsHtml( & $params )
	{
		$content = & $params['data'];
		$movieid = $this->strrand(25); 

$my_script = "<div id=\"$movieid\">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>\n";
$my_script .= "<script type=\"text/javascript\">"."\n";
$my_script .= "//<![CDATA["."\n";
$my_script .= "var so = new SWFObject('".$this->get_plugin_url()."mediaplayer.swf','mpl','\\2','\\3','8');\n";
$my_script .= "so.addParam('allowscriptaccess','always');\n";
$my_script .= "so.addParam('allowfullscreen','true');\n";
$my_script .= "so.addVariable('width','\\2');so.addVariable('height','\\3');\n";
$my_script .= "so.addVariable('showstop','true');so.addVariable('file','\\1');\n";
$my_script .= "so.addVariable('image','\\4');so.addVariable('displayheight','\\3');\n";
$my_script .= "so.write('$movieid');"."\n"; 
$my_script .= "// ]]>"."\n"; 
$my_script .= " </script>\n"; 

		// flash:	
	$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );


... and it still shows the same output. Deleting /n merges the lines... I wrote "."/n" near the places in which line breaks are crucial (I think)... the rest can be merged.

What do you think?

38 Mar 05, 2008 04:59

I use simple notepad...

What bothers me is: between </div> and <script... > There's a correct line break, and then there are that <br />...

Another variation I made, and still the same (it only added the tab space)

$my_script = "\n\t"."<div id=\"$movieid\">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>";$my_script .= "\n\t"."<script type=\"text/javascript\">";$my_script .= "\n\t"."//<![CDATA[";$my_script .= "\n\t"."var so = new SWFObject('".$this->get_plugin_url()."mediaplayer.swf','mpl','\\2','\\3','8');";$my_script .= "\n\t"."so.addParam('allowscriptaccess','always');";$my_script .= "\n\t"."so.addParam('allowfullscreen','true');";$my_script .= "\n\t"."so.addVariable('width','\\2');so.addVariable('height','\\3');";$my_script .= "\n\t"."so.addVariable('showstop','true');so.addVariable('file','\\1');";$my_script .= "\n\t"."so.addVariable('image','\\4');so.addVariable('displayheight','\\3');";$my_script .= "\n\t"."so.write('$movieid');"; $my_script .= "\n\t"."// ]]>"; $my_script .= "\n\t"." </script>"; 

I always refresh both plugin and the page...

39 Mar 05, 2008 05:09

I may be way off-base, but when ever I'm working on plugins I DELETE the plugin then re-install it. Now, if you are seeing a change each time you upload your new material and refresh the plugin then obviously I'm just crazy.

Also do I understand that this is an IE issue? In other words is it working in Firefox or some other browser but not in IE, or is IE the only browser you've been testing with?

40 Mar 05, 2008 05:17

You delete it via ftp or just in the CP? Because I delete it in CP... and still the same.

Yup, it's only IE issue... but it really works in IE with that CDATA comments (I saw it in the other site. The only thing I missed in my code were CDATA tags). In other browsers it works without CDATA (and without any need to make line breaks). In Firefox it even works with that <BR />s :D.

Anyway, I can just leave it and use "Object" tag... (it also validates XHTML strict) but I have heard that SWFobject is just sooo great :) It skips the IE "click to activate" stupidity, for example... and has best cross-browser compability. Youtube uses it...

It's 5.00 a.m. where I live... I better go to bed or I'll smash my head onto keyboard :P Thanks for help, see you tomorrow :D

42 Mar 05, 2008 05:41

I will look at it tomorrow.
Change

var $priority = 65;


to

var $priority = 10;


You must make sure your priority is higher (and the number lower) than the autop plugin.
This is a likely cause of your <br /> problem.

Good luck

43 Mar 05, 2008 17:03

Afwas wrote:

I will look at it tomorrow.
Change

var $priority = 65;


to

var $priority = 10;


You must make sure your priority is higher (and the number lower) than the autop plugin.
This is a likely cause of your <br /> problem.

Good luck

I'll need it :)

I changed to priority = 10 and still the same... The auto_p 's priority is 70.

44 Mar 05, 2008 18:10

change your plugins priority to 80 ;)

¥

46 Mar 06, 2008 17:16

SWFObject is used only for FLV player, not yet for mp3 player. :) I can see your player, it's all OK... which browser do you have? I'm worried about your browser's crashing...

OK, I'll try to change the priority.

47 Mar 06, 2008 17:22

It's an mp3 indeed and set up with the mp3 player.
I use FireFox 2 and FireFox 3.
My RSS viewer also crashed upon opening the mp3 in the player :/

48 Mar 06, 2008 17:36

Yes! :) Now it works! (The flv player) No more <BR />! (The priority set to 80 helped).

Please try to put mp3 into FLV player. It also plays mp3s, just set the height to 20 and put any splash image you like. Tell me if it crashes, ok?

If not, then I'll just delete the mp3 players... these just have nice skins, nothing more.

49 Mar 06, 2008 17:47

Well it doesn't crash, actually it plays! Any examples of splash screens? I tried classic.swf, but it leaves a black bar.

50 Mar 06, 2008 18:16

I will update swfobject in a second to newest one with patch for IE (it didn't play because of a described somewhere issue...). In a minute I'll deliver updated zip file.

Here's the demo of a player (playing flv file):

http://blog.manjikai.com/dojo.php/basic-flowplayer-integration-plugin

A splash screen is just a simple JPG file.

BTW, instead of a file you can also insert xml files with playlists, but I'll need to make a separate admin button for it (player that plays a playlist doesn't need a splash image)

In this package I'll also include a very nice playlist generator script.

See the player with a playlist in action here:
http://www.jeroenwijering.com/?page=wizard&example=22

51 Mar 06, 2008 18:36

OK, plugin updated :)

http://blog.manjikai.com/media/users/admin/Tools/jwplayer_plugin.zip

Now to make another admin button for player with a playlist :D

Can you tell me how this player acts in any rss reader?

EDIT: Hmmm... I think I know wht this plugin breaks RSS reader. The "my_script" part gets read by the reader. As I see the Videoplug plugin, we would need some kind of RenderItemAsXml:

/**
	 * Perform rendering for XML feeds
	 *
	 * @see Plugin::RenderItemAsXml()
	 */
	function RenderItemAsXml( & $params )
	{
		$this->RenderItemAsHtml( $params );

		/*
		$content = & $params['data'];
		$Item = & $params['Item'];
		$my_script = "";
		$sc_script = "";

		$content = preg_replace( '¤\[object:flv(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<p>Media file</p>', $content );
		$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<p>mp3 file</p>', $content );
		*/

		return true;
	}

This is what I added, but it doesn't work...

52 Mar 07, 2008 01:05

I try to implement a proper rendering from RSS... without any success.

Can you tell me what's wrong here? (code) It's based on video plugin...


	function RenderItemAsHtml( & $params )
	{
		$content = & $params['data'];
		$movieid = $this->strrand(25); 

		// flash:
	
	$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<div id=\''.$movieid.'\' style=\'display:block\'></div>'."\n\t".'<script type=\'text/javascript\'>'."\n\t".'//<![CDATA['."\n\t"."\n\t".'var so = new SWFObject(\''.$this->get_plugin_url().'mediaplayer.swf\',\'mpl\',\'\\2\',\'\\3\',\'8\');'."\n\t".'so.addParam(\'allowscriptaccess\',\'always\');'."\n\t".'so.addParam(\'allowfullscreen\',\'true\');'."\n\t".'so.addVariable(\'width\',\'\\2\');'."\n\t".'so.addVariable(\'height\',\'\\3\');'."\n\t".'so.addVariable(\'showstop\',\'true\');'."\n\t".'so.addVariable(\'file\',\'\\1\');'."\n\t".'so.addVariable(\'image\',\'\\4\');'."\n\t".'so.addVariable(\'displayheight\',\'\\3\');'."\n\t".'so.write(\''.$movieid.'\');'."\n\t"."\n\t".'// ]]>'."\n\t".' </script>' , $content );

		$movieid = $this->strrand(25); 

		// mp3:

	$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<div id=\''.$movieid.'\' style=\'display:block\'></div>'."\n\t".'<script type=\'text/javascript\'>'."\n\t".'//<![CDATA['."\n\t"."\n\t".'var so = new SWFObject(\''.$this->get_plugin_url().'mediaplayer.swf\',\'mpl\',\'\\2\',\'\\3\',\'8\');'."\n\t".'so.addParam(\'allowscriptaccess\',\'always\');'."\n\t".'so.addParam(\'allowfullscreen\',\'true\');'."\n\t".'so.addVariable(\'width\',\'\\2\');'."\n\t".'so.addVariable(\'height\',\'\\3\');'."\n\t".'so.addVariable(\'showstop\',\'true\');'."\n\t".'so.addVariable(\'file\',\'\\1\');'."\n\t".'so.write(\''.$movieid.'\');'."\n\t"."\n\t".'// ]]>'."\n\t".' </script>' , $content );


			return true;
	}

	/**
	 * Perform rendering for XML feeds
	 *
	 * @see Plugin::RenderItemAsXml()
	 */
	function RenderItemAsXml( & $params )
	{
		$this->RenderItemAsHtml( $params );

		/*
		$content = & $params['data'];
		$Item = & $params['Item'];

	$content = preg_replace( '¤\[object:flv(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<p>Media file</p>', $content );
	$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<p>MP3 file</p>', $content );

		return true;
		*/
	}

53 Mar 07, 2008 01:27

   function RenderItemAsXml( & $params )
   {
      $return_this = $this->RenderItemAsHtml( $params ); 
      return $return_this;
   }

54 Mar 07, 2008 01:30

Is it a whole function or should I enter something into it as well?... o_O?

Hmm... this function, judging from the source code of the xml page from the reader (standard firefox reader), outputs the post twice, and the output is without a proper rendering. What I want accomplish is to make the renderItemAsXml completely change the output of RenderItemAsHtml... just as in videoplugin.

Hmm... I have a feeling that it has something to do with "CDATA"...

55 Mar 07, 2008 01:54

perhaps it is

return true;


You want to copy the complete code from renderItemAsHtml and redo it, the way you want it to be output in the RSS.

56 Mar 09, 2008 21:41

I have this function as follows:

 function RenderItemAsXml( & $params )
	   {
	      $return_this = $this->RenderItemAsHtml( $params ); 

		/*
		$content = & $params['data'];
		$Item = & $params['Item'];

	$content = preg_replace( '¤\[object:flv(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<p>Media file</p>', $content );
	$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<p>MP3 file</p>', $content );

		 return $return_this;
		*/
		
	   } 

It still breaks the output of RSS...

EDIT:

OK, I eliminated the CDATA in javascript, as I supposed it was the case of RSS reader breaks... but well, is it possible to completely eliminate the javascript output in the XML? I have written in the RenderItemAsXml "Media file" and "MP3 file" but it doesn't appear...

See here:

http://blog.manjikai.com/dojo.php/basic-flowplayer-integration-plugin

Also: click the Entries RSS at the very bottom.

57 Mar 10, 2008 00:45

Try:

 function RenderItemAsXml( & $params )
      {
         $return_this = $this->RenderItemAsHtml( $params );
         return true;
       }

58 Mar 10, 2008 21:33

as far as I see, it displays the same ...

What about RSS enclosure? ...


Form is loading...

Free CMS – This forum is powered by b2evolution CMS, a complete engine for your website.