You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Patch to add XML support to Flowplayer Created Mar 14, 2009

This thread is solved

Views: 4476     Replies: 8     Last reply Sep 20, 2011  
You must login first before you can use this feature

Wojjie

Posts: 7

Registered:
Mar 2, 2009

Patch to add XML support to Flowplayer

Posted: Mar 14, 2009

I'm not sure where to post this, as it is not really a plug in, but it doesn't really fit in any other forum.

Update (Mar 15):
Fixed a bug where events were not working due to 'playerId' being lost.

Introduction
I was shocked to see that Flowplayer does not support XML feeds, there are plenty of users that need some method of giving their users an embed feature while making it difficult for them to remove any plugins they wish.

I made modifications to the Flowplayer source (thankfully its open source/GPL) and made a patch file anyone can apply to add support for XML 'config' files.

Patch (for flowplayer 3.0.7):
http://code.wojjie.com/flash/flowplayer/patches/XMLPatch-3.0.7.diff

This patch was made against the 3.0.7 source. To apply it on a unix system:

cd [flowplayer src directory]
patch -p0 < XMLPatch-3.0.7.diff

Then you can run 'ant' and build a new flowplayer.swf to use.

To use XML feeds with this patch, you must specify the flashvar 'xml', which you should specify an absolute path (ie:http://domain/get/test.xml) for incase you embed it on other pages. You can either specify it with the javascript API, or directly when embedding the player on your page.

Javascript API:

$f("player", "/flowplayer/flowplayer.swf", {'xml':'http://domain/get/test.xml'});

Embed:

<object id="player_api" height="300" width="400" type="application/x-shockwave-flash" data="/flowplayer/flowplayer.swf">
<param name="movie" value="/flowplayer/flowplayer.swf" />
<param value="true" name="allowfullscreen"/>
<param value="always" name="allowscriptaccess"/>
<param value="high" name="quality"/>
<param value="#000000" name="bgcolor"/>
<param value="xml=http://domain/get/test.xml" name="flashvars"/>
</object>

XML Format
The XML file is laid out the same way you would configure flowplayer through the javascript API:

<flowplayer>
	<plugins>
		<controls display="none" ></controls>
	</plugins>
	<playlist url="test.flv" linkUrl="http://www.google.com" linkWindow="_blank" ></playlist>
	<playlist url="test.flv"" ></playlist>
</flowplayer>

This XML file will hide the controls, and add 'test.flv' to the playlist and make the video link to Google in a new window.

Also, when specifying an XML file it will completely overwrite any other config that is passed to it outside the XML unless you specify 'merge' in the XML file, at which point it will merge the two configurations giving priority to the XML file (XML will override the other config where the collide).

Example:

<flowplayer merge="1">
	<plugins>
		<controls display="none" ></controls>
	</plugins>
	<playlist url="test.flv" linkUrl="http://www.google.com" linkWindow="_blank" ></playlist>
	<playlist url="test.flv"" ></playlist>
</flowplayer>

So if you specify multiple playlist items with the javascript API and you use this XML file, it will keep your playlist, but replace the first item with 'text.flv'.

Last few things before I finish this post:
  • you don't have to use 'flowplayer' as the top XML node, you can essentially use anything you want, the player ignores it.

  • any events used with the javascript API are not passed to the player through flashvars, and therefore will still work even if 'merge' is not set

  • using an XML config file does not replace javascript event listeners, so if you are wanting to hide the controls before a given clip, you will have to use javascript, or modify the Flowplayer source to add config support for this. (I am actually working on this one at the moment for someone)

  • I am new to Flash development, but have been a programmer all my life and know many different languages, so it was easy to pick up. The only thing is, since I am new, I may have not developed this in the most clean/proper way.

  • When adding support for XML, I tried to modify the code in a way that would be easiest to implement into future versions (incase the flowplayer team does not add support for XML soon)

I will do my best to keep an eye out on this thread.
I can also be contacted via MSN: wojjie [at]] hotmail (dot) com (please do not try to contact me through my website, as it is horribly out of date, I don't even do hosting anymore)

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» Patch to add XML support to Flowplayer

Posted: Mar 16, 2009

Reply to: Patch to add XML support to Flowplayer, from Wojjie
wow. impressive work! congratulations. you seem to have gotten a good insight on flowplayer development quite fast. I especially like this patching thing - professional.

few questions. what is the primary reason for XML configurations? you could have accessed JSON files from a specified url too.

are your skills available? would you be interested on developing things for Flowplayer?

Wojjie

Posts: 7

Registered:
Mar 2, 2009

» » Patch to add XML support to Flowplayer

Posted: Mar 16, 2009

Reply to: » Patch to add XML support to Flowplayer, from tipiirai
Thank you.

It took a while, I have been 'grep'ing through the code looking for the best way to implement new features into Flowplayer, though I think I have gotten the hang of it. Still learning how to develop plugins, and compiling them into flowplayer, but have a couple deadlines looming, so I have been just modifying Flowplayer directly.

The patching is so that I don't have to redistribute the code, for which I was not certain if you would get upset about. It also allows people to apply multiple patches/features to the code without having to know the code (unless there are conflicts/collisions).

To be honest, I didn't think of using JSON, just thought XML was the way Flash developers went with loading external data, but it would be easy to modify it to read JSON files as well.

Reason why I decided to implement this is so it would be easier to embed videos on other sites, while making it more difficult for the user to remove ads, and settings. The actual version I made has certain things hard coded into Flowplayer, for instance the path to the XML file, and might make it require an XML file later down the road.

They are available, would love to contribute some 'features' to Flowplayer, since there are so many things I wish it had, and will possibly be developing them anyway. Feel free to email me and we can discuss this further. (I'm sure you can get my email from your forum system)

Andre Reiter

Posts: 19

Registered:
Feb 13, 2009

» » » Patch to add XML support to Flowplayer

Posted: May 11, 2009

Reply to: » » Patch to add XML support to Flowplayer, from Wojjie
Hi Wojjie,

very nice feature... seams to work very well!
It's a pity, that this patch did not find a way into the 3.1.0 release...
unfortunately its not working together with an other nice featurehttp://flowplayer.org/forum/7/15909, which is actually not officially supported

if i define the playlist over a rss url, it does not work
i'm new to the AS programming, anyway i'll try to find the reason, why its not working...

regards
[Edit]
ok, i've found the solution for this patch, now it works with the RSS lists. after applying the patch, i commented out this two lines in the ConfigLoader.as:
  
// }else if ( forceArray.indexOf(prefix+cname) > -1 ){
// o[cname] = [val];

changed patch:http://andiger.homelinux.org/XMLPatch-3.1.0-dev.diff
now it works fine with rss

Andre Reiter

Posts: 19

Registered:
Feb 13, 2009

» » » » Patch to add XML support to Flowplayer

Posted: May 20, 2009

Reply to: » » » Patch to add XML support to Flowplayer, from andiger
cool, with the version 3.1.1 the player does suppert the external configuration
no xml, json only... anyway the format does not matter... :-)
thanks for that!!!

happyhour

Posts: 1

Registered:
Aug 2, 2009

» Patch to add XML support to Flowplayer

Posted: Aug 2, 2009

Reply to: Patch to add XML support to Flowplayer, from Wojjie
Hi,

thankyou for the patch.

How can I apply it on a normal windows PC?
What kind of file is diff ?

Do you have an URL where I can see an example?

Sorry, I´m not a programmer :-)

kevin
We are Video Branding

Posts: 7

Registered:
Oct 23, 2009

Does it work with 3.14???

Posted: Nov 18, 2009

Reply to: Patch to add XML support to Flowplayer, from Wojjie
Hey does this work with the 3.15 version? I really wanna use this, but don't wanna waste the time working on it, if it isn't compatible.

XML E4X should be standard for this player. Hopefully flowplayer team can include it in the next update.