-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Tech change handler spam #1859
Closed
Closed
Tech change handler spam #1859
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d7c7d38
Tech change handler spam fixes #882 #1485 #1505 #1484
benjipott 6bfc50e
Tech change handler spam fixes #882 #1485 #1505 #1484
benjipott e069608
Fix duplicate off key
benjipott 7eb93a8
Merge branch 'hotfix/switch-between-tech' of https://github.com/benji…
benjipott c7443d1
Fix duplicate off key
benjipott 0da0f77
Rename disable controls method
benjipott 0316c38
Rename method to desactivateControls
benjipott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,20 +53,14 @@ vjs.MediaTechController = vjs.Component.extend({ | |
* any controls will still keep the user active | ||
*/ | ||
vjs.MediaTechController.prototype.initControlsListeners = function(){ | ||
var player, activateControls; | ||
var player; | ||
|
||
player = this.player(); | ||
|
||
activateControls = function(){ | ||
if (player.controls() && !player.usingNativeControls()) { | ||
this.addControlsListeners(); | ||
} | ||
}; | ||
|
||
// Set up event listeners once the tech is ready and has an element to apply | ||
// listeners to | ||
this.ready(activateControls); | ||
this.on(player, 'controlsenabled', activateControls); | ||
this.ready(this.activateControls); | ||
this.on(player, 'controlsenabled', this.activateControls); | ||
this.on(player, 'controlsdisabled', this.removeControlsListeners); | ||
|
||
// if we're loading the playback object after it has started loading or playing the | ||
|
@@ -81,6 +75,15 @@ vjs.MediaTechController.prototype.initControlsListeners = function(){ | |
}); | ||
}; | ||
|
||
vjs.MediaTechController.prototype.removeControlsListeners = function () { | ||
var player; | ||
|
||
player = this.player(); | ||
|
||
this.off(player, 'controlsenabled', this.activateControls); | ||
this.off(player, 'controlsdisabled', this.removeControlsListeners); | ||
}; | ||
|
||
vjs.MediaTechController.prototype.addControlsListeners = function(){ | ||
var userWasActive; | ||
|
||
|
@@ -133,6 +136,19 @@ vjs.MediaTechController.prototype.removeControlsListeners = function(){ | |
this.off('mousedown'); | ||
}; | ||
|
||
/** | ||
* Activate contols listeners handler | ||
*/ | ||
vjs.MediaTechController.prototype.activateControls = function () { | ||
var player; | ||
|
||
player = this.player(); | ||
|
||
if (player.controls() && !player.usingNativeControls()) { | ||
this.addControlsListeners(); | ||
} | ||
}; | ||
|
||
/** | ||
* Handle a click on the media element. By default will play/pause the media. | ||
*/ | ||
|
@@ -218,6 +234,7 @@ vjs.MediaTechController.prototype.manualTimeUpdatesOff = function(){ | |
var player = this.player_; | ||
|
||
this.manualTimeUpdates = false; | ||
|
||
this.stopTrackingCurrentTime(); | ||
this.off(player, 'play', this.trackCurrentTime); | ||
this.off(player, 'pause', this.stopTrackingCurrentTime); | ||
|
@@ -239,7 +256,8 @@ vjs.MediaTechController.prototype.stopTrackingCurrentTime = function(){ | |
this.player().trigger('timeupdate'); | ||
}; | ||
|
||
vjs.MediaTechController.prototype.dispose = function() { | ||
vjs.MediaTechController.prototype.dispose = function(){ | ||
this.removeControlsListeners(); | ||
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. This actuallyl shouldn't be needed. When you use |
||
// Turn off any manual progress or timeupdate tracking | ||
if (this.manualProgress) { this.manualProgressOff(); } | ||
|
||
|
@@ -248,7 +266,7 @@ vjs.MediaTechController.prototype.dispose = function() { | |
vjs.Component.prototype.dispose.call(this); | ||
}; | ||
|
||
vjs.MediaTechController.prototype.setCurrentTime = function() { | ||
vjs.MediaTechController.prototype.setCurrentTime = function(){ | ||
// improve the accuracy of manual timeupdates | ||
if (this.manualTimeUpdates) { this.player().trigger('timeupdate'); } | ||
}; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's already a removeControlsListeners. Should this be combined with that?
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.
I think there's a problem with this. It will remove the removeControlsListeners and activateControls listeners when
controlsdisabled
is triggered, but what ifcontrolsenabled
is triggered again? I think this will break that use case.e.g.