-
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
Feature/reset player ui #4683 #5684
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
73c109c
Finished reset of progress bar and playback rate
reeckset bf5b0b8
Added volume reset
reeckset 0ea44eb
Fixed remaining time reset, added unit tests
reeckset 69a5bbf
Changed private method names to have _ suffix
reeckset 7a0338c
Moved UI reset method call to before playerreset event is triggered
reeckset c6bc3d9
Rolled package-lock back
reeckset 134cce4
Merge remote-tracking branch 'origin/master' into feature/reset-playe…
reeckset 93411a6
Removed durationchange trigger call in resetProgressBar, fixed test i…
reeckset 4987953
Changed duration to NaN upon reset
reeckset 05ea374
Changed resetControlBarUI to resetControlBarUI_
reeckset d0d09b5
Updated tests to call resetControlBarUI_ (with suffix)
reeckset 9df7e79
Merge branch 'master' into feature/reset-player-UI
gkatsev 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
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 |
---|---|---|
|
@@ -2928,11 +2928,49 @@ class Player extends Component { | |
} | ||
this.loadTech_(this.options_.techOrder[0], null); | ||
this.techCall_('reset'); | ||
this.resetControlBarUI(); | ||
if (isEvented(this)) { | ||
this.trigger('playerreset'); | ||
} | ||
} | ||
|
||
/** | ||
* Reset Control Bar's UI by calling sub-methods that reset | ||
* all of Control Bar's components | ||
*/ | ||
resetControlBarUI() { | ||
this.resetProgressBar_(); | ||
this.resetPlaybackRate_(); | ||
this.resetVolumeBar_(); | ||
} | ||
|
||
/** | ||
* Reset tech's progress so progress bar is reset in the UI | ||
*/ | ||
resetProgressBar_() { | ||
this.currentTime(0); | ||
this.duration(0); | ||
this.controlBar.durationDisplay.updateContent(); | ||
this.controlBar.remainingTimeDisplay.updateContent(); | ||
this.tech_.trigger({ type: 'timeupdate', target: this.tech_, manuallyTriggered: true }); | ||
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. |
||
} | ||
|
||
/** | ||
* Reset Playback ratio | ||
*/ | ||
resetPlaybackRate_() { | ||
this.playbackRate(this.defaultPlaybackRate()); | ||
this.handleTechRateChange_(); | ||
} | ||
|
||
/** | ||
* Reset Volume bar | ||
*/ | ||
resetVolumeBar_() { | ||
this.volume(1.0); | ||
this.trigger('volumechange'); | ||
} | ||
|
||
/** | ||
* Returns all of the current source objects. | ||
* | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint-env qunit */ | ||
import TestHelpers from './test-helpers.js'; | ||
gkatsev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
QUnit.module('player reset-ui'); | ||
|
||
QUnit.test('Calling resetProgressBar player method should place progress bar at 0% width', function(assert) { | ||
const player = TestHelpers.makePlayer(); | ||
|
||
player.currentTime(20); | ||
player.trigger('timeupdate'); | ||
player.resetProgressBar_(); | ||
assert.equal( | ||
player.controlBar.progressControl.seekBar.playProgressBar.el().offsetWidth, 0, | ||
'progress bar is reset to width 0%' | ||
); | ||
assert.equal( | ||
player.currentTime(), 0, | ||
'player current time is 0' | ||
); | ||
player.dispose(); | ||
}); | ||
|
||
QUnit.test('Calling resetPlaybackRate player method should place play rate at 1x', function(assert) { | ||
const player = TestHelpers.makePlayer({techOrder: ['html5']}); | ||
|
||
player.playbackRate(2); | ||
player.handleTechRateChange_(); | ||
player.resetPlaybackRate_(); | ||
const defaultRate = player.defaultPlaybackRate(); | ||
|
||
assert.equal( | ||
player.controlBar.playbackRateMenuButton.labelEl_.textContent, defaultRate + 'x', | ||
'Playback rate is the default one on the UI' | ||
); | ||
assert.equal( | ||
player.playbackRate(), defaultRate, | ||
'Playback rate is the default one on the player object' | ||
); | ||
player.dispose(); | ||
}); | ||
|
||
QUnit.test('Calling resetVolumeBar player method should reset volume bar', function(assert) { | ||
const player = TestHelpers.makePlayer({ techOrder: ['html5'] }); | ||
|
||
player.volume(0.5); | ||
|
||
player.trigger('volumechange'); | ||
|
||
assert.equal(player.controlBar.volumePanel.volumeControl.volumeBar.el_.getAttribute('aria-valuenow'), 50, 'UI value of VolumeBar is 50'); | ||
|
||
player.resetVolumeBar_(); | ||
|
||
assert.equal(player.controlBar.volumePanel.volumeControl.volumeBar.el_.getAttribute('aria-valuenow'), 100, 'UI value of VolumeBar is 100'); | ||
|
||
player.dispose(); | ||
}); |
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.
these methods should be suffixed with an
_
to show that they're "private" or shouldn't be used directly outside of Video.js.