|
Mar
18
|
I was searching for some Textpattern (the CMS powering the Jorid) plugin which could give me the possibility to display a playlist of some of Jib’s animations, and decided that creating my own plugin would be quicker.
It uses Jeroen Wijering’s Flash Media Player to be able to insert Flash movies (.flv) into a webpage, in the manner of a local “youtube”.
[Latest version is now found here]
Some details are given below, if others are interested in implementing it (it also works for all the formats recognized by the Flash media player, like mp3, jpg etc.).
Documentation is scarce, but hopefully legible enough.
Notes
This plugin is a simplified version loosely based on a previous integration (bas_flvplayer) made by Bastian Sackermann.
It is called for instance like this
<txp:elk_mediaplayer video="3,4" width="400" height="200" plwidth="200" />
provided that the filemediaplayer.swfis uploaded in the textpattern “files” folder, along with SWFObject javascript library 1.5 that can be found on Jeroen’s website.Parameters are (not exhaustive and can be adapted in the code itself)
- video: a list of videos (names or IDs, separated by commas)
- width: width of the player
- height: height of the player
- plwidth: height of the playlist, if applicable (default=0)
NB: to simplify the use of the plugin, the Flash Player requires a playlist, even if for just one file. In that case, it requires a special setup of textpattern to deliver a XML file that will create the playlist itself (see function
elk_playlist).
This can be done by following these steps:
- create a “playlist” page with the following code:
<txp:mg_setheader />
<txp:output_form form="playlist" />
Where the required pluginmg_setheaderallows to change the header sent to XML.- Create a section “playlist”, using the page “playlist”
- Create the form “playlist” as follows (a bit dirty, would welcome a more elegant solution)
<txp:php>
$videos = isset($_GET["v"]) ? $_GET["v"] : "" ;
parse("<txp:elk_playlist id=\"$videos\" />") ;
</txp:php>
And it should work… (older version, for the record : elk_mediaplayer v0.1)
[June 12th 2008 update] in version > 0.1 the plugin takes the first article image (if any provided) to put as a preview image in the mediaplayer.
If you want to enable this, you need to change the form accordingly, so that the page can pass the image id to the XML playlist:
<txp:php>
$videos = isset($_GET["v"]) ? $_GET["v"] : "" ;
$image = isset($_GET["i"]) ? $_GET["i"] : "" ;
$sort = isset($_GET["st"]) ? $_GET["st"] : "" ;
$sortby = isset($_GET["sb"]) ? $_GET["sb"] : "" ;
parse("<txp:elk_playlist id=\"$videos\"img=\"$image\" sort=\"$sort\"sortby=\"$sortby\"/>") ;
</txp:php>
Download the plugin (updated July, 9th 2008):






