Commit a470a62d by David Ormsbee

Hack to disable YouTube <iframe> API when they break it.

parent e5fda33e
...@@ -128,6 +128,17 @@ class VideoModule(XModule): ...@@ -128,6 +128,17 @@ class VideoModule(XModule):
else: else:
caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location) + '/subs_' caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location) + '/subs_'
# We normally let JS parse this, but in the case that we need a hacked
# out <object> player because YouTube has broken their <iframe> API for
# the third time in a year, we need to extract it server side.
normal_speed_video_id = None # The 1.0 speed video
# video_list() example:
# "0.75:nugHYNiD3fI,1.0:7m8pab1MfYY,1.25:3CxdPGXShq8,1.50:F-D7bOFCnXA"
for video_id_str in self.video_list().split(","):
if video_id_str.startswith("1.0:"):
normal_speed_video_id = video_id_str.split(":")[1]
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(),
...@@ -140,7 +151,8 @@ class VideoModule(XModule): ...@@ -140,7 +151,8 @@ class VideoModule(XModule):
'caption_asset_path': caption_asset_path, 'caption_asset_path': caption_asset_path,
'show_captions': self.show_captions, 'show_captions': self.show_captions,
'start': self.start_time, 'start': self.start_time,
'end': self.end_time 'end': self.end_time,
'normal_speed_video_id': normal_speed_video_id
}) })
......
...@@ -81,6 +81,9 @@ MITX_FEATURES = { ...@@ -81,6 +81,9 @@ MITX_FEATURES = {
'AUTH_USE_OPENID': False, 'AUTH_USE_OPENID': False,
'AUTH_USE_MIT_CERTIFICATES': False, 'AUTH_USE_MIT_CERTIFICATES': False,
'AUTH_USE_OPENID_PROVIDER': False, 'AUTH_USE_OPENID_PROVIDER': False,
# When the YouTube iframe API breaks
'USE_YOUTUBE_OBJECT_API': True,
} }
# Used for A/B testing # Used for A/B testing
......
...@@ -2,9 +2,19 @@ ...@@ -2,9 +2,19 @@
<h2> ${display_name} </h2> <h2> ${display_name} </h2>
% endif % endif
%if settings.MITX_FEATURES['STUB_VIDEO_FOR_TESTING']: %if settings.MITX_FEATURES['STUB_VIDEO_FOR_TESTING']:
<div id="stub_out_video_for_testing"></div> <div id="stub_out_video_for_testing"></div>
%elif settings.MITX_FEATURES.get('USE_YOUTUBE_OBJECT_API') and normal_speed_video_id:
<object width="640" height="390">
<param name="movie"
value="https://www.youtube.com/v/${normal_speed_video_id}?version=3&amp;autoplay=1&amp;rel=0"></param>
<param name="allowScriptAccess" value="always"></param>
<embed src="https://www.youtube.com/v/${normal_speed_video_id}?version=3&amp;autoplay=1&amp;rel=0"
type="application/x-shockwave-flash"
allowscriptaccess="always"
width="640" height="390"></embed>
</object>
%else: %else:
<div id="video_${id}" class="video" data-streams="${streams}" data-caption-data-dir="${data_dir}" data-show-captions="${show_captions}" data-start="${start}" data-end="${end}" data-caption-asset-path="${caption_asset_path}"> <div id="video_${id}" class="video" data-streams="${streams}" data-caption-data-dir="${data_dir}" data-show-captions="${show_captions}" data-start="${start}" data-end="${end}" data-caption-asset-path="${caption_asset_path}">
<div class="tc-wrapper"> <div class="tc-wrapper">
......
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