b416adc6 by Gary Katsevman

add a cancelKeyXhr akin to cancelSegmentXhr

1 parent 0154b51f
...@@ -138,8 +138,7 @@ videojs.Hls.prototype.handleSourceOpen = function() { ...@@ -138,8 +138,7 @@ videojs.Hls.prototype.handleSourceOpen = function() {
138 this.playlists.on('mediachange', videojs.bind(this, function() { 138 this.playlists.on('mediachange', videojs.bind(this, function() {
139 // abort outstanding key requests and check if new keys need to be retrieved 139 // abort outstanding key requests and check if new keys need to be retrieved
140 if (keyXhr) { 140 if (keyXhr) {
141 keyXhr.abort(); 141 this.cancelKeyXhr();
142 keyXhr = null;
143 this.fetchKeys(this.playlists.media(), this.mediaIndex); 142 this.fetchKeys(this.playlists.media(), this.mediaIndex);
144 } 143 }
145 144
...@@ -200,8 +199,7 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) { ...@@ -200,8 +199,7 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) {
200 // fetch new encryption keys, if necessary 199 // fetch new encryption keys, if necessary
201 if (keyXhr) { 200 if (keyXhr) {
202 keyXhr.aborted = true; 201 keyXhr.aborted = true;
203 keyXhr.abort(); 202 this.cancelKeyXhr();
204 keyXhr = null;
205 this.fetchKeys(this.playlists.media(), this.mediaIndex); 203 this.fetchKeys(this.playlists.media(), this.mediaIndex);
206 } 204 }
207 205
...@@ -241,15 +239,19 @@ videojs.Hls.prototype.updateDuration = function(playlist) { ...@@ -241,15 +239,19 @@ videojs.Hls.prototype.updateDuration = function(playlist) {
241 */ 239 */
242 videojs.Hls.prototype.resetSrc_ = function() { 240 videojs.Hls.prototype.resetSrc_ = function() {
243 this.cancelSegmentXhr(); 241 this.cancelSegmentXhr();
242 this.cancelKeyXhr();
243
244 if (this.sourceBuffer) {
245 this.sourceBuffer.abort();
246 }
247 };
244 248
249 videojs.Hls.prototype.cancelKeyXhr = function() {
245 if (keyXhr) { 250 if (keyXhr) {
246 keyXhr.onreadystatechange = null; 251 keyXhr.onreadystatechange = null;
247 keyXhr.abort(); 252 keyXhr.abort();
248 keyXhr = null; 253 keyXhr = null;
249 } 254 }
250 if (this.sourceBuffer) {
251 this.sourceBuffer.abort();
252 }
253 }; 255 };
254 256
255 videojs.Hls.prototype.cancelSegmentXhr = function() { 257 videojs.Hls.prototype.cancelSegmentXhr = function() {
......