Commit 5b79352a by Victor Shnayder

Merge pull request #806 from MITx/feature/rocha/support-additional-video-sources

Add support for video download link
parents 607fdb02 f357e90d
......@@ -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"
......@@ -13,3 +13,8 @@
</article>
</div>
</div>
% if source:
<div class="video-sources">
<p>Download video <a href="${source}">here</a>.</p>
</div>
% endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment