Skip to content

Commit

Permalink
fix: wait till play event to listen for user activity (#5093)
Browse files Browse the repository at this point in the history
There is no need to listen for user activity until a play is requested on the player and it just adds an extra timer for a player that hasn't started playing yet. Instead, just wait till the first `play` event.

Closes #5076.
  • Loading branch information
axten authored and gkatsev committed Apr 20, 2018
1 parent 7c3213c commit 9f8ce2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ class Player extends Component {
// like the control bar show themselves if needed
this.userActive(true);
this.reportUserActivity();
this.listenForUserActivity_();

this.one('play', this.listenForUserActivity_);
this.on('fullscreenchange', this.handleFullscreenChange_);
this.on('stageclick', this.handleStageClick_);

Expand Down
4 changes: 4 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,8 @@ QUnit.test('should honor default inactivity timeout', function(assert) {
// default timeout is 2000ms
const player = TestHelpers.makePlayer({});

player.trigger('play');

assert.equal(player.userActive(), true, 'User is active on creation');
clock.tick(1800);
assert.equal(player.userActive(), true, 'User is still active');
Expand All @@ -932,6 +934,8 @@ QUnit.test('should honor configured inactivity timeout', function(assert) {
inactivityTimeout: 200
});

player.trigger('play');

assert.equal(player.userActive(), true, 'User is active on creation');
clock.tick(150);
assert.equal(player.userActive(), true, 'User is still active');
Expand Down

0 comments on commit 9f8ce2d

Please sign in to comment.