in 2020/lib/mse/msutil.js [201:244]
this.init = function(t, cb) {
this.initLength = forceSize || 32 * 1024;
if (!cb) {
if (!this.initBuf)
throw 'Calling init synchronusly when the init seg is not ready';
return this.initBuf;
}
if (this.initBuf) {
timeoutManager.setTimeout(cb.bind(this, this.initBuf), 1);
}
else {
var self = this;
var fileExtPattern = /\.(webm|mp4)$/;
var extResult = fileExtPattern.exec(this.path)[1];
if (extResult !== 'mp4' && extResult !== 'webm') {
throw 'File extension "' + extResult + '" not supported!';
}
var xhr = xhrManager.createRequest(this.path, function(e) {
self.segs = null;
var response = this.getResponseData();
if (extResult === 'mp4') {
self.segs = parseMp4(response);
} else {
if (!!self.forceSize) {
self.segs = parseWebM(response.buffer, self.forceSize);
} else {
self.segs = parseWebM(response.buffer);
}
}
self.startIndex = self.startIndex || 0;
self.endIndex = self.endIndex || self.segs.length - 1;
self.endIndex = Math.min(self.endIndex, self.segs.length - 1);
self.startIndex = Math.min(self.startIndex, self.endIndex);
self.segIndex = self.startIndex;
xhr = xhrManager.createRequest(self.path, function(e) {
self.initBuf = this.getResponseData();
cb.call(self, self.initBuf);
}, 0, self.segs[0].offset);
xhr.send();
}, 0, self.initLength);
xhr.send();
}
};