This blog entry was posted by peter on September 28, 2007.
It is tagged with Django, Flash, flv, template, and video.
So far there are 2 comments. Feel free to add one.
The previous entry chronologically is Experiments on Last.FM in X3D.
A Django application for integrating a Flash based videoplayer into templates using a custom template tag. It is based on the videoplayer from JW FLV Player and can be easily customized by template parameters.
The Django application code is licensed under a BSD license.
The application uses the JW FLV Player by Jeroen Wijering which is licensed under a Creative Commons License.
The flvplayer app is only available as a tarball. It contains the Django application and the flashplayer from JW FLV Player.
To install the videoplayer app, follow these steps:
That’s it. The flvplayer does not use any models or views, only a custom template tag named flvplayer.
The flvplayer can be used in any template like this:
1 2 3 4 | {% load flvplayer %}
# …
{% flvplayer file=file_url %}
# …
|
First load the flvplayer template tag library, then instantiate the player as often as you like, using different files and/or player configurations.
Here’s a live example:
The flvplayer can be customized to fit your project’s needs.You can set looping, width, height and the colors for the various player areas like this:
1 | {% flvplayer file=file_url,autostart=True,backcolor=0xff000 %}
|
The following table contains the full list of supported parameters. The original can be found at jeroenwijering. Please be aware that the original values for bool variables have been pythonified: Instead of using true and false the flvplayer tag can also use False and True.
Please refer to jeroenwijering for a detailed explanation of the parameters. Note that not all parameters are supported by the template tag right now.
| Parameter | Default | Description |
|---|---|---|
| file | The URL of the flv file | |
| playerUrl | see below | The URL of the player.swf file |
| image | Preview image (JPG/SWF/PNG/GIF) | |
| displayheight | Height of the display | |
| displaywidth | Width of the display | |
| height | Height of the player | |
| width | Width of the player | |
| backcolor | 0xFFFFFF | Background color of the player |
| frontcolor | Texts / buttons color of the player | |
| lightcolor | Rollover/ active color of the player | |
| autostart | False | Specifies whether the player starts automatically. Can be one of [True,False,Muted] |
| autoscroll | False | Playlist scrollbar behaviour |
| largecontrols | False | Make the controlbar twice as large |
| logo | Logo in the top right corner of the display | |
| overstretch | How to stretch movies to make them fit the display | |
| showdigits | True | |
| showvolume | True | Show/hide the volume button |
| bufferlength | 3 | Number of seconds an FLV should be buffered ahead |
| repeat | False | |
| volume | 80 |
By default the flvplayer tag uses the flvplayer.swf found at {{ MEDIA_URL }}/flvplayer/flvplayer.swf.
To change that behaviour pass the URL of the player using the playerUrl parameter like this:
1 | {% flvplayer file=file.mp3,playerUrl=/foo/bar/player.swf %}
|
The following code is inserted by the flvplayer template tag based on the flvplayer/flvplayer.html template (the shown code is just an example and varies depending on your parameters):
1 2 3 4 5 6 7 8 | <object classid=“clsid:d27cdb6e-ae6d-11cf-96b8-444553540000” codebase=“http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0” width=“180” height=“60”> <param name=“width” value=“180” /> <param name=“height” value=“60” /> <param name=“bgcolor” value=“f2f2f2” /> <param name=“flashvars” value=“height=18&amp;bg=0xF7F7F7&amp;slider=0xB29461&amp;track=0xFFFFFF&amp;righticon=0x666666&amp;lefticon=0x666666&amp;soundFile=%2Fmedia%2Faudio%2FSuitcase_-_Sheep.mp3&amp;loader=0xEEFFCC&amp;rightbg=0x22C1D6&amp;bgcolor=0xf2f2f2&amp;rightbghover=0x32D1E6&amp;autostart=no&amp;text=0x4F4F4F&amp;leftbg=0xBAFF7B&amp;righticonhover=0x444444&amp;border=0x00FF00&amp;width=156&amp;loop=no” /> <param name=“src” value=“/media/flvplayer/flvplayer.swf” /> <embed type=“application/x-shockwave-flash” width=“180” height=“60” bgcolor=“f2f2f2” flashvars=“height=18&amp;bg=0xF7F7F7&amp;slider=0xB29461&amp;track=0xFFFFFF&amp;righticon=0x666666&amp;lefticon=0x666666&amp;soundFile=%2Fmedia%2Faudio%2FSuitcase_-_Sheep.mp3&amp;loader=0xEEFFCC&amp;rightbg=0x22C1D6&amp;bgcolor=0xf2f2f2&amp;rightbghover=0x32D1E6&amp;autostart=no&amp;text=0x4F4F4F&amp;leftbg=0xBAFF7B&amp;righticonhover=0x444444&amp;border=0x00FF00&amp;width=156&amp;loop=no” src=“/media/cms/flvplayer/player.swf”></embed> </object> |
The code shown above is read from the template flvplayer/flvplayer.html. You can provide a custom template to adopt the code to your needs. The template will be passed the following context variables:
Hi there,
just trying this, very cool. But, why isn't it showing thumbnails in the playlist?
bernd said on October 05, 2007
look cool, I test it soon.
Thanks for that.