- '''
+ secondaryControls = $('.secondary-controls')
+ li = secondaryControls.find('.video_speeds li')
+ expect(secondaryControls).toContain '.speeds'
+ expect(secondaryControls).toContain '.video_speeds'
+ expect(secondaryControls.find('p.active').text()).toBe '1.0x'
+ expect(li.filter('.active')).toHaveData 'speed', @speedControl.currentSpeed
+ expect(li.length).toBe @speedControl.speeds.length
+ $.each li.toArray().reverse(), (index, link) =>
+ expect($(link)).toHaveData 'speed', @speedControl.speeds[index]
+ expect($(link).find('a').text()).toBe @speedControl.speeds[index] + 'x'
it 'bind to change video speed link', ->
expect($('.video_speeds a')).toHandleWith 'click', @speedControl.changeVideoSpeed
describe 'when running on touch based device', ->
beforeEach ->
- spyOn(window, 'onTouchBasedDevice').andReturn true
+ window.onTouchBasedDevice.andReturn true
$('.speeds').removeClass 'open'
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
@@ -37,7 +38,6 @@ xdescribe 'VideoSpeedControl', ->
describe 'when running on non-touch based device', ->
beforeEach ->
- spyOn(window, 'onTouchBasedDevice').andReturn false
$('.speeds').removeClass 'open'
@speedControl = new VideoSpeedControl el: $('.secondary-controls'), speeds: @video.speeds, currentSpeed: '1.0'
diff --git a/common/lib/xmodule/xmodule/js/spec/video/display/video_volume_control_spec.coffee b/common/lib/xmodule/xmodule/js/spec/video/display/video_volume_control_spec.coffee
index 41ac5dd3e401..a2b14afa5553 100644
--- a/common/lib/xmodule/xmodule/js/spec/video/display/video_volume_control_spec.coffee
+++ b/common/lib/xmodule/xmodule/js/spec/video/display/video_volume_control_spec.coffee
@@ -1,5 +1,4 @@
-# TODO: figure out why failing
-xdescribe 'VideoVolumeControl', ->
+describe 'VideoVolumeControl', ->
beforeEach ->
jasmine.stubVideoPlayer @
$('.volume').remove()
diff --git a/common/lib/xmodule/xmodule/js/spec/video/display_spec.coffee b/common/lib/xmodule/xmodule/js/spec/video/display_spec.coffee
index ac90310519bb..a83fa3905cb2 100644
--- a/common/lib/xmodule/xmodule/js/spec/video/display_spec.coffee
+++ b/common/lib/xmodule/xmodule/js/spec/video/display_spec.coffee
@@ -1,12 +1,20 @@
-# TODO: figure out why failing
-xdescribe 'Video', ->
+describe 'Video', ->
+ metadata = undefined
+
beforeEach ->
loadFixtures 'video.html'
jasmine.stubRequests()
- @videosDefinition = '.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
+ @videosDefinition = '0.75:slowerSpeedYoutubeId,1.0:normalSpeedYoutubeId'
@slowerSpeedYoutubeId = 'slowerSpeedYoutubeId'
@normalSpeedYoutubeId = 'normalSpeedYoutubeId'
+ metadata =
+ slowerSpeedYoutubeId:
+ id: @slowerSpeedYoutubeId
+ duration: 300
+ normalSpeedYoutubeId:
+ id: @normalSpeedYoutubeId
+ duration: 200
afterEach ->
window.player = undefined
@@ -16,17 +24,18 @@ xdescribe 'Video', ->
beforeEach ->
@stubVideoPlayer = jasmine.createSpy('VideoPlayer')
$.cookie.andReturn '0.75'
- window.player = 100
+ window.player = undefined
describe 'by default', ->
beforeEach ->
- @video = new Video 'example', @videosDefinition
-
+ spyOn(window.Video.prototype, 'fetchMetadata').andCallFake ->
+ @metadata = metadata
+ @video = new Video '#example', @videosDefinition
it 'reset the current video player', ->
expect(window.player).toBeNull()
it 'set the elements', ->
- expect(@video.el).toBe '#video_example'
+ expect(@video.el).toBe '#video_id'
it 'parse the videos', ->
expect(@video.videos).toEqual
@@ -34,13 +43,8 @@ xdescribe 'Video', ->
'1.0': @normalSpeedYoutubeId
it 'fetch the video metadata', ->
- expect(@video.metadata).toEqual
- slowerSpeedYoutubeId:
- id: @slowerSpeedYoutubeId
- duration: 300
- normalSpeedYoutubeId:
- id: @normalSpeedYoutubeId
- duration: 200
+ expect(@video.fetchMetadata).toHaveBeenCalled
+ expect(@video.metadata).toEqual metadata
it 'parse available video speeds', ->
expect(@video.speeds).toEqual ['0.75', '1.0']
@@ -56,7 +60,7 @@ xdescribe 'Video', ->
@originalYT = window.YT
window.YT = { Player: true }
spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer)
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
afterEach ->
window.YT = @originalYT
@@ -69,7 +73,7 @@ xdescribe 'Video', ->
beforeEach ->
@originalYT = window.YT
window.YT = {}
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
afterEach ->
window.YT = @originalYT
@@ -82,7 +86,7 @@ xdescribe 'Video', ->
@originalYT = window.YT
window.YT = {}
spyOn(window, 'VideoPlayer').andReturn(@stubVideoPlayer)
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
window.onYouTubePlayerAPIReady()
afterEach ->
@@ -95,7 +99,7 @@ xdescribe 'Video', ->
describe 'youtubeId', ->
beforeEach ->
$.cookie.andReturn '1.0'
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
describe 'with speed', ->
it 'return the video id for given speed', ->
@@ -108,7 +112,7 @@ xdescribe 'Video', ->
describe 'setSpeed', ->
beforeEach ->
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
describe 'when new speed is available', ->
beforeEach ->
@@ -129,14 +133,14 @@ xdescribe 'Video', ->
describe 'getDuration', ->
beforeEach ->
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
it 'return duration for current video', ->
expect(@video.getDuration()).toEqual 200
describe 'log', ->
beforeEach ->
- @video = new Video 'example', @videosDefinition
+ @video = new Video '#example', @videosDefinition
@video.setSpeed '1.0'
spyOn Logger, 'log'
@video.player = { currentTime: 25 }
@@ -144,7 +148,7 @@ xdescribe 'Video', ->
it 'call the logger with valid parameters', ->
expect(Logger.log).toHaveBeenCalledWith 'someEvent',
- id: 'example'
+ id: 'id'
code: @normalSpeedYoutubeId
currentTime: 25
speed: '1.0'
diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
index bf3ec1e1029c..c72067b0dc45 100644
--- a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
+++ b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee
@@ -37,7 +37,7 @@ class @VideoCaption extends Subview
@loaded = true
if onTouchBasedDevice()
- $('.subtitles li').html "Caption will be displayed when you start playing the video."
+ $('.subtitles').html "
Caption will be displayed when you start playing the video.
"
else
@renderCaption()
diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee
index 561ca07c8a3f..73ff3512e2aa 100644
--- a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee
+++ b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee
@@ -15,7 +15,7 @@ class @VideoPlayer extends Subview
$(@progressSlider).bind('seek', @onSeek)
if @volumeControl
$(@volumeControl).bind('volumeChange', @onVolumeChange)
- $(document).keyup @bindExitFullScreen
+ $(document.documentElement).keyup @bindExitFullScreen
@$('.add-fullscreen').click @toggleFullScreen
@addToolTip() unless onTouchBasedDevice()
diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_progress_slider.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_progress_slider.coffee
index 874756cb7196..ef2f38698b60 100644
--- a/common/lib/xmodule/xmodule/js/src/video/display/video_progress_slider.coffee
+++ b/common/lib/xmodule/xmodule/js/src/video/display/video_progress_slider.coffee
@@ -11,7 +11,7 @@ class @VideoProgressSlider extends Subview
@buildHandle()
buildHandle: ->
- @handle = @$('.slider .ui-slider-handle')
+ @handle = @$('.ui-slider-handle')
@handle.qtip
content: "#{Time.format(@slider.slider('value'))}"
position:
diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py
index f902a9665bef..994611c67619 100644
--- a/common/lib/xmodule/xmodule/video_module.py
+++ b/common/lib/xmodule/xmodule/video_module.py
@@ -1,3 +1,6 @@
+# pylint: disable=W0223
+"""Video is ungraded Xmodule for support video content."""
+
import json
import logging
@@ -8,7 +11,6 @@
from xmodule.x_module import XModule
from xmodule.raw_module import RawDescriptor
-from xmodule.contentstore.content import StaticContent
from xblock.core import Integer, Scope, String
import datetime
@@ -18,21 +20,26 @@
class VideoFields(object):
+ """Fields for `VideoModule` and `VideoDescriptor`."""
data = String(help="XML data for the problem", scope=Scope.content)
position = Integer(help="Current position in the video", scope=Scope.user_state, default=0)
class VideoModule(VideoFields, XModule):
+ """Video Xmodule."""
video_time = 0
icon_class = 'video'
- js = {'coffee':
- [resource_string(__name__, 'js/src/time.coffee'),
- resource_string(__name__, 'js/src/video/display.coffee')] +
+ js = {
+ 'coffee': [
+ resource_string(__name__, 'js/src/time.coffee'),
+ resource_string(__name__, 'js/src/video/display.coffee')
+ ] +
[resource_string(__name__, 'js/src/video/display/' + filename)
for filename
in sorted(resource_listdir(__name__, 'js/src/video/display'))
- if filename.endswith('.coffee')]}
+ if filename.endswith('.coffee')]
+ }
css = {'scss': [resource_string(__name__, 'css/video/display.scss')]}
js_module_name = "Video"
@@ -44,14 +51,14 @@ def __init__(self, *args, **kwargs):
self.show_captions = xmltree.get('show_captions', 'true')
self.source = self._get_source(xmltree)
self.track = self._get_track(xmltree)
- self.start_time, self.end_time = self._get_timeframe(xmltree)
+ self.start_time, self.end_time = self.get_timeframe(xmltree)
def _get_source(self, xmltree):
- # find the first valid source
+ """Find the first valid source."""
return self._get_first_external(xmltree, 'source')
def _get_track(self, xmltree):
- # find the first valid track
+ """Find the first valid track."""
return self._get_first_external(xmltree, 'track')
def _get_first_external(self, xmltree, tag):
@@ -68,59 +75,44 @@ def _get_first_external(self, xmltree, tag):
break
return result
- def _get_timeframe(self, xmltree):
+ def get_timeframe(self, xmltree):
""" Converts 'from' and 'to' parameters in video tag to seconds.
If there are no parameters, returns empty string. """
- def parse_time(s):
+ def parse_time(str_time):
"""Converts s in '12:34:45' format to seconds. If s is
None, returns empty string"""
- if s is None:
+ if str_time is None:
return ''
else:
- x = time.strptime(s, '%H:%M:%S')
- return datetime.timedelta(hours=x.tm_hour,
- minutes=x.tm_min,
- seconds=x.tm_sec).total_seconds()
+ obj_time = time.strptime(str_time, '%H:%M:%S')
+ return datetime.timedelta(
+ hours=obj_time.tm_hour,
+ minutes=obj_time.tm_min,
+ seconds=obj_time.tm_sec
+ ).total_seconds()
return parse_time(xmltree.get('from')), parse_time(xmltree.get('to'))
def handle_ajax(self, dispatch, get):
- '''
- Handle ajax calls to this video.
- TODO (vshnayder): This is not being called right now, so the position
- is not being saved.
- '''
+ """This is not being called right now and we raise 404 error."""
log.debug(u"GET {0}".format(get))
log.debug(u"DISPATCH {0}".format(dispatch))
- if dispatch == 'goto_position':
- self.position = int(float(get['position']))
- log.info(u"NEW POSITION {0}".format(self.position))
- return json.dumps({'success': True})
raise Http404()
- def get_progress(self):
- ''' TODO (vshnayder): Get and save duration of youtube video, then return
- fraction watched.
- (Be careful to notice when video link changes and update)
-
- For now, we have no way of knowing if the video has even been watched, so
- just return None.
- '''
- return None
-
def get_instance_state(self):
- #log.debug(u"STATE POSITION {0}".format(self.position))
+ """Return information about state (position)."""
return json.dumps({'position': self.position})
def video_list(self):
+ """Return video list."""
return self.youtube
def get_html(self):
# We normally let JS parse this, but in the case that we need a hacked
# out