March 19th, 2008 at 6:55 pm
sounds cool. i have exceeded my broadband useage this month and it is taking ages to look at anything so i will have to wait till i am on high speed again
March 19th, 2008 at 9:01 pm
The good thing is that these flash movies are not very big to download…
Well, as long as Jib isn’t doing a whole feature film that is
June 11th, 2008 at 3:20 pm
Hey Yuki,
I’ve got this plugin working fine, thanks by the way, but I want the ability to have a placeholder image before the movie starts. I have tried modifying the code myself, but it is beyond my very basic skills. Can you tell me what needs to be done?
Many Thanks
June 11th, 2008 at 4:46 pm
Hi Zander, glad it works for you.
For doing what you want, you may use an external JS function encapsulating the call (basically something like this)
function showVideo(myId, url, width, height){swfobject.embedSWF(url, myId, width, height, "8.0.0");
}
instead of directly calling the movie as it is done in the plugin.
For the placeholder image, it needs to be put inside the <div> with something like
<a href="javascript:void(0)" onClick="javascript:showVideo('etc.')><img src="link_to_your_placeholder_image"/></a>So that when the page first loads it loads the image inside the <div>, and when you click on it, it calls the javascript replacement of what’s inside the named <div>.
Hope it helps
June 11th, 2008 at 5:34 pm
Hey Yuki,
Cheers for replying so soon. Why would you not use a flashvar like it says you are able to on JW’s site? could a solution not be made for that?
Also, your solution is a bit beyond me, could you explain? or even better, spell it out step by step… maybe you’d prefer to email me..?
Cheers
June 12th, 2008 at 9:23 am
Oh, I probably got you wrong; do you mean you’d want to have an image inside the mediaplayer before it starts?
(I thought you wanted an image to load instead of the player, and then, when you click on the image, it loads the player… That would be a bit more tricky to realize)
If that’s what you want, that must be easy with the flashvars and adapting the XML… Only thing is… what image would you take? with a name based on the name of the video(s)?
And if you got more than one clip (with the playlist having more than one file) how do you manage this case?
June 12th, 2008 at 1:25 pm
I’ve made an updated version of the plugin; it seems to works here, hope it will for you too
June 12th, 2008 at 3:02 pm
Eric,
Thank you so much for all the help.
It works perfectly.
July 2nd, 2008 at 6:59 pm
Yuki:
Thanks for the great plugin, I was looking for the exact upgrade you just made.
My problem is that when I try to load it into TXP 4.06 I get:
Badly formed or empty plug in
Any assistance would be greatly appreciated.
July 2nd, 2008 at 7:56 pm
Hi Randy,
I’m using the 4.06 version too, and don’t have the problem you mention… Not sure how you are proceeding?
Usually, going to admin>plugins tab and pasting all the code (select all with CTRL+A, then copy) inside the
.txtfile into theInstall pluginarea works fine…July 3rd, 2008 at 2:01 pm
Yuki:
Thanks for the quick reply Uki. I tried again and got same message.
To test I uploaded a different plug in and it worked like a charm. Is there any other way we can do this. I know in the past when I have worked with Gerhard, we have had it look at a Plug In folder rather than loading thru TXP. Not sure if this is an option.
Willing to try anything. Please let me know.
Randy
July 3rd, 2008 at 5:41 pm
Randy, I’ve sent you the decoded php version of the plugin, if you want to try it in the plugin folder… You can try to reimport it into the database plugins with the useful “plugin composer” extension (
ied_plugin_composer)…Hope it helps!
July 8th, 2008 at 3:40 am
Yuki:
I just wanted to let you know .. I have now got the plug in to load and the player to appear … I am close … but now I get two different error messages I was hoping you could decipher …
If I use the image ID (I assume you mean File ID) I get Error #2032.
If I use the actual file name, it states that it can not find it and provides me with the path …/playlist?v=video.flv. I have uploaded this file thru TXP. I also made a copy in a folder called “playlist”. Finally I put a copy in the root. All of theses were unsuccesful.
I have followed the instructions regarding the section; page and form. So I am now stumped. Any assistance would be appreciated.
Thanks.
July 8th, 2008 at 11:33 am
Hi Randy,
The error #2032 seems to be related to Flash having issue with
crossdomain.xmlfileI didn’t mention that, but usually it seems you’d have to put a crossdomain.xml at the root of your domain to allow flash to access files -> see some documentation here
Tell me if that helps
July 8th, 2008 at 9:33 pm
Hey Yuki,
Hope all’s well. I would like to be able to sort the playlist created from this plugin. At the moment it uses the files id ascending to create it play order. I can’t seem to use the sort attribute. Can I make it so they play in the order I enter them?
For instance:
Many thanks
July 9th, 2008 at 1:58 pm
Hey Zander,
I’ve updated the plugin elk_mediaplayer v0.2 with your suggestion.
You have to make some adjustments to the form to pass the new variables (sort, and sortby).
By default, the sorting should be the same as provided, as long as you keep it all IDs.
It made me learn a new sql trick on the way
Enjoy! (very nice use of the plugin on your website by the way!)
July 25th, 2008 at 1:52 pm
Hello, Yuki.
I try to setup your plugin. Everything is ok but i can’t to understand how to use playlist. I follow all your recomendations, and now player write ” This playlist is not valid XML file”.Please give advise me, what to do?! And just one question: in what folder i must to store video and other media =)
July 27th, 2008 at 8:16 pm
Hi Ivan,
You can try to display the playlist directly in your browser; as it’s an XML file, browsers like Firefox and probably IE can show the XML if it’s properly rendered.
The address should be something like
my.site/playlist?v=1,2where 1 and 2 are for example the textpattern IDs of the uploaded videos I want to have in my playlist.By default in my installation, uploaded videos go in the “files” folder, so the XML reads the correct path in the
<location>tag… (something likemy.site/files/video1_name.flv)If the XML doesn’t show up, then it may be a problem with the sent headers (you need to install the mg_setheader plugin)… Otherwise, you should be able to tell by reading it what is the problem.
Hope it helps =)