From f357e90dc0af5cf4d041f491602f708c9e1e094f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s=20Rocha?= Date: Tue, 2 Oct 2012 14:23:31 -0400 Subject: [PATCH] Add support for video download link Add a download link to the video player. The link is defined in the content xml using the following structure: --- common/lib/xmodule/xmodule/video_module.py | 13 ++++++++++++- lms/templates/video.html | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py index 792e570fb4..11c90f45ef 100644 --- a/common/lib/xmodule/xmodule/video_module.py +++ b/common/lib/xmodule/xmodule/video_module.py @@ -31,12 +31,23 @@ class VideoModule(XModule): self.youtube = xmltree.get('youtube') self.position = 0 self.show_captions = xmltree.get('show_captions', 'true') + self.source = self._get_source(xmltree) if instance_state is not None: state = json.loads(instance_state) if 'position' in state: self.position = int(float(state['position'])) + def _get_source(self, xmltree): + # find the first valid source + source = None + for element in xmltree.findall('source'): + src = element.get('src') + if src: + source = src + break + return source + def handle_ajax(self, dispatch, get): ''' Handle ajax calls to this video. @@ -73,6 +84,7 @@ class VideoModule(XModule): 'streams': self.video_list(), 'id': self.location.html_id(), 'position': self.position, + 'source': self.source, 'display_name': self.display_name, # TODO (cpennington): This won't work when we move to data that isn't on the filesystem 'data_dir': self.metadata['data_dir'], @@ -82,6 +94,5 @@ class VideoModule(XModule): class VideoDescriptor(RawDescriptor): module_class = VideoModule - stores_state = True template_dir_name = "video" diff --git a/lms/templates/video.html b/lms/templates/video.html index bd3ec77fbe..47556095cb 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -13,3 +13,8 @@ +% if source: +
+

Download video here.

+
+% endif