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.
Showing
1 changed file
with
12 additions
and
10 deletions
... | @@ -195,11 +195,7 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) { | ... | @@ -195,11 +195,7 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) { |
195 | this.sourceBuffer.abort(); | 195 | this.sourceBuffer.abort(); |
196 | 196 | ||
197 | // cancel outstanding requests and buffer appends | 197 | // cancel outstanding requests and buffer appends |
198 | if (this.segmentXhr_) { | 198 | this.cancelSegmentXhr(); |
199 | this.segmentXhr_.onreadystatechange = null; | ||
200 | this.segmentXhr_.abort(); | ||
201 | this.segmentXhr_ = null; | ||
202 | } | ||
203 | 199 | ||
204 | // fetch new encryption keys, if necessary | 200 | // fetch new encryption keys, if necessary |
205 | if (keyXhr) { | 201 | if (keyXhr) { |
... | @@ -244,11 +240,8 @@ videojs.Hls.prototype.updateDuration = function(playlist) { | ... | @@ -244,11 +240,8 @@ videojs.Hls.prototype.updateDuration = function(playlist) { |
244 | * state suitable for switching to a different video. | 240 | * state suitable for switching to a different video. |
245 | */ | 241 | */ |
246 | videojs.Hls.prototype.resetSrc_ = function() { | 242 | videojs.Hls.prototype.resetSrc_ = function() { |
247 | if (this.segmentXhr_) { | 243 | this.cancelSegmentXhr(); |
248 | this.segmentXhr_.onreadystatechange = null; | 244 | |
249 | this.segmentXhr_.abort(); | ||
250 | this.segmentXhr_ = null; | ||
251 | } | ||
252 | if (keyXhr) { | 245 | if (keyXhr) { |
253 | keyXhr.onreadystatechange = null; | 246 | keyXhr.onreadystatechange = null; |
254 | keyXhr.abort(); | 247 | keyXhr.abort(); |
... | @@ -259,6 +252,15 @@ videojs.Hls.prototype.resetSrc_ = function() { | ... | @@ -259,6 +252,15 @@ videojs.Hls.prototype.resetSrc_ = function() { |
259 | } | 252 | } |
260 | }; | 253 | }; |
261 | 254 | ||
255 | videojs.Hls.prototype.cancelSegmentXhr = function() { | ||
256 | if (this.segmentXhr_) { | ||
257 | // Prevent error handler from running. | ||
258 | this.segmentXhr_.onreadystatechange = null; | ||
259 | this.segmentXhr_.abort(); | ||
260 | this.segmentXhr_ = null; | ||
261 | } | ||
262 | }; | ||
263 | |||
262 | /** | 264 | /** |
263 | * Abort all outstanding work and cleanup. | 265 | * Abort all outstanding work and cleanup. |
264 | */ | 266 | */ | ... | ... |
-
Please register or sign in to post a comment