Skip to content

Commit

Permalink
refactor: use Fn.UPDATE_REFRESH_INTERVAL in seekBar & liveTracker (#6407
Browse files Browse the repository at this point in the history
)

Follow up from #6142 to include a couple of other uses.
  • Loading branch information
brandonocasey authored and gkatsev committed Jan 15, 2020
1 parent 9bb7acb commit bcaa869
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
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

0 comments on commit bcaa869

Please sign in to comment.