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
OpenEdx
edx-platform
Commits
ded745dc
Commit
ded745dc
authored
Oct 27, 2017
by
J. Cliff Dyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add video copmletion handler to main player.
parent
5475e3ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
common/lib/xmodule/xmodule/js/src/video/10_main.js
+5
-3
common/lib/xmodule/xmodule/js/src/video/99_completion.js
+16
-13
No files found.
common/lib/xmodule/xmodule/js/src/video/10_main.js
View file @
ded745dc
...
...
@@ -54,6 +54,7 @@
'video/09_events_plugin.js'
,
'video/09_events_bumper_plugin.js'
,
'video/09_poster.js'
,
'video/99_completion.js'
,
'video/10_commands.js'
,
'video/095_video_context_menu.js'
],
...
...
@@ -61,8 +62,8 @@
VideoStorage
,
initialize
,
FocusGrabber
,
VideoAccessibleMenu
,
VideoControl
,
VideoFullScreen
,
VideoQualityControl
,
VideoProgressSlider
,
VideoVolumeControl
,
VideoSpeedControl
,
VideoCaption
,
VideoPlayPlaceholder
,
VideoPlayPauseControl
,
VideoPlaySkipControl
,
VideoSkipControl
,
VideoBumper
,
VideoSaveStatePlugin
,
VideoEventsPlugin
,
VideoEventsBumperPlugin
,
VideoPoster
,
VideoCommands
,
VideoContextMenu
VideoSaveStatePlugin
,
VideoEventsPlugin
,
VideoEventsBumperPlugin
,
VideoPoster
,
VideoCo
mpletionHandler
,
VideoCommands
,
VideoCo
ntextMenu
)
{
var
youtubeXhr
=
null
,
oldVideo
=
window
.
Video
;
...
...
@@ -75,7 +76,7 @@
mainVideoModules
=
[
FocusGrabber
,
VideoControl
,
VideoPlayPlaceholder
,
VideoPlayPauseControl
,
VideoProgressSlider
,
VideoSpeedControl
,
VideoVolumeControl
,
VideoQualityControl
,
VideoFullScreen
,
VideoCaption
,
VideoCommands
,
VideoContextMenu
,
VideoSaveStatePlugin
,
VideoEventsPlugin
],
VideoSaveStatePlugin
,
VideoEventsPlugin
,
VideoCompletionHandler
],
bumperVideoModules
=
[
VideoControl
,
VideoPlaySkipControl
,
VideoSkipControl
,
VideoVolumeControl
,
VideoCaption
,
VideoCommands
,
VideoSaveStatePlugin
,
VideoEventsBumperPlugin
],
state
=
{
...
...
@@ -116,6 +117,7 @@
saveStateUrl
:
state
.
metadata
.
saveStateUrl
});
if
(
bumperMetadata
)
{
new
VideoPoster
(
el
,
{
poster
:
el
.
data
(
'poster'
),
...
...
common/lib/xmodule/xmodule/js/src/video/99_completion.js
View file @
ded745dc
...
...
@@ -8,20 +8,20 @@
* @param {Object} state The object containing the state of the video
* @return {jquery Promise}
*/
var
CompletionListen
er
=
function
(
state
)
{
if
(
!
(
this
instanceof
CompletionListen
er
))
{
return
new
CompletionListen
er
(
state
);
var
VideoCompletionHandl
er
=
function
(
state
)
{
if
(
!
(
this
instanceof
VideoCompletionHandl
er
))
{
return
new
VideoCompletionHandl
er
(
state
);
}
_
.
bindAll
(
this
,
'play'
,
'pause'
,
'onClick'
,
'destroy'
);
this
.
state
=
state
;
this
.
state
.
completion
Listen
er
=
this
;
this
.
state
.
completion
Handl
er
=
this
;
this
.
initialize
();
return
$
.
Deferred
().
resolve
().
promise
();
};
CompletionListen
er
.
prototype
=
{
VideoCompletionHandl
er
.
prototype
=
{
destroy
:
function
()
{
this
.
el
.
remove
();
this
.
state
.
el
.
off
(
'destroy'
,
this
.
destroy
);
...
...
@@ -30,20 +30,23 @@
/** Initializes the module. */
initialize
:
function
()
{
this
.
complete
=
False
;
this
.
complete
=
false
;
this
.
lastValue
=
1
;
this
.
bindHandlers
();
},
/** Bind any necessary function callbacks to DOM events. */
bindHandlers
:
function
()
{
this
.
state
.
el
.
on
({
'timeupdate'
:
this
.
checkCompletion
,
});
this
.
state
.
el
.
on
({
timeupdate
:
this
.
checkCompletion
});
},
/** Event handler to check if the video is complete, and submit a completion if it is */
checkCompletion
:
function
(
currentTime
)
{
// Need to access runtime for this.
if
(
currentTime
!=
this
.
lastValue
)
{
console
.
warn
(
"CURRENT TIME"
,
currentTime
);
this
.
lastValue
=
currentTime
;
}
if
(
this
.
complete
===
false
&&
currentTime
>
this
.
state
.
completeAfter
)
{
this
.
complete
=
true
;
if
(
this
.
state
.
config
.
publishCompletionUrl
)
{
...
...
@@ -54,13 +57,13 @@
completion
:
1.0
})
});
}
else
{
console
.
warn
(
"publishCompletionUrl not defined"
);
}
}
else
{
console
.
warn
(
'publishCompletionUrl not defined'
);
}
}
}
};
return
CompletionListen
er
;
return
VideoCompletionHandl
er
;
});
}(
RequireJS
.
define
));
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