1
0
mirror of https://github.com/videojs/video.js.git synced 2025-04-13 11:50:49 +02:00

Don't track progress until ready

Delay manual progress checks until the tech is ready to avoid errors.
The Flash tech errors if buffered() is called before the SWF has loaded,
for instance.

closes 
fixes 
rel 
This commit is contained in:
David LaPalomento 2015-07-07 14:35:17 -04:00 committed by heff
parent f9316fcda0
commit ccd6ed44b8
3 changed files with 31 additions and 17 deletions
CHANGELOG.md
src/js/tech
test/unit/tech

@ -59,6 +59,7 @@ CHANGELOG
* @mboles updated JSDoc comments everywhere to prepare for new docs ([view](https://github.com/videojs/video.js/pull/2270)) * @mboles updated JSDoc comments everywhere to prepare for new docs ([view](https://github.com/videojs/video.js/pull/2270))
* @mmcc added a currentTime tooltip to the progress handle ([view](https://github.com/videojs/video.js/pull/2255)) * @mmcc added a currentTime tooltip to the progress handle ([view](https://github.com/videojs/video.js/pull/2255))
* @pavelhoral fixed subclassing without a constructor ([view](https://github.com/videojs/video.js/pull/2308)) * @pavelhoral fixed subclassing without a constructor ([view](https://github.com/videojs/video.js/pull/2308))
* @dmlap fixed a vjs_getProperty error caused by a progress check before the swf was ready ([view](https://github.com/videojs/video.js/pull/2316))
-------------------- --------------------

@ -105,7 +105,7 @@ class Tech extends Component {
this.manualProgress = true; this.manualProgress = true;
// Trigger progress watching when a source begins loading // Trigger progress watching when a source begins loading
this.trackProgress(); this.one('ready', this.trackProgress);
} }
/** /**
@ -126,6 +126,7 @@ class Tech extends Component {
* @method trackProgress * @method trackProgress
*/ */
trackProgress() { trackProgress() {
this.stopTrackingProgress();
this.progressInterval = this.setInterval(Fn.bind(this, function(){ this.progressInterval = this.setInterval(Fn.bind(this, function(){
// Don't trigger unless buffered amount is greater than last time // Don't trigger unless buffered amount is greater than last time

@ -61,14 +61,26 @@ test('stops manual timeupdates while paused', function() {
}); });
test('should synthesize progress events by default', function() { test('should synthesize progress events by default', function() {
var progresses = 0, tech; var progresses = 0, bufferedPercent = 0.5, tech;
tech = new Tech(); tech = new Tech();
tech.on('progress', function() { tech.on('progress', function() {
progresses++; progresses++;
}); });
tech.bufferedPercent = function() {
return bufferedPercent;
};
this.clock.tick(500);
equal(progresses, 0, 'waits until ready');
tech.trigger('ready');
this.clock.tick(500); this.clock.tick(500);
equal(progresses, 1, 'triggered one event'); equal(progresses, 1, 'triggered one event');
tech.trigger('ready');
bufferedPercent = 0.75;
this.clock.tick(500);
equal(progresses, 2, 'repeated readies are ok');
}); });
test('dispose() should stop time tracking', function() { test('dispose() should stop time tracking', function() {