Skip to content

Commit

Permalink
Merge branch 'add-xapi-video-verbs' of https://github.com/uhm-coe/h5p…
Browse files Browse the repository at this point in the history
…-video into add-xapi-video-verbs

# Conflicts:
#	scripts/html5.js
#	scripts/youtube.js
  • Loading branch information
KirkJohnson committed Apr 23, 2018
2 parents 4f70c16 + cbef273 commit 94ff7b3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
29 changes: 27 additions & 2 deletions scripts/video.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @namespace H5P */
H5P.Video = (function ($, ContentCopyrights, MediaCopyright, handlers) {
'use strict';

/**
* The ultimate H5P video player!
Expand All @@ -15,14 +16,35 @@ H5P.Video = (function ($, ContentCopyrights, MediaCopyright, handlers) {
function Video(parameters, id) {
var self = this;

self.videoXAPI = new H5P.VideoXAPI(self);

// Ref youtube.js - ipad & youtube - issue
self.pressToPlay = false;

// Values needed for xAPI triggering
self.finishedThreshold = 0.95;

// Values needed for xAPI triggering, set by handlers
self.previousTime = 0;
self.seeking = false;
self.seekedTo = 0;
self.duration = 0;
self.previousState = -1;
self.mousedown = false;

/*
* Used to distinguish seeking from pausing
* TODO: This might be much cleaner with refactoring IV, video and the handlers
*/
document.addEventListener('mousedown', function() {
self.mousedown = true;
});
document.addEventListener('mouseup', function() {
if (self.seeking) {
self.trigger('seeked', self.videoXAPI.getArgsXAPISeeked(self.seekedTo));
self.seeking = false;
}
self.mousedown = false;
});

// Initialize event inheritance
H5P.EventDispatcher.call(self);
Expand Down Expand Up @@ -145,7 +167,10 @@ H5P.Video = (function ($, ContentCopyrights, MediaCopyright, handlers) {
self.triggerXAPI('initialized', event.data);
});
self.on('paused', function (event) {
self.triggerXAPI('paused', event.data);
// if mouse button is down, we're seeking
if (self.mousedown === false) {
self.triggerXAPI('paused', event.data);
}
});

// Find player for video sources
Expand Down
4 changes: 2 additions & 2 deletions scripts/x-api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @namespace H5P */
H5P.VideoXAPI = (function ($) {
'use strict';

/**
* Xapi video statement generator for H5P.
Expand Down Expand Up @@ -135,7 +136,7 @@ H5P.VideoXAPI = (function ($) {
*/
self.getArgsXAPIPlayed = function (currentTime) {
var resultExtTime = formatFloat(currentTime);
playingSegmentStart = resultExtTime;
//playingSegmentStart = resultExtTime;

return self.getArgsXAPI({
verb: 'https://w3id.org/xapi/video/verbs/played',
Expand Down Expand Up @@ -426,7 +427,6 @@ H5P.VideoXAPI = (function ($) {
}
}
}
xAPIBase = xAPIObject;
return xAPIObject;
};
}
Expand Down

0 comments on commit 94ff7b3

Please sign in to comment.