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
2f572a86
Commit
2f572a86
authored
Mar 31, 2014
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor video caption module.
parent
668134de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
59 deletions
+24
-59
common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js
+7
-19
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
+12
-18
common/lib/xmodule/xmodule/js/src/video/03_video_player.js
+5
-21
common/lib/xmodule/xmodule/js/src/video/04_video_control.js
+0
-1
common/lib/xmodule/xmodule/js/src/video/09_video_caption.js
+0
-0
No files found.
common/lib/xmodule/xmodule/js/spec/video/video_caption_spec.js
View file @
2f572a86
...
@@ -123,28 +123,16 @@
...
@@ -123,28 +123,16 @@
it
(
'bind the hide caption button'
,
function
()
{
it
(
'bind the hide caption button'
,
function
()
{
state
=
jasmine
.
initializePlayer
();
state
=
jasmine
.
initializePlayer
();
expect
(
$
(
'.hide-subtitles'
)).
toHandleWith
(
expect
(
$
(
'.hide-subtitles'
)).
toHandle
(
'click'
);
'click'
,
state
.
videoCaption
.
toggle
);
});
});
it
(
'bind the mouse movement'
,
function
()
{
it
(
'bind the mouse movement'
,
function
()
{
state
=
jasmine
.
initializePlayer
();
state
=
jasmine
.
initializePlayer
();
expect
(
$
(
'.subtitles'
)).
toHandleWith
(
expect
(
$
(
'.subtitles'
)).
toHandle
(
'mouseover'
);
'mouseover'
,
state
.
videoCaption
.
onMouseEnter
expect
(
$
(
'.subtitles'
)).
toHandle
(
'mouseout'
);
);
expect
(
$
(
'.subtitles'
)).
toHandle
(
'mousemove'
);
expect
(
$
(
'.subtitles'
)).
toHandleWith
(
expect
(
$
(
'.subtitles'
)).
toHandle
(
'mousewheel'
);
'mouseout'
,
state
.
videoCaption
.
onMouseLeave
expect
(
$
(
'.subtitles'
)).
toHandle
(
'DOMMouseScroll'
);
);
expect
(
$
(
'.subtitles'
)).
toHandleWith
(
'mousemove'
,
state
.
videoCaption
.
onMovement
);
expect
(
$
(
'.subtitles'
)).
toHandleWith
(
'mousewheel'
,
state
.
videoCaption
.
onMovement
);
expect
(
$
(
'.subtitles'
)).
toHandleWith
(
'DOMMouseScroll'
,
state
.
videoCaption
.
onMovement
);
});
});
it
(
'bind the scroll'
,
function
()
{
it
(
'bind the scroll'
,
function
()
{
...
@@ -859,7 +847,7 @@
...
@@ -859,7 +847,7 @@
runs
(
function
()
{
runs
(
function
()
{
videoControl
=
state
.
videoControl
;
videoControl
=
state
.
videoControl
;
$
(
'.subtitles li[data-index=1]'
).
addClass
(
'current'
);
$
(
'.subtitles li[data-index=1]'
).
addClass
(
'current'
);
state
.
videoCaption
.
r
esize
();
state
.
videoCaption
.
onR
esize
();
});
});
});
});
...
...
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
View file @
2f572a86
...
@@ -26,7 +26,6 @@ function (VideoPlayer) {
...
@@ -26,7 +26,6 @@ function (VideoPlayer) {
describe
(
'always'
,
function
()
{
describe
(
'always'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
state
=
jasmine
.
initializePlayer
();
state
=
jasmine
.
initializePlayer
();
state
.
videoEl
=
$
(
'video, iframe'
);
state
.
videoEl
=
$
(
'video, iframe'
);
});
});
...
@@ -211,7 +210,7 @@ function (VideoPlayer) {
...
@@ -211,7 +210,7 @@ function (VideoPlayer) {
state
.
videoEl
=
$
(
'video, iframe'
);
state
.
videoEl
=
$
(
'video, iframe'
);
spyOn
(
state
.
videoControl
,
'pause'
).
andCallThrough
();
spyOn
(
state
.
videoControl
,
'pause'
).
andCallThrough
();
spyOn
(
state
.
videoCaption
,
'pause
'
).
andCallThrough
();
spyOn
(
$
.
fn
,
'trigger
'
).
andCallThrough
();
state
.
videoPlayer
.
onStateChange
({
state
.
videoPlayer
.
onStateChange
({
data
:
YT
.
PlayerState
.
PAUSED
data
:
YT
.
PlayerState
.
PAUSED
...
@@ -223,7 +222,7 @@ function (VideoPlayer) {
...
@@ -223,7 +222,7 @@ function (VideoPlayer) {
});
});
it
(
'pause the video caption'
,
function
()
{
it
(
'pause the video caption'
,
function
()
{
expect
(
state
.
videoCaption
.
pause
).
toHaveBeenCalled
(
);
expect
(
$
.
fn
.
trigger
).
toHaveBeenCalledWith
(
'pause'
,
{}
);
});
});
});
});
...
@@ -245,7 +244,7 @@ function (VideoPlayer) {
...
@@ -245,7 +244,7 @@ function (VideoPlayer) {
spyOn
(
state
.
videoPlayer
,
'log'
).
andCallThrough
();
spyOn
(
state
.
videoPlayer
,
'log'
).
andCallThrough
();
spyOn
(
window
,
'setInterval'
).
andReturn
(
100
);
spyOn
(
window
,
'setInterval'
).
andReturn
(
100
);
spyOn
(
state
.
videoControl
,
'play'
);
spyOn
(
state
.
videoControl
,
'play'
);
spyOn
(
state
.
videoCaption
,
'play'
);
spyOn
(
$
.
fn
,
'trigger'
).
andCallThrough
(
);
state
.
videoPlayer
.
onStateChange
({
state
.
videoPlayer
.
onStateChange
({
data
:
YT
.
PlayerState
.
PLAYING
data
:
YT
.
PlayerState
.
PLAYING
...
@@ -281,7 +280,7 @@ function (VideoPlayer) {
...
@@ -281,7 +280,7 @@ function (VideoPlayer) {
});
});
it
(
'play the video caption'
,
function
()
{
it
(
'play the video caption'
,
function
()
{
expect
(
state
.
videoCaption
.
play
).
toHaveBeenCalled
(
);
expect
(
$
.
fn
.
trigger
).
toHaveBeenCalledWith
(
'play'
,
{}
);
});
});
});
});
...
@@ -295,7 +294,7 @@ function (VideoPlayer) {
...
@@ -295,7 +294,7 @@ function (VideoPlayer) {
spyOn
(
state
.
videoPlayer
,
'log'
).
andCallThrough
();
spyOn
(
state
.
videoPlayer
,
'log'
).
andCallThrough
();
spyOn
(
state
.
videoControl
,
'pause'
).
andCallThrough
();
spyOn
(
state
.
videoControl
,
'pause'
).
andCallThrough
();
spyOn
(
state
.
videoCaption
,
'pause
'
).
andCallThrough
();
spyOn
(
$
.
fn
,
'trigger
'
).
andCallThrough
();
state
.
videoPlayer
.
onStateChange
({
state
.
videoPlayer
.
onStateChange
({
data
:
YT
.
PlayerState
.
PLAYING
data
:
YT
.
PlayerState
.
PLAYING
...
@@ -323,7 +322,7 @@ function (VideoPlayer) {
...
@@ -323,7 +322,7 @@ function (VideoPlayer) {
});
});
it
(
'pause the video caption'
,
function
()
{
it
(
'pause the video caption'
,
function
()
{
expect
(
state
.
videoCaption
.
pause
).
toHaveBeenCalled
(
);
expect
(
$
.
fn
.
trigger
).
toHaveBeenCalledWith
(
'pause'
,
{}
);
});
});
});
});
...
@@ -334,7 +333,7 @@ function (VideoPlayer) {
...
@@ -334,7 +333,7 @@ function (VideoPlayer) {
state
.
videoEl
=
$
(
'video, iframe'
);
state
.
videoEl
=
$
(
'video, iframe'
);
spyOn
(
state
.
videoControl
,
'pause'
).
andCallThrough
();
spyOn
(
state
.
videoControl
,
'pause'
).
andCallThrough
();
spyOn
(
state
.
videoCaption
,
'pause
'
).
andCallThrough
();
spyOn
(
$
.
fn
,
'trigger
'
).
andCallThrough
();
state
.
videoPlayer
.
onStateChange
({
state
.
videoPlayer
.
onStateChange
({
data
:
YT
.
PlayerState
.
ENDED
data
:
YT
.
PlayerState
.
ENDED
...
@@ -346,7 +345,7 @@ function (VideoPlayer) {
...
@@ -346,7 +345,7 @@ function (VideoPlayer) {
});
});
it
(
'pause the video caption'
,
function
()
{
it
(
'pause the video caption'
,
function
()
{
expect
(
state
.
videoCaption
.
pause
).
toHaveBeenCalled
(
);
expect
(
$
.
fn
.
trigger
).
toHaveBeenCalledWith
(
'ended'
,
{}
);
});
});
});
});
});
});
...
@@ -709,6 +708,7 @@ function (VideoPlayer) {
...
@@ -709,6 +708,7 @@ function (VideoPlayer) {
describe
(
'updatePlayTime with invalid endTime'
,
function
()
{
describe
(
'updatePlayTime with invalid endTime'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
state
=
{
state
=
{
el
:
$
(
'#video_id'
),
videoPlayer
:
{
videoPlayer
:
{
duration
:
function
()
{
duration
:
function
()
{
// The video will be 60 seconds long.
// The video will be 60 seconds long.
...
@@ -756,10 +756,7 @@ function (VideoPlayer) {
...
@@ -756,10 +756,7 @@ function (VideoPlayer) {
describe
(
'when the video player is not full screen'
,
function
()
{
describe
(
'when the video player is not full screen'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
state
=
jasmine
.
initializePlayer
();
state
=
jasmine
.
initializePlayer
();
state
.
videoEl
=
$
(
'video, iframe'
);
state
.
videoEl
=
$
(
'video, iframe'
);
spyOn
(
state
.
videoCaption
,
'resize'
).
andCallThrough
();
spyOn
(
$
.
fn
,
'trigger'
).
andCallThrough
();
spyOn
(
$
.
fn
,
'trigger'
).
andCallThrough
();
state
.
videoControl
.
toggleFullScreen
(
jQuery
.
Event
(
'click'
));
state
.
videoControl
.
toggleFullScreen
(
jQuery
.
Event
(
'click'
));
});
});
...
@@ -774,7 +771,7 @@ function (VideoPlayer) {
...
@@ -774,7 +771,7 @@ function (VideoPlayer) {
});
});
it
(
'tell VideoCaption to resize'
,
function
()
{
it
(
'tell VideoCaption to resize'
,
function
()
{
expect
(
state
.
videoCaption
.
resize
).
toHaveBeenCalled
(
);
expect
(
$
.
fn
.
trigger
).
toHaveBeenCalledWith
(
'fullscreen'
,
[
true
]
);
expect
(
state
.
resizer
.
setMode
).
toHaveBeenCalledWith
(
'both'
);
expect
(
state
.
resizer
.
setMode
).
toHaveBeenCalledWith
(
'both'
);
expect
(
state
.
resizer
.
delta
.
substract
).
toHaveBeenCalled
();
expect
(
state
.
resizer
.
delta
.
substract
).
toHaveBeenCalled
();
});
});
...
@@ -783,11 +780,8 @@ function (VideoPlayer) {
...
@@ -783,11 +780,8 @@ function (VideoPlayer) {
describe
(
'when the video player already full screen'
,
function
()
{
describe
(
'when the video player already full screen'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
state
=
jasmine
.
initializePlayer
();
state
=
jasmine
.
initializePlayer
();
state
.
videoEl
=
$
(
'video, iframe'
);
state
.
videoEl
=
$
(
'video, iframe'
);
spyOn
(
$
.
fn
,
'trigger'
).
andCallThrough
();
spyOn
(
state
.
videoCaption
,
'resize'
).
andCallThrough
();
state
.
el
.
addClass
(
'video-fullscreen'
);
state
.
el
.
addClass
(
'video-fullscreen'
);
state
.
videoControl
.
fullScreenState
=
true
;
state
.
videoControl
.
fullScreenState
=
true
;
state
.
videoControl
.
isFullScreen
=
true
;
state
.
videoControl
.
isFullScreen
=
true
;
...
@@ -806,7 +800,7 @@ function (VideoPlayer) {
...
@@ -806,7 +800,7 @@ function (VideoPlayer) {
});
});
it
(
'tell VideoCaption to resize'
,
function
()
{
it
(
'tell VideoCaption to resize'
,
function
()
{
expect
(
state
.
videoCaption
.
resize
).
toHaveBeenCalled
(
);
expect
(
$
.
fn
.
trigger
).
toHaveBeenCalledWith
(
'fullscreen'
,
[
false
]
);
expect
(
state
.
resizer
.
setMode
)
expect
(
state
.
resizer
.
setMode
)
.
toHaveBeenCalledWith
(
'width'
);
.
toHaveBeenCalledWith
(
'width'
);
expect
(
state
.
resizer
.
delta
.
reset
).
toHaveBeenCalled
();
expect
(
state
.
resizer
.
delta
.
reset
).
toHaveBeenCalled
();
...
...
common/lib/xmodule/xmodule/js/src/video/03_video_player.js
View file @
2f572a86
...
@@ -223,20 +223,20 @@ function (HTML5Video, Resizer) {
...
@@ -223,20 +223,20 @@ function (HTML5Video, Resizer) {
container
:
state
.
container
container
:
state
.
container
})
})
.
callbacks
.
once
(
function
()
{
.
callbacks
.
once
(
function
()
{
state
.
trigger
(
'videoCaption.resize'
,
null
);
state
.
el
.
trigger
(
'caption:resize'
);
})
})
.
setMode
(
'width'
);
.
setMode
(
'width'
);
// Update captions size when controls becomes visible on iPad or Android
// Update captions size when controls becomes visible on iPad or Android
if
(
/iPad|Android/i
.
test
(
state
.
isTouch
[
0
]))
{
if
(
/iPad|Android/i
.
test
(
state
.
isTouch
[
0
]))
{
state
.
el
.
on
(
'controls:show'
,
function
()
{
state
.
el
.
on
(
'controls:show'
,
function
()
{
state
.
trigger
(
'videoCaption.resize'
,
null
);
state
.
el
.
trigger
(
'caption:resize'
);
});
});
}
}
$
(
window
).
on
(
'resize'
,
_
.
debounce
(
function
()
{
$
(
window
).
on
(
'resize'
,
_
.
debounce
(
function
()
{
state
.
trigger
(
'videoControl.updateControlsHeight'
,
null
);
state
.
trigger
(
'videoControl.updateControlsHeight'
,
null
);
state
.
trigger
(
'videoCaption.resize'
,
null
);
state
.
el
.
trigger
(
'caption:resize'
);
state
.
resizer
.
align
();
state
.
resizer
.
align
();
},
100
));
},
100
));
}
}
...
@@ -271,7 +271,7 @@ function (HTML5Video, Resizer) {
...
@@ -271,7 +271,7 @@ function (HTML5Video, Resizer) {
});
});
_updateVcrAndRegion
(
state
,
true
);
_updateVcrAndRegion
(
state
,
true
);
state
.
trigger
(
'videoCaption.fetchCaption'
,
null
);
state
.
el
.
trigger
(
'caption:fetch'
);
state
.
resizer
.
setElement
(
state
.
el
.
find
(
'iframe'
)).
align
();
state
.
resizer
.
setElement
(
state
.
el
.
find
(
'iframe'
)).
align
();
}
}
...
@@ -447,10 +447,6 @@ function (HTML5Video, Resizer) {
...
@@ -447,10 +447,6 @@ function (HTML5Video, Resizer) {
end
:
true
end
:
true
});
});
if
(
this
.
config
.
showCaptions
)
{
this
.
trigger
(
'videoCaption.pause'
,
null
);
}
if
(
this
.
videoPlayer
.
skipOnEndedStartEndReset
)
{
if
(
this
.
videoPlayer
.
skipOnEndedStartEndReset
)
{
this
.
videoPlayer
.
skipOnEndedStartEndReset
=
undefined
;
this
.
videoPlayer
.
skipOnEndedStartEndReset
=
undefined
;
}
}
...
@@ -475,11 +471,6 @@ function (HTML5Video, Resizer) {
...
@@ -475,11 +471,6 @@ function (HTML5Video, Resizer) {
delete
this
.
videoPlayer
.
updateInterval
;
delete
this
.
videoPlayer
.
updateInterval
;
this
.
trigger
(
'videoControl.pause'
,
null
);
this
.
trigger
(
'videoControl.pause'
,
null
);
if
(
this
.
config
.
showCaptions
)
{
this
.
trigger
(
'videoCaption.pause'
,
null
);
}
this
.
saveState
(
true
);
this
.
saveState
(
true
);
this
.
el
.
trigger
(
'pause'
,
arguments
);
this
.
el
.
trigger
(
'pause'
,
arguments
);
}
}
...
@@ -501,17 +492,10 @@ function (HTML5Video, Resizer) {
...
@@ -501,17 +492,10 @@ function (HTML5Video, Resizer) {
}
}
this
.
trigger
(
'videoControl.play'
,
null
);
this
.
trigger
(
'videoControl.play'
,
null
);
this
.
trigger
(
'videoProgressSlider.notifyThroughHandleEnd'
,
{
this
.
trigger
(
'videoProgressSlider.notifyThroughHandleEnd'
,
{
end
:
false
end
:
false
});
});
if
(
this
.
config
.
showCaptions
)
{
this
.
trigger
(
'videoCaption.play'
,
null
);
}
this
.
videoPlayer
.
ready
();
this
.
videoPlayer
.
ready
();
this
.
el
.
trigger
(
'play'
,
arguments
);
this
.
el
.
trigger
(
'play'
,
arguments
);
}
}
...
@@ -803,7 +787,7 @@ function (HTML5Video, Resizer) {
...
@@ -803,7 +787,7 @@ function (HTML5Video, Resizer) {
}
}
);
);
this
.
trigger
(
'videoCaption.updatePlayTime'
,
time
);
this
.
el
.
trigger
(
'caption:update'
,
[
time
]
);
}
}
function
isEnded
()
{
function
isEnded
()
{
...
...
common/lib/xmodule/xmodule/js/src/video/04_video_control.js
View file @
2f572a86
...
@@ -277,7 +277,6 @@ function () {
...
@@ -277,7 +277,6 @@ function () {
.
attr
(
'title'
,
text
)
.
attr
(
'title'
,
text
)
.
text
(
text
);
.
text
(
text
);
this
.
trigger
(
'videoCaption.resize'
,
null
);
this
.
el
.
trigger
(
'fullscreen'
,
[
this
.
isFullScreen
]);
this
.
el
.
trigger
(
'fullscreen'
,
[
this
.
isFullScreen
]);
}
}
...
...
common/lib/xmodule/xmodule/js/src/video/09_video_caption.js
View file @
2f572a86
This diff is collapsed.
Click to expand it.
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