Skip to content

Commit ec33990

Browse files
authored
fix: prevent current time display showing 0:00 during seek (#9135)
1 parent d203eab commit ec33990

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/js/control-bar/time-controls/current-time-display.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CurrentTimeDisplay extends TimeDisplay {
3535

3636
if (this.player_.ended()) {
3737
time = this.player_.duration();
38-
} else if (event && event.target && typeof event.target.pendingSeekTime === 'function') {
38+
} else if (event && event.target && typeof event.target.pendingSeekTime === 'function' && event.target.pendingSeekTime() !== null) {
3939
time = event.target.pendingSeekTime();
4040
} else {
4141
time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();

test/unit/controls.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,28 @@ QUnit.test('Remaing time negative sign can be optional', function(assert) {
681681
player.dispose();
682682
});
683683

684+
QUnit.test('Current time display shouldn\'t flash zero on seek', function(assert) {
685+
const player = TestHelpers.makePlayer({ techOrder: ['html5'] });
686+
const currentTimeDisplay = player.controlBar.currentTimeDisplay;
687+
const spy = sinon.spy(currentTimeDisplay, 'updateTextNode_');
688+
689+
player.ended = () => false;
690+
player.currentTime = () => 10;
691+
692+
currentTimeDisplay.updateContent({
693+
target: {
694+
pendingSeekTime: () => null
695+
}
696+
});
697+
698+
this.clock.tick(1);
699+
700+
assert.ok(spy.calledWith(10), 'control was updated with currentTime');
701+
assert.notOk(spy.calledWith(null), 'control was not updated with null');
702+
assert.notStrictEqual(currentTimeDisplay.formattedTime_, '0:00', 'display text not set to 0:00');
703+
704+
});
705+
684706
QUnit.module('SmartTV UI Updates (Progress Bar & Time Display)', function(hooks) {
685707
let player;
686708
let seekBar;

0 commit comments

Comments
 (0)