-
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 3 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,24 @@ function (HTML5Video) { | |
| }); | ||
| } | ||
|
|
||
| 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 | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function _stopHeartbeatLogging(state) { | ||
| window.clearInterval(state.videoPlayer.heartbeatsInterval); | ||
| } | ||
|
|
||
| function _restartHeartbeatLogging(state) { | ||
| _stopHeartbeatLogging(); | ||
| _startHeartbeatLogging(); | ||
| } | ||
|
|
||
| // *************************************************************** | ||
| // Public functions start here. | ||
| // These are available via the 'state' object. Their context ('this' keyword) is the 'state' object. | ||
|
|
@@ -244,6 +262,7 @@ function (HTML5Video) { | |
| if (this.videoPlayer.isPlaying()) { | ||
| clearInterval(this.videoPlayer.updateInterval); | ||
| this.videoPlayer.updateInterval = setInterval(this.videoPlayer.update, 200); | ||
| _restartHeartbeatLogging(this); | ||
|
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. Why do we need to restart them?
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. Removed. |
||
| } else { | ||
| this.videoPlayer.currentTime = params.time; | ||
| } | ||
|
|
@@ -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.