mirror of
https://github.com/videojs/video.js.git
synced 2025-03-29 22:07:10 +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 #2316 fixes #2288 rel #2289
This commit is contained in:
parent
f9316fcda0
commit
ccd6ed44b8
@ -59,6 +59,7 @@ CHANGELOG
|
||||
* @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))
|
||||
* @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))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -95,7 +95,7 @@ class Tech extends Component {
|
||||
// Manually trigger progress events based on changes to the buffered amount
|
||||
// Many flash players and older HTML5 browsers don't send progress or progress-like events
|
||||
/**
|
||||
* Turn on progress events
|
||||
* Turn on progress events
|
||||
*
|
||||
* @method manualProgressOn
|
||||
*/
|
||||
@ -105,11 +105,11 @@ class Tech extends Component {
|
||||
this.manualProgress = true;
|
||||
|
||||
// Trigger progress watching when a source begins loading
|
||||
this.trackProgress();
|
||||
this.one('ready', this.trackProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off progress events
|
||||
* Turn off progress events
|
||||
*
|
||||
* @method manualProgressOff
|
||||
*/
|
||||
@ -121,11 +121,12 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Track progress
|
||||
* Track progress
|
||||
*
|
||||
* @method trackProgress
|
||||
*/
|
||||
trackProgress() {
|
||||
this.stopTrackingProgress();
|
||||
this.progressInterval = this.setInterval(Fn.bind(this, function(){
|
||||
// Don't trigger unless buffered amount is greater than last time
|
||||
|
||||
@ -144,7 +145,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update duration
|
||||
* Update duration
|
||||
*
|
||||
* @method onDurationChange
|
||||
*/
|
||||
@ -153,7 +154,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and get TimeRange object for buffering
|
||||
* Create and get TimeRange object for buffering
|
||||
*
|
||||
* @return {TimeRangeObject}
|
||||
* @method buffered
|
||||
@ -173,7 +174,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops tracking progress by clearing progress interval
|
||||
* Stops tracking progress by clearing progress interval
|
||||
*
|
||||
* @method stopTrackingProgress
|
||||
*/
|
||||
@ -246,7 +247,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current time
|
||||
* Set current time
|
||||
*
|
||||
* @method setCurrentTime
|
||||
*/
|
||||
@ -256,7 +257,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize texttrack listeners
|
||||
* Initialize texttrack listeners
|
||||
*
|
||||
* @method initTextTrackListeners
|
||||
*/
|
||||
@ -279,7 +280,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emulate texttracks
|
||||
* Emulate texttracks
|
||||
*
|
||||
* @method emulateTextTracks
|
||||
*/
|
||||
@ -324,7 +325,7 @@ class Tech extends Component {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get texttracks
|
||||
* Get texttracks
|
||||
*
|
||||
* @returns {TextTrackList}
|
||||
* @method textTracks
|
||||
@ -335,7 +336,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get remote texttracks
|
||||
* Get remote texttracks
|
||||
*
|
||||
* @returns {TextTrackList}
|
||||
* @method remoteTextTracks
|
||||
@ -346,7 +347,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a remote text track object
|
||||
* Creates and returns a remote text track object
|
||||
*
|
||||
* @param {String} kind Text track kind (subtitles, captions, descriptions
|
||||
* chapters and metadata)
|
||||
@ -364,7 +365,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a remote text track object
|
||||
* Creates and returns a remote text track object
|
||||
*
|
||||
* @param {Object} options The object should contain values for
|
||||
* kind, language, label and src (location of the WebVTT file)
|
||||
@ -380,7 +381,7 @@ class Tech extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove remote texttrack
|
||||
* Remove remote texttrack
|
||||
*
|
||||
* @param {TextTrackObject} track Texttrack to remove
|
||||
* @method removeRemoteTextTrack
|
||||
@ -442,7 +443,7 @@ Tech.prototype.featuresTimeupdateEvents = false;
|
||||
Tech.prototype.featuresNativeTextTracks = false;
|
||||
|
||||
/*
|
||||
* A functional mixin for techs that want to use the Source Handler pattern.
|
||||
* A functional mixin for techs that want to use the Source Handler pattern.
|
||||
*
|
||||
* ##### EXAMPLE:
|
||||
*
|
||||
|
@ -61,14 +61,26 @@ test('stops manual timeupdates while paused', function() {
|
||||
});
|
||||
|
||||
test('should synthesize progress events by default', function() {
|
||||
var progresses = 0, tech;
|
||||
var progresses = 0, bufferedPercent = 0.5, tech;
|
||||
tech = new Tech();
|
||||
tech.on('progress', function() {
|
||||
progresses++;
|
||||
});
|
||||
tech.bufferedPercent = function() {
|
||||
return bufferedPercent;
|
||||
};
|
||||
|
||||
this.clock.tick(500);
|
||||
equal(progresses, 0, 'waits until ready');
|
||||
|
||||
tech.trigger('ready');
|
||||
this.clock.tick(500);
|
||||
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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user