0154b51f by Benjamin Peterson Committed by Gary Katsevman

prevent the segment xhr error handler from being called during seek

When an XHR is aborted, the error handler is called. The error handler for the
segment loader increments the mediaIndex of the player. This is undesired
because setCurrentTime has already set the mediaIndex to the proper target
segment.
1 parent 180f73e0
......@@ -195,11 +195,7 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) {
this.sourceBuffer.abort();
// cancel outstanding requests and buffer appends
if (this.segmentXhr_) {
this.segmentXhr_.onreadystatechange = null;
this.segmentXhr_.abort();
this.segmentXhr_ = null;
}
this.cancelSegmentXhr();
// fetch new encryption keys, if necessary
if (keyXhr) {
......@@ -244,11 +240,8 @@ videojs.Hls.prototype.updateDuration = function(playlist) {
* state suitable for switching to a different video.
*/
videojs.Hls.prototype.resetSrc_ = function() {
if (this.segmentXhr_) {
this.segmentXhr_.onreadystatechange = null;
this.segmentXhr_.abort();
this.segmentXhr_ = null;
}
this.cancelSegmentXhr();
if (keyXhr) {
keyXhr.onreadystatechange = null;
keyXhr.abort();
......@@ -259,6 +252,15 @@ videojs.Hls.prototype.resetSrc_ = function() {
}
};
videojs.Hls.prototype.cancelSegmentXhr = function() {
if (this.segmentXhr_) {
// Prevent error handler from running.
this.segmentXhr_.onreadystatechange = null;
this.segmentXhr_.abort();
this.segmentXhr_ = null;
}
};
/**
* Abort all outstanding work and cleanup.
*/
......