Skip to content

Commit

Permalink
Trigger completed statement at 95% or more watched
Browse files Browse the repository at this point in the history
When video ends, if the watched segments cover at least 95% of the total video time, then fire the xAPI completed statement. This covers edge cases where small imprecisions in play/pause timecodes cause getProgress() to report less-than-100% completion, even if the entire video was watched.
  • Loading branch information
figureone committed Mar 23, 2018
1 parent 91936f3 commit 166c8d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ H5P.VideoHtml5 = (function ($) {
if (length > 0) {
// Length passed in as current time, because at end of video when this is fired currentTime reset to 0 if on loop
var progress = videoXAPI.getProgress(length, length);
if (progress >= 1) {
if (progress >= 0.95) {
extraTrigger = 'finished';
extraArg = videoXAPI.getArgsXAPICompleted(video.currentTime, video.duration, progress);
lastSend = 'finished';
Expand Down
2 changes: 1 addition & 1 deletion scripts/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ H5P.VideoYouTube = (function ($) {
if (length > 0) {
// Length passed in as current time, because at end of video when this is fired currentTime reset to 0 if on loop
var progress = videoXAPI.getProgress(length, length);
if (progress >= 1) {
if (progress >= 0.95) {
var arg = videoXAPI.getArgsXAPICompleted(player.getCurrentTime(), self.duration, progress);
self.trigger('finished', arg);
}
Expand Down

0 comments on commit 166c8d3

Please sign in to comment.