Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Template tag now accepts and *array* of urls and converts it into a f…

…lowplayer playlist. Configuration of flowplayer settings now available via the FLOWPLAYER_CONFIG settings variable, containing a dict of (most) available flowplayer settings. A 'default' entry allows for global settings to be used also. Combined with the CSS this allows for example audio/video display to differ, or different players to be used on different pages of the site with a single keyword change in the calling tag.
  • Loading branch information...
commit 08c4e135f822c685a69053f75a4ec038c8273911 1 parent 5e6bd77
@mfitzp authored
View
36 docs/overview.txt
@@ -92,6 +92,28 @@ FLOWPLAYER_URL
The url to the flowplayer flash file (and -controls and audio plugins).
+FLOWPLAYER_CONFIG
+--------------
+
+This is a dict defining the config settings for the play for a given player type.
+The root entry is the type e.g 'audio' with the configuration entries following the
+same hierarchy as defined in the flowplayer docs.
+
+Any settings in 'default' will apply to all players (settings are merged with
+any named player you define). See below for an example:
+
+FLOWPLAYER_CONFIG = {
+ 'default' :
+ { 'clip' : { 'autoPlay':'false' },
+ 'plugins' : { 'controls' : { 'playlist': 'true' } }
+ },
+
+ 'audio' :
+ { 'clip' :
+ { 'autoPlay':'false' }
+ },
+ }
+
Template tags
=============
@@ -105,19 +127,23 @@ Tag reference
flowplayer
~~~~~~~~~~
-Outputs a flowplayer mediaplayer instance for a given url, with an optional
-'classtype' parameter for specifying audio player display. When provided
-classtype is used to add an additional CSS class to the player, in the form
-flowplayer<classtype>, allowing for specific layouts for given mediatypes.
+Outputs a flowplayer mediaplayer instance for a given url/playlist array, with an optional
+'playertype' parameter for specifying audio player display. When provided
+playertype is used to add an additional CSS class to the player, in the form
+flowplayer<playertype>, allowing for specific layouts for given mediatypes.
See example.css in the media/css folder for a demonstration.
Usage::
- {% flowplayer url classtype %}
+ {% flowplayer media playertype %}
Examples::
{% flowplayer object.url %}
{% flowplayer http://example.com/video.flv %}
{% flowplayer http://example.com/audio.mp3 audio %}
+ {% flowplayer array_of_urls %}
+
+
+
View
55 flowplayer/templates/flowplayer/flowplayer.html
@@ -1,10 +1,45 @@
- <a
- href="{{ media_url }}"
- class="flowplayer{% if player_class %} flowplayer{{ player_class }}{% endif %}"
- id="flowplayer{{ player_id }}">
- </a>
-
- <!-- this will install flowplayer inside previous A- tag. -->
- <script>
- flowplayer("flowplayer{{ player_id }}", "{{ player_url }}");
- </script>
+<a
+ href="{{ media_url }}"
+ class="flowplayer{% if player_class %} flowplayer{{ player_class }}{% endif %}"
+ id="flowplayer{{ player_id }}">
+</a>
+<!-- this will install flowplayer inside previous A- tag. -->
+<script>
+ flowplayer("flowplayer{{ player_id }}", "{{ player_url }}", { // supply the configuration
+
+ {% if player_config.clip %}
+ clip : {
+ {% for keycl, valuecl in player_config.clip.items %}
+ {{ keycl }}: {{ valuecl }}
+ {% endfor %}
+ },
+ {% endif %}
+
+ {% if media_playlist %}
+ playlist: [
+ {% for entry in media_playlist %}'{{ entry }}', {% endfor %}
+ ],
+ {% endif %}
+
+
+ {% if player_config.plugins %}
+ plugins: {
+ {% if player_config.plugins.controls %}
+ controls: {
+ {% for keyc, valuec in player_config.plugins.controls.items %}
+ {{ keyc }}: {{ valuec }}
+ {% endfor %}
+ {% if player_config.plugins.controls.tooltips %}
+ tooltips: {
+ {% for keyct, valuect in player_config.plugins.controls.tooltips.items %}
+ {{ keyct }}: {{ valuect }}
+ {% endfor %}
+ }
+ {% endif %}
+ }
+ {% endif %}
+ },
+ {% endif %}
+
+});
+</script>
View
5 flowplayer/templatetags/.directory
@@ -0,0 +1,5 @@
+[Dolphin]
+Timestamp=2009,12,22,10,25,36
+
+[Settings]
+ShowDotFiles=true
View
44 flowplayer/templatetags/flowplayer_tags.py
@@ -10,20 +10,20 @@
class FlowPlayerNode(Node):
"Renderer class for the flowplayer template tag."
- def __init__(self, media_url, player_class):
+ def __init__(self, media, player_class):
"""
Constructor.
Parameters:
- file_url
- Video url.
- player_url
- Flowplayer url.
+ media
+ Media file url OR an array of urls
+ player_class
+ Type of player to show (changes css class and config source)
"""
self.player_class = player_class
- self.media_url = Variable(media_url)
-
+ self.media = Variable(media)
+
global FLOWPLAYER_ITERATOR
FLOWPLAYER_ITERATOR += 1
self.player_id = FLOWPLAYER_ITERATOR
@@ -33,19 +33,37 @@ def __init__(self, media_url, player_class):
else:
self.player_url = "%sflowplayer/FlowPlayerLight.swf" % (settings.MEDIA_URL)
- def render(self, context):
+ # Import the configuration settings to set on the player output
+ # Configuration is defined in the settings (multiple types of player)
+ if 'default' in settings.FLOWPLAYER_CONFIG:
+ self.player_config = settings.FLOWPLAYER_CONFIG['default']
+ else:
+ self.player_config = dict()
+ if player_class in settings.FLOWPLAYER_CONFIG:
+ self.player_config.update(settings.FLOWPLAYER_CONFIG[player_class])
+
+ def render(self, context):
try:
- media_url = self.media_url.resolve(context)
+ # Try resolve this variable in the template context
+ self.media = self.media.resolve(context)
except VariableDoesNotExist:
- media_url = self.media_url
+ # Cannot resolve, therefore it's an url
+ self.media_url = self.media
+ self.media_playlist = False
+ else:
+ # Can resolve, push first url into the url variable
+ self.media_url = self.media[0]
+ self.media_playlist = self.media
t = loader.get_template('flowplayer/flowplayer.html')
code_context = Context(
{"player_url": self.player_url,
"player_id": self.player_id,
"player_class": self.player_class,
- "media_url": media_url,
+ "player_config": self.player_config,
+ "media_url": self.media_url,
+ "media_playlist":self.media_playlist
}, autoescape=context.autoescape)
return t.render(code_context)
@@ -81,9 +99,9 @@ def do_flowplayer(parser, token):
else:
player_class = None
- media_url = args[1]
+ media = args[1]
- return FlowPlayerNode(media_url, player_class)
+ return FlowPlayerNode(media, player_class)
# register the tag
Please sign in to comment.
Something went wrong with that request. Please try again.