c0d2ed06 by Gary Katsevman

convert segmentXHR to use xhr helper

1 parent 64547ed3
......@@ -639,31 +639,24 @@ var
}
// request the next segment
segmentXhr = new window.XMLHttpRequest();
segmentXhr.open('GET', segmentUri);
segmentXhr.responseType = 'arraybuffer';
segmentXhr.onreadystatechange = function() {
// wait until the request completes
if (this.readyState !== 4) {
return;
}
segmentXhr = xhr({
url: segmentUri,
responseType: 'arraybuffer'
}, function(error, url) {
// the segment request is no longer outstanding
segmentXhr = null;
// trigger an error if the request was not successful
if (this.status >= 400) {
if (error) {
player.hls.error = {
status: this.status,
message: 'HLS segment request error at URL: ' + segmentUri,
message: 'HLS segment request error at URL: ' + url,
code: (this.status >= 500) ? 4 : 2
};
// try moving on to the next segment
player.hls.mediaIndex++;
return;
}
} else {
// stop processing if the request was aborted
if (!this.response) {
return;
......@@ -698,9 +691,10 @@ var
// figure out what stream the next segment should be downloaded from
// with the updated bandwidth information
updateCurrentPlaylist();
};
}
});
startTime = +new Date();
segmentXhr.send(null);
};
// load the MediaSource into the player
......