-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Video: Add heartbeats to video logging #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,6 +154,25 @@ function (HTML5Video) { | |
| }); | ||
| } | ||
|
|
||
| // Start heartbeats logging. | ||
| // Send logs to the server each state.config.heartbeatsLoggingDelay seconds | ||
| // and provide an indication of whether students still have a video playing | ||
| // on their screen so that we have a better idea of whether they are getting | ||
| // the educational benefit of watching the lecture. | ||
| function _startHeartbeatLogging(state) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment about what these function do and why they are necessary. To a person who never has anything to do with heartbeats this will be helpful.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added comments. |
||
| if (!state.videoPlayer.heartbeatsInterval) { | ||
| state.videoPlayer.heartbeatsInterval = window.setInterval( | ||
| _.bind(state.videoPlayer.log, state, 'is_video_playing'), | ||
| state.config.heartbeatsLoggingDelay | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // Stop heartbeats logging. | ||
| function _stopHeartbeatLogging(state) { | ||
| window.clearInterval(state.videoPlayer.heartbeatsInterval); | ||
| } | ||
|
|
||
| // *************************************************************** | ||
| // Public functions start here. | ||
| // These are available via the 'state' object. Their context ('this' keyword) is the 'state' object. | ||
|
|
@@ -267,6 +286,7 @@ function (HTML5Video) { | |
| } | ||
| ); | ||
|
|
||
| _stopHeartbeatLogging(this); | ||
| clearInterval(this.videoPlayer.updateInterval); | ||
| delete this.videoPlayer.updateInterval; | ||
|
|
||
|
|
@@ -285,6 +305,8 @@ function (HTML5Video) { | |
| } | ||
| ); | ||
|
|
||
| _startHeartbeatLogging(this); | ||
|
|
||
| if (!this.videoPlayer.updateInterval) { | ||
| this.videoPlayer.updateInterval = setInterval(this.videoPlayer.update, 200); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why you shouldn't try to line up the values in an object: this should have been a one-line change.