Skip to content
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

refactor: use Fn.UPDATE_REFRESH_INTERVAL in seekBar & liveTracker #6407

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/js/control-bar/progress-control/seek-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const STEP_SECONDS = 5;
// The multiplier of STEP_SECONDS that PgUp/PgDown move the timeline.
const PAGE_KEY_MULTIPLIER = 12;

// The interval at which the bar should update as it progresses.
const UPDATE_REFRESH_INTERVAL = 30;

/**
* Seek bar and container for the progress bars. Uses {@link PlayProgressBar}
* as its `bar`.
Expand Down Expand Up @@ -53,7 +50,7 @@ class SeekBar extends Slider {
*/
setEventHandlers_() {
this.update_ = Fn.bind(this, this.update);
this.update = Fn.throttle(this.update_, UPDATE_REFRESH_INTERVAL);
this.update = Fn.throttle(this.update_, Fn.UPDATE_REFRESH_INTERVAL);

this.on(this.player_, ['ended', 'durationchange', 'timeupdate'], this.update);
if (this.player_.liveTracker) {
Expand Down Expand Up @@ -91,7 +88,7 @@ class SeekBar extends Slider {
return;

}
this.updateInterval = this.setInterval(this.update, UPDATE_REFRESH_INTERVAL);
this.updateInterval = this.setInterval(this.update, Fn.UPDATE_REFRESH_INTERVAL);
}

disableInterval_(e) {
Expand Down
3 changes: 2 additions & 1 deletion src/js/live-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import median from './utils/median.js';
import mergeOptions from './utils/merge-options.js';
import document from 'global/document';
import * as browser from './utils/browser.js';
import * as Fn from './utils/fn.js';

/* track when we are at the live edge, and other helpers for live playback */
class LiveTracker extends Component {
Expand Down Expand Up @@ -129,7 +130,7 @@ class LiveTracker extends Component {
this.timeupdateSeen_ = this.player_.hasStarted();
}

this.trackingInterval_ = this.setInterval(this.trackLive_, 30);
this.trackingInterval_ = this.setInterval(this.trackLive_, Fn.UPDATE_REFRESH_INTERVAL);
this.trackLive_();

this.on(this.player_, 'play', this.trackLive_);
Expand Down