xgplayer-streaming-shared
Advanced tools
Comparing version 3.0.0-next.16 to 3.0.0-next.16-1
@@ -18,2 +18,3 @@ export namespace ERR { | ||
const MSE_OTHER: string; | ||
const MSE_FULL: string; | ||
const OPTION: string; | ||
@@ -31,2 +32,3 @@ } | ||
MSE_OTHER?: undefined; | ||
MSE_FULL?: undefined; | ||
} | { | ||
@@ -40,2 +42,3 @@ FLV: number; | ||
MSE_OTHER?: undefined; | ||
MSE_FULL?: undefined; | ||
} | { | ||
@@ -49,2 +52,3 @@ FMP4: number; | ||
MSE_OTHER?: undefined; | ||
MSE_FULL?: undefined; | ||
} | { | ||
@@ -54,2 +58,3 @@ MSE_ADD_SB: number; | ||
MSE_OTHER: number; | ||
MSE_FULL: number; | ||
HLS?: undefined; | ||
@@ -56,0 +61,0 @@ FLV?: undefined; |
@@ -20,2 +20,3 @@ import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, wrapNativeSuper as _wrapNativeSuper } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
MSE_OTHER: "MSE_OTHER", | ||
MSE_FULL: "MSE_FULL", | ||
OPTION: "OPTION" | ||
@@ -37,3 +38,4 @@ } | ||
MSE_APPEND_BUFFER: 5201, | ||
MSE_OTHER: 5202 | ||
MSE_OTHER: 5202, | ||
MSE_FULL: 5203 | ||
}), _defineProperty(_ERR_CODE, ERR.OTHER, 8e3), _ERR_CODE); | ||
@@ -40,0 +42,0 @@ var StreamingError = /* @__PURE__ */ function(_Error) { |
@@ -66,2 +66,3 @@ declare var _default: { | ||
MSE_OTHER: string; | ||
MSE_FULL: string; | ||
OPTION: string; | ||
@@ -79,2 +80,3 @@ }; | ||
MSE_OTHER?: undefined; | ||
MSE_FULL?: undefined; | ||
} | { | ||
@@ -88,2 +90,3 @@ FLV: number; | ||
MSE_OTHER?: undefined; | ||
MSE_FULL?: undefined; | ||
} | { | ||
@@ -97,2 +100,3 @@ FMP4: number; | ||
MSE_OTHER?: undefined; | ||
MSE_FULL?: undefined; | ||
} | { | ||
@@ -102,2 +106,3 @@ MSE_ADD_SB: number; | ||
MSE_OTHER: number; | ||
MSE_FULL: number; | ||
HLS?: undefined; | ||
@@ -104,0 +109,0 @@ FLV?: undefined; |
import { defineProperty as _defineProperty, createClass as _createClass, classCallCheck as _classCallCheck } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.function.name.js"; | ||
import "core-js/modules/es.array.concat.js"; | ||
import { nowTime } from "./utils.js"; | ||
var Logger = /* @__PURE__ */ function() { | ||
@@ -19,3 +20,3 @@ function Logger2(name) { | ||
} | ||
(_console = console).debug.apply(_console, [this._prefix].concat(args)); | ||
(_console = console).debug.apply(_console, [this._prefix, nowTime()].concat(args)); | ||
} | ||
@@ -31,3 +32,3 @@ }, { | ||
} | ||
(_console2 = console).log.apply(_console2, [this._prefix].concat(args)); | ||
(_console2 = console).log.apply(_console2, [this._prefix, nowTime()].concat(args)); | ||
} | ||
@@ -43,3 +44,3 @@ }, { | ||
} | ||
(_console3 = console).warn.apply(_console3, [this._prefix].concat(args)); | ||
(_console3 = console).warn.apply(_console3, [this._prefix, nowTime()].concat(args)); | ||
} | ||
@@ -55,3 +56,3 @@ }, { | ||
} | ||
(_console4 = console).error.apply(_console4, [this._prefix].concat(args)); | ||
(_console4 = console).error.apply(_console4, [this._prefix, nowTime()].concat(args)); | ||
} | ||
@@ -58,0 +59,0 @@ }, { |
@@ -17,2 +17,5 @@ export type MSEErrorType = string; | ||
static AUDIO: string; | ||
static getDefaultConfig(): { | ||
openLog: boolean; | ||
}; | ||
/** | ||
@@ -26,3 +29,3 @@ * @param {string} [mime='video/mp4; codecs="avc1.42E01E,mp4a.40.2"'] | ||
*/ | ||
constructor(media?: HTMLMediaElement); | ||
constructor(media?: HTMLMediaElement, config: any); | ||
/** @type { HTMLMediaElement | null } */ | ||
@@ -35,8 +38,17 @@ media: HTMLMediaElement | null; | ||
_sourceBuffer: any; | ||
_mseFullFlag: {}; | ||
_st: number; | ||
_opst: number; | ||
_logger: any; | ||
_config: any; | ||
_url: any; | ||
get isOpened(): boolean; | ||
get url(): any; | ||
get duration(): any; | ||
get isEnded(): boolean; | ||
isFull(type: any): any; | ||
/** | ||
* @param { number } duration | ||
* @return { Promise } | ||
*/ | ||
*/ | ||
updateDuration(duration: number): Promise; | ||
@@ -48,3 +60,3 @@ /** @return { Promise } */ | ||
* @return { Promise } | ||
*/ | ||
*/ | ||
bindMedia(media: HTMLMediaElement): Promise; | ||
@@ -56,3 +68,3 @@ /** @return { Promise } */ | ||
* @param { string } mimeType | ||
*/ | ||
*/ | ||
createSource(type: string, mimeType: string): void; | ||
@@ -63,3 +75,3 @@ /** | ||
* @return { Promise } | ||
*/ | ||
*/ | ||
changeType(type: string, mimeType: string): Promise; | ||
@@ -70,3 +82,3 @@ /** | ||
* @return { Promise } | ||
*/ | ||
*/ | ||
createOrChangeSource(type: string, mimeType: string): Promise; | ||
@@ -77,4 +89,4 @@ /** | ||
* @return { Promise } | ||
*/ | ||
append(type: string, buffer: BufferSource): Promise; | ||
*/ | ||
append(type: string, buffer: BufferSource, context: any): Promise; | ||
/** | ||
@@ -85,6 +97,7 @@ * @param { string } type | ||
* @return { Promise } | ||
*/ | ||
remove(type: string, startTime: number, endTime: number): Promise; | ||
*/ | ||
remove(type: string, startTime: number, endTime: number, context: any): Promise; | ||
clearBuffer(startTime: any, endTime: any): undefined; | ||
clearAllBuffer(): undefined; | ||
clearOpQueues(type: any): void; | ||
/** | ||
@@ -99,3 +112,3 @@ * @param {EndOfStreamError} [reason] | ||
* @return { TimeRanges | void } | ||
*/ | ||
*/ | ||
buffered(type: string): TimeRanges | void; | ||
@@ -105,3 +118,3 @@ /** | ||
* @return { number } | ||
*/ | ||
*/ | ||
bufferStart(type: string): number; | ||
@@ -111,9 +124,12 @@ /** | ||
* @return { number } | ||
*/ | ||
*/ | ||
bufferEnd(type: string): number; | ||
_enqueueOp(type: any, exec: any): any; | ||
_enqueueBlockingOp(exec: any): unknown; | ||
_enqueueOp(type: any, exec: any, opName: any, context: any, isInsertHead: any): any; | ||
_enqueueBlockingOp(exec: any, opName: any): unknown; | ||
_startQueue(type: any): void; | ||
_onSBUpdateEnd: (type: any) => void; | ||
_onSBUpdateError: (type: any, event: any) => void; | ||
setTimeoffset(type: any, timestampOffset: any, context: any): any; | ||
/** *重置decode时间戳 */ | ||
abort(type: any, context: any): any; | ||
} |
213
es/mse.js
import { defineProperty as _defineProperty, inherits as _inherits, createSuper as _createSuper, createClass as _createClass, classCallCheck as _classCallCheck, wrapNativeSuper as _wrapNativeSuper, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "./_virtual/_rollupPluginBabelHelpers.js"; | ||
import "core-js/modules/es.object.assign.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.promise.js"; | ||
import "core-js/modules/es.array.iterator.js"; | ||
import "core-js/modules/es.object.to-string.js"; | ||
import "core-js/modules/es.string.iterator.js"; | ||
@@ -10,8 +12,10 @@ import "core-js/modules/web.dom-collections.iterator.js"; | ||
import "core-js/modules/es.object.keys.js"; | ||
import "core-js/modules/es.promise.js"; | ||
import "core-js/modules/es.array.slice.js"; | ||
import "core-js/modules/es.array.splice.js"; | ||
import "core-js/modules/es.regexp.exec.js"; | ||
import { createPublicPromise } from "./utils.js"; | ||
import { createPublicPromise, nowTime } from "./utils.js"; | ||
import { Buffer } from "./buffer.js"; | ||
import { StreamingError, ERR } from "./error.js"; | ||
import { isBrowser } from "./env.js"; | ||
import { Logger } from "./logger.js"; | ||
function getMediaSource() { | ||
@@ -27,2 +31,6 @@ try { | ||
}; | ||
var OP_NAME = { | ||
APPEND: "appendBuffer", | ||
REMOVE: "removeBuffer" | ||
}; | ||
var MSEError = /* @__PURE__ */ function(_Error) { | ||
@@ -42,3 +50,3 @@ _inherits(MSEError2, _Error); | ||
var MSE = /* @__PURE__ */ function() { | ||
function MSE2(media) { | ||
function MSE2(media, config) { | ||
var _this2 = this; | ||
@@ -51,2 +59,8 @@ _classCallCheck(this, MSE2); | ||
_defineProperty(this, "_sourceBuffer", /* @__PURE__ */ Object.create(null)); | ||
_defineProperty(this, "_mseFullFlag", {}); | ||
_defineProperty(this, "_st", 0); | ||
_defineProperty(this, "_opst", 0); | ||
_defineProperty(this, "_logger", null); | ||
_defineProperty(this, "_config", null); | ||
_defineProperty(this, "_url", null); | ||
_defineProperty(this, "_onSBUpdateEnd", function(type) { | ||
@@ -57,3 +71,9 @@ var queue = _this2._queue[type]; | ||
if (op) { | ||
op.promise.resolve(); | ||
var costtime = nowTime() - _this2._opst; | ||
_this2._logger.debug("UpdateEnd", op.opName, costtime, op.context); | ||
op.promise.resolve({ | ||
name: op.opName, | ||
context: op.context, | ||
costtime | ||
}); | ||
_this2._startQueue(type); | ||
@@ -68,2 +88,3 @@ } | ||
if (op) { | ||
_this2._logger.error("UpdateError", type, op.opName, op.context); | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_APPEND_BUFFER, event)); | ||
@@ -73,4 +94,9 @@ } | ||
}); | ||
this._config = Object.assign(MSE2.getDefaultConfig(), config); | ||
if (media) | ||
this.bindMedia(media); | ||
this._logger = new Logger("MSE"); | ||
if (this._config.openLog) { | ||
Logger.enable(); | ||
} | ||
} | ||
@@ -84,2 +110,7 @@ _createClass(MSE2, [{ | ||
}, { | ||
key: "url", | ||
get: function get() { | ||
return this._url; | ||
} | ||
}, { | ||
key: "duration", | ||
@@ -91,9 +122,28 @@ get: function get() { | ||
}, { | ||
key: "isEnded", | ||
get: function get() { | ||
return this.mediaSource ? this.mediaSource.readyState === "ended" : false; | ||
} | ||
}, { | ||
key: "isFull", | ||
value: function isFull(type) { | ||
return type ? this._mseFullFlag[type] : this._mseFullFlag[MSE2.VIDEO]; | ||
} | ||
}, { | ||
key: "updateDuration", | ||
value: function updateDuration(duration) { | ||
var _this3 = this; | ||
if (this.mediaSource && this.mediaSource.duration > value) { | ||
return Promise.resolve(); | ||
} | ||
return this._enqueueBlockingOp(function() { | ||
if (_this3.mediaSource) | ||
if (_this3.isEnded) { | ||
_this3._logger.debug("[debug mse] setDuration ended"); | ||
return; | ||
} | ||
if (_this3.mediaSource) { | ||
_this3.mediaSource.duration = duration; | ||
}); | ||
_this3._logger.debug("[debug mse] setDuration"); | ||
} | ||
}, "updateDuration"); | ||
} | ||
@@ -107,4 +157,8 @@ }, { | ||
var onOpen = function onOpen2() { | ||
var costtime = nowTime() - _this4._st; | ||
_this4._logger.debug("MSE OPEN", costtime); | ||
ms.removeEventListener("sourceopen", onOpen2); | ||
_this4._openPromise.resolve(); | ||
_this4._openPromise.resolve({ | ||
costtime | ||
}); | ||
}; | ||
@@ -141,11 +195,17 @@ ms.addEventListener("sourceopen", onOpen); | ||
ms = this.mediaSource = new MediaSource(); | ||
media.src = URL.createObjectURL(ms); | ||
this._st = nowTime(); | ||
onOpen = function onOpen2() { | ||
var costtime = nowTime() - _this5._st; | ||
_this5._logger.debug("MSE OPEN"); | ||
ms.removeEventListener("sourceopen", onOpen2); | ||
URL.revokeObjectURL(media.src); | ||
_this5._openPromise.resolve(); | ||
_this5._openPromise.resolve({ | ||
costtime | ||
}); | ||
}; | ||
ms.addEventListener("sourceopen", onOpen); | ||
this._url = URL.createObjectURL(ms); | ||
media.src = this._url; | ||
return _context.abrupt("return", this._openPromise); | ||
case 11: | ||
case 13: | ||
case "end": | ||
@@ -256,3 +316,3 @@ return _context.stop(); | ||
key: "append", | ||
value: function append(type, buffer) { | ||
value: function append(type, buffer, context) { | ||
var _this7 = this; | ||
@@ -268,11 +328,15 @@ if (!buffer || !buffer.byteLength) { | ||
return; | ||
_this7._logger.debug("MSE APPEND START", context); | ||
_this7._opst = nowTime(); | ||
(_this7$_sourceBuffer$ = _this7._sourceBuffer[type]) === null || _this7$_sourceBuffer$ === void 0 ? void 0 : _this7$_sourceBuffer$.appendBuffer(buffer); | ||
}); | ||
}, OP_NAME.APPEND, context); | ||
} | ||
}, { | ||
key: "remove", | ||
value: function remove(type, startTime, endTime) { | ||
value: function remove(type, startTime, endTime, context) { | ||
var _this8 = this; | ||
if (Object.keys(this._sourceBuffer).length === 1) | ||
return Promise.resolve(); | ||
var isInsertHead = false; | ||
if (this._mseFullFlag[type]) { | ||
isInsertHead = true; | ||
} | ||
return this._enqueueOp(type, function() { | ||
@@ -286,4 +350,6 @@ if (!_this8.mediaSource) | ||
} | ||
_this8._opst = nowTime(); | ||
_this8._logger.debug("MSE REMOVE START", type, startTime, endTime, context); | ||
sb.remove(startTime, endTime); | ||
}); | ||
}, OP_NAME.REMOVE, context, isInsertHead); | ||
} | ||
@@ -300,2 +366,3 @@ }, { | ||
var sb = _this9._sourceBuffer[k]; | ||
_this9._logger.debug("MSE clearBuffer START", k, startTime, endTime); | ||
sb.remove(startTime, endTime); | ||
@@ -316,2 +383,3 @@ }); | ||
var sb = _this10._sourceBuffer[k]; | ||
_this10._logger.debug("MSE clearAllBuffer START", k); | ||
sb.remove(0, Buffer.end(Buffer.get(sb))); | ||
@@ -323,2 +391,19 @@ }); | ||
}, { | ||
key: "clearOpQueues", | ||
value: function clearOpQueues(type) { | ||
var _this$_queue$type; | ||
this._logger.debug("MSE clearOpQueue START"); | ||
var queue = this._queue[type]; | ||
if (!queue || !queue[type] || queue.length < 5) | ||
return; | ||
var initOpque = []; | ||
queue.forEach(function(op) { | ||
if (op.context && op.context.isinit) { | ||
initOpque.push(op); | ||
} | ||
}); | ||
this._queue[type] = queue.slice(0, 2); | ||
initOpque.length > 0 && (_this$_queue$type = this._queue[type]).push.apply(_this$_queue$type, initOpque); | ||
} | ||
}, { | ||
key: "endOfStream", | ||
@@ -333,2 +418,3 @@ value: function endOfStream(reason) { | ||
return; | ||
_this11._logger.debug("MSE endOfStream START"); | ||
if (reason) { | ||
@@ -339,3 +425,3 @@ ms.endOfStream(reason); | ||
} | ||
}); | ||
}, "endOfStream"); | ||
} | ||
@@ -367,3 +453,4 @@ }, { | ||
key: "_enqueueOp", | ||
value: function _enqueueOp(type, exec) { | ||
value: function _enqueueOp(type, exec, opName, context, isInsertHead) { | ||
var _this12 = this; | ||
if (!this.mediaSource) | ||
@@ -374,8 +461,24 @@ return Promise.resolve(); | ||
exec, | ||
promise: createPublicPromise() | ||
promise: createPublicPromise(), | ||
opName, | ||
context | ||
}; | ||
queue.push(op); | ||
if (queue.length === 1) { | ||
if (isInsertHead) { | ||
queue.splice(0, 0, op); | ||
this._mseFullFlag[type] = false; | ||
this._startQueue(type); | ||
} else { | ||
queue.push(op); | ||
} | ||
if (this.isOpened) { | ||
if (queue.length === 1) { | ||
this._startQueue(type); | ||
} | ||
} else { | ||
this._openPromise.then(function() { | ||
if (queue.length === 1) { | ||
_this12._startQueue(type); | ||
} | ||
}); | ||
} | ||
return op.promise; | ||
@@ -386,4 +489,4 @@ } | ||
value: function() { | ||
var _enqueueBlockingOp2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(exec) { | ||
var _this12 = this; | ||
var _enqueueBlockingOp2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(exec, opName) { | ||
var _this13 = this; | ||
var types, waiters; | ||
@@ -409,3 +512,3 @@ return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
types.forEach(function(t) { | ||
var queue = _this12._queue[t]; | ||
var queue = _this13._queue[t]; | ||
var prom = createPublicPromise(); | ||
@@ -417,6 +520,7 @@ waiters.push(prom); | ||
}, | ||
promise: prom | ||
promise: prom, | ||
opName | ||
}); | ||
if (queue.length === 1) { | ||
_this12._startQueue(t); | ||
_this13._startQueue(t); | ||
} | ||
@@ -429,7 +533,7 @@ }); | ||
types.forEach(function(t) { | ||
var queue = _this12._queue[t]; | ||
var sb = _this12._sourceBuffer[t]; | ||
var queue = _this13._queue[t]; | ||
var sb = _this13._sourceBuffer[t]; | ||
queue === null || queue === void 0 ? void 0 : queue.shift(); | ||
if (!sb || !sb.updating) { | ||
_this12._startQueue(t); | ||
_this13._startQueue(t); | ||
} | ||
@@ -446,3 +550,3 @@ }); | ||
})); | ||
function _enqueueBlockingOp(_x2) { | ||
function _enqueueBlockingOp(_x2, _x3) { | ||
return _enqueueBlockingOp2.apply(this, arguments); | ||
@@ -458,9 +562,16 @@ } | ||
var op = queue[0]; | ||
if (op) { | ||
if (op && !this._mseFullFlag[type]) { | ||
try { | ||
op.exec(); | ||
} catch (error) { | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error)); | ||
queue.shift(); | ||
this._startQueue(type); | ||
if (error && error.message && error.message.indexOf("SourceBuffer is full") >= 0) { | ||
this._mseFullFlag[type] = true; | ||
this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full"); | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_FULL, error)); | ||
} else { | ||
this._logger.error(error); | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error)); | ||
queue.shift(); | ||
this._startQueue(type); | ||
} | ||
} | ||
@@ -470,3 +581,34 @@ } | ||
} | ||
}, { | ||
key: "setTimeoffset", | ||
value: function setTimeoffset(type, timestampOffset, context) { | ||
var _this14 = this; | ||
return this._enqueueOp(type, function() { | ||
if (timestampOffset < 0) { | ||
timestampOffset += 1e-3; | ||
} | ||
_this14._sourceBuffer[type].timestampOffset = timestampOffset; | ||
_this14._onSBUpdateEnd(type); | ||
}, "setTimeoffset", context); | ||
} | ||
}, { | ||
key: "abort", | ||
value: function abort(type, context) { | ||
var _this15 = this; | ||
if (!this.isOpened) { | ||
return Promise.resolve(); | ||
} | ||
return this._enqueueOp(type, function() { | ||
_this15._sourceBuffer[type].abort(); | ||
_this15._onSBUpdateEnd(type); | ||
}, "abort", context); | ||
} | ||
}], [{ | ||
key: "getDefaultConfig", | ||
value: function getDefaultConfig() { | ||
return { | ||
openLog: false | ||
}; | ||
} | ||
}, { | ||
key: "isSupported", | ||
@@ -480,2 +622,3 @@ value: function isSupported() { | ||
} catch (error) { | ||
this._logger.error(mime, error); | ||
return false; | ||
@@ -482,0 +625,0 @@ } |
@@ -15,3 +15,4 @@ export class FetchLoader { | ||
_onProcessMinLen: number; | ||
load({ url, vid, timeout, responseType, onProgress, index, onTimeout, range, transformResponse, request, params, logger, method, headers, body, mode, credentials, cache, redirect, referrer, referrerPolicy, onProcessMinLen }: { | ||
_onCancel: any; | ||
load({ url, vid, timeout, responseType, onProgress, index, onTimeout, onCancel, range, transformResponse, request, params, logger, method, headers, body, mode, credentials, cache, redirect, referrer, referrerPolicy, onProcessMinLen }: { | ||
url: any; | ||
@@ -24,2 +25,3 @@ vid: any; | ||
onTimeout: any; | ||
onCancel: any; | ||
range: any; | ||
@@ -26,0 +28,0 @@ transformResponse: any; |
@@ -58,2 +58,3 @@ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
_defineProperty(_assertThisInitialized(_this), "_onProcessMinLen", 0); | ||
_defineProperty(_assertThisInitialized(_this), "_onCancel", null); | ||
return _this; | ||
@@ -65,6 +66,7 @@ } | ||
var _this$_abortControlle, _this2 = this; | ||
var url = _ref.url, vid = _ref.vid, timeout = _ref.timeout, responseType = _ref.responseType, onProgress = _ref.onProgress, index = _ref.index, onTimeout = _ref.onTimeout, range = _ref.range, transformResponse = _ref.transformResponse, request = _ref.request, params = _ref.params, logger = _ref.logger, method = _ref.method, headers = _ref.headers, body = _ref.body, mode = _ref.mode, credentials = _ref.credentials, cache = _ref.cache, redirect = _ref.redirect, referrer = _ref.referrer, referrerPolicy = _ref.referrerPolicy, onProcessMinLen = _ref.onProcessMinLen; | ||
var url = _ref.url, vid = _ref.vid, timeout = _ref.timeout, responseType = _ref.responseType, onProgress = _ref.onProgress, index = _ref.index, onTimeout = _ref.onTimeout, onCancel = _ref.onCancel, range = _ref.range, transformResponse = _ref.transformResponse, request = _ref.request, params = _ref.params, logger = _ref.logger, method = _ref.method, headers = _ref.headers, body = _ref.body, mode = _ref.mode, credentials = _ref.credentials, cache = _ref.cache, redirect = _ref.redirect, referrer = _ref.referrer, referrerPolicy = _ref.referrerPolicy, onProcessMinLen = _ref.onProcessMinLen; | ||
this._logger = logger; | ||
this._aborted = false; | ||
this._onProcessMinLen = onProcessMinLen; | ||
this._onCancel = onCancel; | ||
this._abortController = typeof AbortController !== "undefined" && new AbortController(); | ||
@@ -110,3 +112,3 @@ this._running = true; | ||
error.isTimeout = true; | ||
onTimeout(error); | ||
onTimeout(error, _this2._index); | ||
} | ||
@@ -256,3 +258,6 @@ }, timeout); | ||
} | ||
case 15: | ||
if (this._onCancel) { | ||
this._onCancel(this._index); | ||
} | ||
case 16: | ||
case "end": | ||
@@ -259,0 +264,0 @@ return _context2.stop(); |
@@ -27,2 +27,3 @@ export class XhrLoader { | ||
_subRangeStartTime: any; | ||
_onCancel: any; | ||
load(req: any): any; | ||
@@ -29,0 +30,0 @@ _onTimeout: any; |
@@ -74,2 +74,3 @@ import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectSpread2 as _objectSpread2, get as _get, getPrototypeOf as _getPrototypeOf, createForOfIteratorHelper as _createForOfIteratorHelper } from "../_virtual/_rollupPluginBabelHelpers.js"; | ||
_defineProperty(_assertThisInitialized(_this), "_subRangeStartTime", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "_onCancel", null); | ||
return _this; | ||
@@ -94,2 +95,3 @@ } | ||
this._onTimeout = req.onTimeout; | ||
this._onCancel = req.onCancel; | ||
this._request = req.request; | ||
@@ -160,3 +162,3 @@ this._credentials = req.credentials; | ||
error.isTimeout = true; | ||
_this3._onTimeout(error); | ||
_this3._onTimeout(error, _this3._index); | ||
} | ||
@@ -259,2 +261,5 @@ _this3._loadCompleteReject(event); | ||
_get(_getPrototypeOf(XhrLoader2.prototype), "removeAllListeners", this).call(this); | ||
if (this._onCancel) { | ||
this._onCancel(this._index); | ||
} | ||
if (this._xhr) { | ||
@@ -261,0 +266,0 @@ return this._xhr.abort(); |
export function createPublicPromise(): any; | ||
export function nowTime(): any; |
@@ -20,2 +20,9 @@ import "core-js/modules/es.object.to-string.js"; | ||
} | ||
export { createPublicPromise }; | ||
function nowTime() { | ||
try { | ||
return parseInt(performance.now(), 10); | ||
} catch (e) { | ||
return new Date().getTime(); | ||
} | ||
} | ||
export { createPublicPromise, nowTime }; |
{ | ||
"name": "xgplayer-streaming-shared", | ||
"version": "3.0.0-next.16", | ||
"version": "3.0.0-next.16-1", | ||
"main": "dist/index.min.js", | ||
@@ -5,0 +5,0 @@ "module": "es/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
775358
4121