Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
af56a2df
Commit
af56a2df
authored
Jan 10, 2014
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BLD-518: Fix video volume cookie.
parent
76f4eaf9
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
41 deletions
+81
-41
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
+33
-8
common/lib/xmodule/xmodule/js/src/video/01_initialize.js
+1
-0
common/lib/xmodule/xmodule/js/src/video/02_html5_video.js
+3
-0
common/lib/xmodule/xmodule/js/src/video/03_video_player.js
+1
-0
common/lib/xmodule/xmodule/js/src/video/07_video_volume_control.js
+39
-30
lms/djangoapps/courseware/features/video.py
+4
-3
No files found.
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
View file @
af56a2df
...
...
@@ -335,21 +335,23 @@
beforeEach
(
function
()
{
initialize
();
spyOn
(
videoPlayer
,
'updatePlayTime'
);
spyOn
(
videoPlayer
,
'log'
);
spyOn
(
videoPlayer
.
player
,
'seekTo'
);
runs
(
function
()
{
state
.
videoPlayer
.
play
();
});
waitsFor
(
function
()
{
return
videoPlayer
.
isPlaying
();
duration
=
videoPlayer
.
duration
();
return
duration
>
0
&&
videoPlayer
.
isPlaying
();
},
'video begins playing'
,
WAIT_TIMEOUT
);
});
it
(
'Slider event causes log update'
,
function
()
{
runs
(
function
()
{
var
currentTime
=
videoPlayer
.
currentTime
;
spyOn
(
videoPlayer
,
'log'
);
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
2
}
);
...
...
@@ -367,6 +369,7 @@
it
(
'seek the player'
,
function
()
{
runs
(
function
()
{
spyOn
(
videoPlayer
.
player
,
'seekTo'
);
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
60
}
);
...
...
@@ -378,6 +381,7 @@
it
(
'call updatePlayTime on player'
,
function
()
{
runs
(
function
()
{
spyOn
(
videoPlayer
,
'updatePlayTime'
);
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
60
}
);
...
...
@@ -476,19 +480,38 @@
videoPlayer
.
onPlay
();
expect
(
videoPlayer
.
onSpeedChange
.
calls
.
length
).
toEqual
(
1
);
});
it
(
'video has a correct volume'
,
function
()
{
spyOn
(
videoPlayer
.
player
,
'setVolume'
);
state
.
currentVolume
=
'0.26'
;
videoPlayer
.
onPlay
();
expect
(
videoPlayer
.
player
.
setVolume
).
toHaveBeenCalledWith
(
'0.26'
);
});
});
});
describe
(
'onVolumeChange'
,
function
()
{
beforeEach
(
function
()
{
initialize
();
});
it
(
'set the volume on player'
,
function
()
{
spyOn
(
videoPlayer
.
player
,
'setVolume'
);
videoPlayer
.
onVolumeChange
(
60
);
expect
(
videoPlayer
.
player
.
setVolume
).
toHaveBeenCalledWith
(
60
);
});
it
(
'set the volume on player'
,
function
()
{
expect
(
videoPlayer
.
player
.
setVolume
).
toHaveBeenCalledWith
(
60
);
describe
(
'when the video is not playing'
,
function
()
{
beforeEach
(
function
()
{
videoPlayer
.
player
.
setVolume
(
'1'
);
});
it
(
'video has a correct volume'
,
function
()
{
spyOn
(
videoPlayer
.
player
,
'setVolume'
);
state
.
currentVolume
=
'0.26'
;
videoPlayer
.
onPlay
();
expect
(
videoPlayer
.
player
.
setVolume
).
toHaveBeenCalledWith
(
'0.26'
);
});
});
});
...
...
@@ -922,7 +945,9 @@
});
waitsFor
(
function
()
{
return
videoPlayer
.
isPlaying
();
duration
=
videoPlayer
.
duration
();
return
duration
>
0
&&
videoPlayer
.
isPlaying
();
},
'Video does not play.'
,
WAIT_TIMEOUT
);
runs
(
function
()
{
...
...
common/lib/xmodule/xmodule/js/src/video/01_initialize.js
View file @
af56a2df
...
...
@@ -323,6 +323,7 @@ function (VideoPlayer) {
// element has a CSS class 'fullscreen'.
this
.
__dfd__
=
$
.
Deferred
();
this
.
isFullScreen
=
false
;
this
.
currentVolume
=
100
;
this
.
isTouch
=
onTouchBasedDevice
()
||
''
;
// The parent element of the video, and the ID.
...
...
common/lib/xmodule/xmodule/js/src/video/02_html5_video.js
View file @
af56a2df
...
...
@@ -193,6 +193,9 @@ function () {
sourceStr
[
videoType
]
=
'<source '
+
'src="'
+
_this
.
config
.
videoSources
[
videoType
]
+
// Following hack allows to open the same video twice
// https://code.google.com/p/chromium/issues/detail?id=31014
'?'
+
(
new
Date
()).
getTime
()
+
'" '
+
'type="video/'
+
videoType
+
'" '
+
'/> '
;
}
...
...
common/lib/xmodule/xmodule/js/src/video/03_video_player.js
View file @
af56a2df
...
...
@@ -70,6 +70,7 @@ function (HTML5Video, Resizer) {
if
(
state
.
currentPlayerMode
!==
'flash'
)
{
state
.
videoPlayer
.
onSpeedChange
(
state
.
speed
);
}
state
.
videoPlayer
.
player
.
setVolume
(
state
.
currentVolume
);
});
if
(
state
.
videoType
===
'youtube'
)
{
...
...
common/lib/xmodule/xmodule/js/src/video/07_video_volume_control.js
View file @
af56a2df
...
...
@@ -50,59 +50,68 @@ function () {
// make the created DOM elements available via the 'state' object. Much easier to work this
// way - you don't have to do repeated jQuery element selects.
function
_renderElements
(
state
)
{
state
.
videoVolumeControl
.
el
=
state
.
el
.
find
(
'div.volume'
);
state
.
videoVolumeControl
.
buttonEl
=
state
.
videoVolumeControl
.
el
.
find
(
'a'
);
state
.
videoVolumeControl
.
volumeSliderEl
=
state
.
videoVolumeControl
.
el
.
find
(
'.volume-slider'
);
var
volumeControl
=
state
.
videoVolumeControl
,
element
=
state
.
el
.
find
(
'div.volume'
),
button
=
element
.
find
(
'a'
),
volumeSlider
=
element
.
find
(
'.volume-slider'
),
// Figure out what the current volume is. If no information about
// volume level could be retrieved, then we will use the default 100
// level (full volume).
currentVolume
=
parseInt
(
$
.
cookie
(
'video_player_volume_level'
),
10
),
// Set it up so that muting/unmuting works correctly.
previousVolume
=
100
,
slider
,
buttonStr
,
volumeSliderHandleEl
;
state
.
videoControl
.
secondaryControlsEl
.
prepend
(
state
.
videoVolumeControl
.
el
);
state
.
videoControl
.
secondaryControlsEl
.
prepend
(
element
);
// Figure out what the current volume is. If no information about volume level could be retrieved,
// then we will use the default 100 level (full volume).
state
.
videoVolumeControl
.
currentVolume
=
parseInt
(
$
.
cookie
(
'video_player_volume_level'
),
10
);
if
(
!
isFinite
(
state
.
videoVolumeControl
.
currentVolume
))
{
state
.
videoVolumeControl
.
currentVolume
=
100
;
if
(
!
isFinite
(
currentVolume
))
{
currentVolume
=
100
;
}
// Set it up so that muting/unmuting works correctly.
state
.
videoVolumeControl
.
previousVolume
=
100
;
state
.
videoVolumeControl
.
slider
=
state
.
videoVolumeControl
.
volumeSliderEl
.
slider
({
slider
=
volumeSlider
.
slider
({
orientation
:
'vertical'
,
range
:
'min'
,
min
:
0
,
max
:
100
,
value
:
state
.
videoVolumeControl
.
currentVolume
,
change
:
state
.
videoV
olumeControl
.
onChange
,
slide
:
state
.
videoV
olumeControl
.
onChange
value
:
currentVolume
,
change
:
v
olumeControl
.
onChange
,
slide
:
v
olumeControl
.
onChange
});
state
.
videoVolumeControl
.
el
.
toggleClass
(
'muted'
,
state
.
videoVolumeControl
.
currentVolume
===
0
);
element
.
toggleClass
(
'muted'
,
currentVolume
===
0
);
// ARIA
// Let screen readers know that:
// This anchor behaves as a button named 'Volume'.
var
currentVolume
=
state
.
videoVolumeControl
.
currentVolume
,
buttonStr
=
(
currentVolume
===
0
)
?
'Volume muted'
:
'Volume'
;
// We add the aria-label attribute because the title attribute cannot be
// read.
state
.
videoVolumeControl
.
buttonEl
.
attr
(
'aria-label'
,
gettext
(
buttonStr
));
button
.
attr
(
'aria-label'
,
gettext
(
buttonStr
));
// Let screen readers know that this anchor, representing the slider
// handle, behaves as a slider named 'volume'.
var
volumeSlider
=
state
.
videoVolumeControl
.
slider
;
state
.
videoVolumeControl
.
volumeSliderHandleEl
=
state
.
videoVolumeControl
.
volumeSliderEl
.
find
(
'.ui-slider-handle'
);
state
.
videoVolumeControl
.
volumeSliderHandleEl
.
attr
({
volumeSliderHandleEl
=
slider
.
find
(
'.ui-slider-handle'
);
volumeSliderHandleEl
.
attr
({
'role'
:
'slider'
,
'title'
:
'volume'
,
'aria-disabled'
:
false
,
'aria-valuemin'
:
volumeSlider
.
slider
(
'option'
,
'min'
),
'aria-valuemax'
:
volumeSlider
.
slider
(
'option'
,
'max'
),
'aria-valuenow'
:
volumeSlider
.
slider
(
'option'
,
'value'
),
'aria-valuetext'
:
getVolumeDescription
(
volumeSlider
.
slider
(
'option'
,
'value'
))
'aria-valuemin'
:
slider
.
slider
(
'option'
,
'min'
),
'aria-valuemax'
:
slider
.
slider
(
'option'
,
'max'
),
'aria-valuenow'
:
slider
.
slider
(
'option'
,
'value'
),
'aria-valuetext'
:
getVolumeDescription
(
slider
.
slider
(
'option'
,
'value'
))
});
state
.
currentVolume
=
currentVolume
;
$
.
extend
(
state
.
videoVolumeControl
,
{
el
:
element
,
buttonEl
:
button
,
volumeSliderEl
:
volumeSlider
,
currentVolume
:
currentVolume
,
previousVolume
:
previousVolume
,
slider
:
slider
,
volumeSliderHandleEl
:
volumeSliderHandleEl
});
}
...
...
lms/djangoapps/courseware/features/video.py
View file @
af56a2df
#pylint: disable=C0111
from
lettuce
import
world
,
step
from
lettuce.django
import
django_url
from
common
import
i_am_registered_for_the_course
,
section_location
,
visit_scenario_item
from
django.utils.translation
import
ugettext
as
_
...
...
@@ -94,8 +93,10 @@ def video_is_rendered(_step, mode):
@step
(
'all sources are correct$'
)
def
all_sources_are_correct
(
_step
):
sources
=
world
.
css_find
(
'.video video source'
)
assert
set
(
source
[
'src'
]
for
source
in
sources
)
==
set
(
HTML5_SOURCES
)
elements
=
world
.
css_find
(
'.video video source'
)
sources
=
[
source
[
'src'
]
.
split
(
'?'
)[
0
]
for
source
in
elements
]
assert
set
(
sources
)
==
set
(
HTML5_SOURCES
)
@step
(
'error message is shown$'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment