Commit 71f16d40 by Chris Dodge

wire through course asset path information to the video playback module and…

wire through course asset path information to the video playback module and corresponding .coffee files
parent ee618d42
...@@ -47,6 +47,11 @@ class StaticContent(object): ...@@ -47,6 +47,11 @@ class StaticContent(object):
return None return None
@staticmethod @staticmethod
def get_base_url_path_for_course_assets(loc):
if loc is not None:
return "/c4x/{org}/{course}/asset".format(**loc.dict())
@staticmethod
def get_id_from_location(location): def get_id_from_location(location):
return { 'tag':location.tag, 'org' : location.org, 'course' : location.course, return { 'tag':location.tag, 'org' : location.org, 'course' : location.course,
'category' : location.category, 'name' : location.name, 'category' : location.category, 'name' : location.name,
......
...@@ -3,6 +3,7 @@ class @Video ...@@ -3,6 +3,7 @@ class @Video
@el = $(element).find('.video') @el = $(element).find('.video')
@id = @el.attr('id').replace(/video_/, '') @id = @el.attr('id').replace(/video_/, '')
@caption_data_dir = @el.data('caption-data-dir') @caption_data_dir = @el.data('caption-data-dir')
@caption_asset_path = @el.data('caption-asset-path')
@show_captions = @el.data('show-captions') == "true" @show_captions = @el.data('show-captions') == "true"
window.player = null window.player = null
@el = $("#video_#{@id}") @el = $("#video_#{@id}")
......
...@@ -10,7 +10,10 @@ class @VideoCaption extends Subview ...@@ -10,7 +10,10 @@ class @VideoCaption extends Subview
.bind('DOMMouseScroll', @onMovement) .bind('DOMMouseScroll', @onMovement)
captionURL: -> captionURL: ->
"/static/#{@captionDataDir}/subs/#{@youtubeId}.srt.sjson" if @captionAssetPath != ''
"#{@captionAssetPath}/#{@youtubeId}.srt.sjson"
else
"/static/#{@captionDataDir}/subs/#{@youtubeId}.srt.sjson"
render: -> render: ->
# TODO: make it so you can have a video with no captions. # TODO: make it so you can have a video with no captions.
......
...@@ -32,6 +32,7 @@ class @VideoPlayer extends Subview ...@@ -32,6 +32,7 @@ class @VideoPlayer extends Subview
youtubeId: @video.youtubeId('1.0') youtubeId: @video.youtubeId('1.0')
currentSpeed: @currentSpeed() currentSpeed: @currentSpeed()
captionDataDir: @video.caption_data_dir captionDataDir: @video.caption_data_dir
captionAssetPath: @video.caption_asset_path
unless onTouchBasedDevice() unless onTouchBasedDevice()
@volumeControl = new VideoVolumeControl el: @$('.secondary-controls') @volumeControl = new VideoVolumeControl el: @$('.secondary-controls')
@speedControl = new VideoSpeedControl el: @$('.secondary-controls'), speeds: @video.speeds, currentSpeed: @currentSpeed() @speedControl = new VideoSpeedControl el: @$('.secondary-controls'), speeds: @video.speeds, currentSpeed: @currentSpeed()
......
...@@ -11,12 +11,12 @@ from xmodule.contentstore.content import StaticContent, XASSET_SRCREF_PREFIX ...@@ -11,12 +11,12 @@ from xmodule.contentstore.content import StaticContent, XASSET_SRCREF_PREFIX
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def import_static_content(modules, course_loc, course_data_path, static_content_store, target_location_namespace): def import_static_content(modules, course_loc, course_data_path, static_content_store, target_location_namespace, subpath = 'static'):
remap_dict = {} remap_dict = {}
# now import all static assets # now import all static assets
static_dir = course_data_path / 'static/' static_dir = course_data_path / subpath
for dirname, dirnames, filenames in os.walk(static_dir): for dirname, dirnames, filenames in os.walk(static_dir):
for filename in filenames: for filename in filenames:
...@@ -24,6 +24,8 @@ def import_static_content(modules, course_loc, course_data_path, static_content_ ...@@ -24,6 +24,8 @@ def import_static_content(modules, course_loc, course_data_path, static_content_
try: try:
content_path = os.path.join(dirname, filename) content_path = os.path.join(dirname, filename)
fullname_with_subpath = content_path.replace(static_dir, '') # strip away leading path from the name fullname_with_subpath = content_path.replace(static_dir, '') # strip away leading path from the name
if fullname_with_subpath.startswith('/'):
fullname_with_subpath = fullname_with_subpath[1:]
content_loc = StaticContent.compute_location(target_location_namespace.org, target_location_namespace.course, fullname_with_subpath) content_loc = StaticContent.compute_location(target_location_namespace.org, target_location_namespace.course, fullname_with_subpath)
mime_type = mimetypes.guess_type(filename)[0] mime_type = mimetypes.guess_type(filename)[0]
...@@ -125,8 +127,11 @@ def import_from_xml(store, data_dir, course_dirs=None, ...@@ -125,8 +127,11 @@ def import_from_xml(store, data_dir, course_dirs=None,
course_location = module.location course_location = module.location
if static_content_store is not None: if static_content_store is not None:
_namespace_rename = target_location_namespace if target_location_namespace is not None else module_store.modules[course_id].location
# first pass to find everything in /static/
import_static_content(module_store.modules[course_id], course_location, course_data_path, static_content_store, import_static_content(module_store.modules[course_id], course_location, course_data_path, static_content_store,
target_location_namespace if target_location_namespace is not None else course_location) _namespace_rename, subpath='static')
for module in module_store.modules[course_id].itervalues(): for module in module_store.modules[course_id].itervalues():
......
...@@ -6,6 +6,9 @@ from pkg_resources import resource_string, resource_listdir ...@@ -6,6 +6,9 @@ from pkg_resources import resource_string, resource_listdir
from xmodule.x_module import XModule from xmodule.x_module import XModule
from xmodule.raw_module import RawDescriptor from xmodule.raw_module import RawDescriptor
from xmodule.modulestore.mongo import MongoModuleStore
from xmodule.modulestore.django import modulestore
from xmodule.contentstore.content import StaticContent
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -93,6 +96,10 @@ class VideoModule(XModule): ...@@ -93,6 +96,10 @@ class VideoModule(XModule):
return self.youtube return self.youtube
def get_html(self): def get_html(self):
caption_asset_path = ''
if isinstance(modulestore(), MongoModuleStore) :
caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location)
return self.system.render_template('video.html', { return self.system.render_template('video.html', {
'streams': self.video_list(), 'streams': self.video_list(),
'id': self.location.html_id(), 'id': self.location.html_id(),
...@@ -102,6 +109,7 @@ class VideoModule(XModule): ...@@ -102,6 +109,7 @@ class VideoModule(XModule):
'display_name': self.display_name, 'display_name': self.display_name,
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem # TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'data_dir': self.metadata['data_dir'], 'data_dir': self.metadata['data_dir'],
'caption_asset_path': caption_asset_path,
'show_captions': self.show_captions 'show_captions': self.show_captions
}) })
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<h2> ${display_name} </h2> <h2> ${display_name} </h2>
% endif % endif
<div id="video_${id}" class="video" data-streams="${streams}" data-caption-data-dir="${data_dir}" data-show-captions="${show_captions}"> <div id="video_${id}" class="video" data-streams="${streams}" data-caption-data-dir="${data_dir}" data-caption-asset-path="${caption_asset_path}" data-show-captions="${show_captions}">
<div class="tc-wrapper"> <div class="tc-wrapper">
<article class="video-wrapper"> <article class="video-wrapper">
<section class="video-player"> <section class="video-player">
......
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