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
af67873b
Commit
af67873b
authored
Jun 16, 2014
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix seek log.
parent
8191d3c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
67 deletions
+90
-67
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
+87
-64
common/lib/xmodule/xmodule/js/src/video/03_video_player.js
+3
-3
No files found.
common/lib/xmodule/xmodule/js/spec/video/video_player_spec.js
View file @
af67873b
...
@@ -356,77 +356,80 @@ function (VideoPlayer) {
...
@@ -356,77 +356,80 @@ function (VideoPlayer) {
describe
(
'onSeek'
,
function
()
{
describe
(
'onSeek'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
state
=
jasmine
.
initializePlayer
();
state
=
jasmine
.
initializePlayer
();
state
.
videoEl
=
$
(
'video, iframe'
);
state
.
videoEl
=
$
(
'video, iframe'
);
});
runs
(
function
()
{
describe
(
'when the video is playing'
,
function
()
{
state
.
videoPlayer
.
play
();
beforeEach
(
function
()
{
});
runs
(
function
()
{
state
.
videoPlayer
.
play
();
waitsFor
(
function
()
{
});
var
duration
=
state
.
videoPlayer
.
duration
();
return
duration
>
0
&&
state
.
videoPlayer
.
isPlaying
();
waitsFor
(
function
()
{
},
'video begins playing'
,
WAIT_TIMEOUT
);
var
duration
=
state
.
videoPlayer
.
duration
();
});
it
(
'Slider event causes log update'
,
function
()
{
return
duration
>
0
&&
state
.
videoPlayer
.
isPlaying
();
runs
(
function
()
{
},
'video didn
\'
t start playing'
,
WAIT_TIMEOUT
);
spyOn
(
state
.
videoPlayer
,
'log'
);
state
.
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
2
}
);
});
});
waitsFor
(
function
()
{
it
(
'slider event causes log update'
,
function
()
{
return
state
.
videoPlayer
.
currentTime
>=
2
;
runs
(
function
()
{
},
'currentTime is less than 2 seconds'
,
WAIT_TIMEOUT
);
spyOn
(
state
.
videoPlayer
,
'log'
);
state
.
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
2
}
);
});
runs
(
function
()
{
waitsFor
(
function
()
{
expect
(
state
.
videoPlayer
.
log
).
toHaveBeenCalledWith
(
return
state
.
videoPlayer
.
currentTime
>=
2
;
'seek_video'
,
},
'currentTime is less than 2 seconds'
,
WAIT_TIMEOUT
);
{
old_time
:
jasmine
.
any
(
Number
),
new_time
:
2
,
type
:
'onSlideSeek'
}
);
});
});
it
(
'seek the player'
,
function
()
{
runs
(
function
()
{
runs
(
function
()
{
var
args
=
state
.
videoPlayer
.
log
.
calls
[
0
].
args
;
spyOn
(
state
.
videoPlayer
.
player
,
'seekTo'
).
andCallThrough
();
state
.
videoProgressSlider
.
onSlide
(
expect
(
args
[
0
]).
toBe
(
'seek_video'
);
jQuery
.
Event
(
'slide'
),
{
value
:
30
}
expect
(
args
[
1
].
old_time
).
toBeLessThan
(
2
);
);
expect
(
args
[
1
].
new_time
).
toBe
(
2
);
expect
(
args
[
1
].
type
).
toBe
(
'onSlideSeek'
);
});
});
});
waitsFor
(
function
()
{
it
(
'seek the player'
,
function
()
{
return
state
.
videoPlayer
.
currentTime
>=
30
;
runs
(
function
()
{
},
'currentTime is less than 30 seconds'
,
WAIT_TIMEOUT
);
spyOn
(
state
.
videoPlayer
.
player
,
'seekTo'
)
.
andCallThrough
();
state
.
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
30
}
);
});
runs
(
function
()
{
waitsFor
(
function
()
{
expect
(
state
.
videoPlayer
.
player
.
seekTo
)
return
state
.
videoPlayer
.
currentTime
>=
30
;
.
toHaveBeenCalledWith
(
30
,
true
);
},
'currentTime is less than 30 seconds'
,
WAIT_TIMEOUT
);
});
});
it
(
'call updatePlayTime on player'
,
function
()
{
runs
(
function
()
{
runs
(
function
()
{
expect
(
state
.
videoPlayer
.
player
.
seekTo
)
spyOn
(
state
.
videoPlayer
,
'updatePlayTime'
).
andCallThrough
();
.
toHaveBeenCalledWith
(
30
,
true
);
state
.
videoProgressSlider
.
onSlide
(
});
jQuery
.
Event
(
'slide'
),
{
value
:
30
}
);
});
});
waitsFor
(
function
()
{
it
(
'call updatePlayTime on player'
,
function
()
{
return
state
.
videoPlayer
.
currentTime
>=
30
;
runs
(
function
()
{
},
'currentTime is less than 30 seconds'
,
WAIT_TIMEOUT
);
spyOn
(
state
.
videoPlayer
,
'updatePlayTime'
)
.
andCallThrough
();
state
.
videoProgressSlider
.
onSlide
(
jQuery
.
Event
(
'slide'
),
{
value
:
30
}
);
});
runs
(
function
()
{
waitsFor
(
function
()
{
expect
(
state
.
videoPlayer
.
updatePlayTime
)
return
state
.
videoPlayer
.
currentTime
>=
30
;
.
toHaveBeenCalledWith
(
jasmine
.
any
(
Number
));
},
'currentTime is less than 30 seconds'
,
WAIT_TIMEOUT
);
runs
(
function
()
{
expect
(
state
.
videoPlayer
.
updatePlayTime
)
.
toHaveBeenCalledWith
(
30
,
true
);
});
});
});
});
});
...
@@ -452,13 +455,31 @@ function (VideoPlayer) {
...
@@ -452,13 +455,31 @@ function (VideoPlayer) {
describe
(
'when the video is not playing'
,
function
()
{
describe
(
'when the video is not playing'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
state
=
jasmine
.
initializePlayer
();
spyOn
(
state
.
videoPlayer
,
'setPlaybackRate'
)
.
andCallThrough
();
});
spyOn
(
state
.
videoPlayer
,
'updatePlayTime'
).
andCallThrough
();
it
(
'slider event causes log update'
,
function
()
{
spyOn
(
state
,
'setSpeed'
).
andCallThrough
();
runs
(
function
()
{
spyOn
(
state
.
videoPlayer
,
'log'
).
andCallThrough
();
spyOn
(
state
.
videoPlayer
,
'log'
);
spyOn
(
state
.
videoPlayer
.
player
,
'setPlaybackRate'
).
andCallThrough
();
state
.
videoProgressSlider
.
onSlide
(
spyOn
(
state
.
videoPlayer
,
'setPlaybackRate'
).
andCallThrough
();
jQuery
.
Event
(
'slide'
),
{
value
:
2
}
);
});
waitsFor
(
function
()
{
return
state
.
videoPlayer
.
currentTime
>=
2
;
},
'currentTime is less than 2 seconds'
,
WAIT_TIMEOUT
);
runs
(
function
()
{
expect
(
state
.
videoPlayer
.
log
).
toHaveBeenCalledWith
(
'seek_video'
,
{
old_time
:
0
,
new_time
:
2
,
type
:
'onSlideSeek'
}
);
});
});
});
it
(
'video has a correct speed'
,
function
()
{
it
(
'video has a correct speed'
,
function
()
{
...
@@ -483,7 +504,8 @@ function (VideoPlayer) {
...
@@ -483,7 +504,8 @@ function (VideoPlayer) {
it
(
'set the volume on player'
,
function
()
{
it
(
'set the volume on player'
,
function
()
{
spyOn
(
state
.
videoPlayer
.
player
,
'setVolume'
);
spyOn
(
state
.
videoPlayer
.
player
,
'setVolume'
);
state
.
videoPlayer
.
onVolumeChange
(
60
);
state
.
videoPlayer
.
onVolumeChange
(
60
);
expect
(
state
.
videoPlayer
.
player
.
setVolume
).
toHaveBeenCalledWith
(
60
);
expect
(
state
.
videoPlayer
.
player
.
setVolume
)
.
toHaveBeenCalledWith
(
60
);
});
});
describe
(
'when the video is not playing'
,
function
()
{
describe
(
'when the video is not playing'
,
function
()
{
...
@@ -522,7 +544,8 @@ function (VideoPlayer) {
...
@@ -522,7 +544,8 @@ function (VideoPlayer) {
});
});
it
(
'does not trigger updatePlayTime event'
,
function
()
{
it
(
'does not trigger updatePlayTime event'
,
function
()
{
expect
(
state
.
videoPlayer
.
updatePlayTime
).
not
.
toHaveBeenCalled
();
expect
(
state
.
videoPlayer
.
updatePlayTime
)
.
not
.
toHaveBeenCalled
();
});
});
});
});
...
...
common/lib/xmodule/xmodule/js/src/video/03_video_player.js
View file @
af67873b
...
@@ -431,7 +431,8 @@ function (HTML5Video, Resizer) {
...
@@ -431,7 +431,8 @@ function (HTML5Video, Resizer) {
// Reinitialized on a onSeek event.
// Reinitialized on a onSeek event.
function
onSeek
(
params
)
{
function
onSeek
(
params
)
{
var
time
=
params
.
time
,
var
time
=
params
.
time
,
type
=
params
.
type
;
type
=
params
.
type
,
oldTime
=
this
.
videoPlayer
.
currentTime
;
// After the user seeks, the video will start playing from
// After the user seeks, the video will start playing from
// the sought point, and stop playing at the end.
// the sought point, and stop playing at the end.
...
@@ -441,11 +442,10 @@ function (HTML5Video, Resizer) {
...
@@ -441,11 +442,10 @@ function (HTML5Video, Resizer) {
}
}
this
.
videoPlayer
.
seekTo
(
time
);
this
.
videoPlayer
.
seekTo
(
time
);
this
.
videoPlayer
.
log
(
this
.
videoPlayer
.
log
(
'seek_video'
,
'seek_video'
,
{
{
old_time
:
this
.
videoPlayer
.
current
Time
,
old_time
:
old
Time
,
new_time
:
time
,
new_time
:
time
,
type
:
type
type
:
type
}
}
...
...
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