xgplayer-streaming-shared
Advanced tools
Comparing version 3.0.0-next.2-1 to 3.0.0-next.9-1
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
@@ -158,3 +159,3 @@ var Buffer = /*#__PURE__*/function () { | ||
remaining: end ? end - pos : 0, | ||
length: Buffer.length(buffers) | ||
length: Buffer.length && Buffer.length(buffers) | ||
}; | ||
@@ -161,0 +162,0 @@ } |
export namespace ERR { | ||
const MANIFEST: string; | ||
const NETWORK: string; | ||
const NETWORK_TIMEOUT: string; | ||
const OPTION: string; | ||
const M3U8: string; | ||
const DEMUX: string; | ||
const REMUX: string; | ||
const MSE: string; | ||
const DECRYPT: string; | ||
const MEDIA: string; | ||
const DRM: string; | ||
const OTHER: string; | ||
namespace SUB_TYPES { | ||
const FLV: string; | ||
const HLS: string; | ||
const MP4: string; | ||
const FMP4: string; | ||
const MSE_ADD_SB: string; | ||
const MSE_APPEND_BUFFER: string; | ||
const MSE_OTHER: string; | ||
const OPTION: string; | ||
} | ||
} | ||
export const ERR_CODE: { | ||
[x: string]: number; | ||
[x: string]: number | { | ||
HLS: number; | ||
FLV?: undefined; | ||
MP4?: undefined; | ||
FMP4?: undefined; | ||
MSE_ADD_SB?: undefined; | ||
MSE_APPEND_BUFFER?: undefined; | ||
MSE_OTHER?: undefined; | ||
} | { | ||
FLV: number; | ||
HLS: number; | ||
MP4: number; | ||
FMP4: number; | ||
MSE_ADD_SB?: undefined; | ||
MSE_APPEND_BUFFER?: undefined; | ||
MSE_OTHER?: undefined; | ||
} | { | ||
FMP4: number; | ||
MP4: number; | ||
HLS?: undefined; | ||
FLV?: undefined; | ||
MSE_ADD_SB?: undefined; | ||
MSE_APPEND_BUFFER?: undefined; | ||
MSE_OTHER?: undefined; | ||
} | { | ||
MSE_ADD_SB: number; | ||
MSE_APPEND_BUFFER: number; | ||
MSE_OTHER: number; | ||
HLS?: undefined; | ||
FLV?: undefined; | ||
MP4?: undefined; | ||
FMP4?: undefined; | ||
}; | ||
}; | ||
export class StreamingError extends Error { | ||
static create(type: any, origin: any, payload: any, msg: any): StreamingError; | ||
static create(type: any, subType: any, origin: any, payload: any, msg: any): StreamingError; | ||
static network(error: any): StreamingError; | ||
constructor(type: any, origin: any, payload: any, msg: any); | ||
constructor(type: any, subType: any, origin: any, payload: any, msg: any); | ||
errorType: any; | ||
originError: any; | ||
ext: any; | ||
errorCode: number; | ||
errorCode: any; | ||
errorMessage: string; | ||
} |
@@ -0,1 +1,2 @@ | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.reflect.construct.js'; | ||
@@ -17,13 +18,36 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
var ERR = { | ||
MANIFEST: 'manifest', | ||
NETWORK: 'network', | ||
NETWORK_TIMEOUT: 'network_timeout', | ||
OPTION: 'option', | ||
M3U8: 'm3u8', | ||
DEMUX: 'demux', | ||
REMUX: 'remux', | ||
MSE: 'mse', | ||
DECRYPT: 'decrypt', | ||
OTHER: 'other' | ||
MEDIA: 'media', | ||
DRM: 'drm', | ||
OTHER: 'other', | ||
SUB_TYPES: { | ||
FLV: 'FLV', | ||
HLS: 'HLS', | ||
MP4: 'MP4', | ||
FMP4: 'FMP4', | ||
MSE_ADD_SB: 'MSE_ADD_SB', | ||
MSE_APPEND_BUFFER: 'MSE_APPEND_BUFFER', | ||
MSE_OTHER: 'MSE_OTHER', | ||
OPTION: 'OPTION' | ||
} | ||
}; | ||
var ERR_CODE = (_ERR_CODE = {}, _defineProperty(_ERR_CODE, ERR.OPTION, 500), _defineProperty(_ERR_CODE, ERR.NETWORK, 600), _defineProperty(_ERR_CODE, ERR.NETWORK_TIMEOUT, 601), _defineProperty(_ERR_CODE, ERR.M3U8, 900), _defineProperty(_ERR_CODE, ERR.DEMUX, 700), _defineProperty(_ERR_CODE, ERR.DECRYPT, 701), _defineProperty(_ERR_CODE, ERR.REMUX, 800), _defineProperty(_ERR_CODE, ERR.MSE, 1000), _defineProperty(_ERR_CODE, ERR.OTHER, 999), _ERR_CODE); | ||
var ERR_CODE = (_ERR_CODE = {}, _defineProperty(_ERR_CODE, ERR.MANIFEST, { | ||
HLS: 1100 | ||
}), _defineProperty(_ERR_CODE, ERR.NETWORK, 2100), _defineProperty(_ERR_CODE, ERR.NETWORK_TIMEOUT, 2101), _defineProperty(_ERR_CODE, ERR.DEMUX, { | ||
FLV: 3100, | ||
HLS: 3200, | ||
MP4: 3300, | ||
FMP4: 3400 | ||
}), _defineProperty(_ERR_CODE, ERR.REMUX, { | ||
FMP4: 4100, | ||
MP4: 4200 | ||
}), _defineProperty(_ERR_CODE, ERR.MEDIA, { | ||
MSE_ADD_SB: 5200, | ||
MSE_APPEND_BUFFER: 5201, | ||
MSE_OTHER: 5202 | ||
}), _defineProperty(_ERR_CODE, ERR.OTHER, 8000), _ERR_CODE); | ||
var StreamingError = /*#__PURE__*/function (_Error) { | ||
@@ -34,3 +58,3 @@ _inherits(StreamingError, _Error); | ||
function StreamingError(type, origin, payload, msg) { | ||
function StreamingError(type, subType, origin, payload, msg) { | ||
var _this; | ||
@@ -44,3 +68,3 @@ | ||
_this.ext = payload; | ||
_this.errorCode = ERR_CODE[type]; | ||
_this.errorCode = ERR_CODE[type][subType] || ERR_CODE[type]; | ||
_this.errorMessage = _this.message; | ||
@@ -58,3 +82,3 @@ | ||
key: "create", | ||
value: function create(type, origin, payload, msg) { | ||
value: function create(type, subType, origin, payload, msg) { | ||
if (type instanceof StreamingError) { | ||
@@ -68,3 +92,3 @@ return type; | ||
if (!type) type = ERR.OTHER; | ||
return new StreamingError(type, origin, payload, msg); | ||
return new StreamingError(type, subType, origin, payload, msg); | ||
} | ||
@@ -76,3 +100,3 @@ }, { | ||
return new StreamingError(error !== null && error !== void 0 && error.isTimeout ? ERR.NETWORK_TIMEOUT : ERR.NETWORK, error, { | ||
return new StreamingError(error !== null && error !== void 0 && error.isTimeout ? ERR.NETWORK_TIMEOUT : ERR.NETWORK, error, null, { | ||
url: error === null || error === void 0 ? void 0 : error.url, | ||
@@ -79,0 +103,0 @@ response: error === null || error === void 0 ? void 0 : error.response, |
@@ -6,3 +6,3 @@ export { MSE, MSEError, MSEErrorType } from './mse.js'; | ||
export { EVENT } from './event.js'; | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, softDecodeProbe } from './streaming-helper.js'; | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, sleep } from './streaming-helper.js'; | ||
export { Logger } from './logger.js'; | ||
@@ -9,0 +9,0 @@ export { LoaderType, ResponseType } from './net/types.js'; |
export type MSEErrorType = string; | ||
export namespace MSEErrorType { | ||
const CANCELLED: string; | ||
const UPDATE_ERROR: string; | ||
@@ -16,2 +15,4 @@ } | ||
export class MSE { | ||
static VIDEO: string; | ||
static AUDIO: string; | ||
/** | ||
@@ -79,2 +80,3 @@ * @param {string} [mime='video/mp4; codecs="avc1.42E01E,mp4a.40.2"'] | ||
remove(type: string, startTime: number, endTime: number): Promise<any>; | ||
clearBuffer(startTime: any, endTime: any): undefined; | ||
clearAllBuffer(): undefined; | ||
@@ -81,0 +83,0 @@ /** |
import 'core-js/modules/es.reflect.construct.js'; | ||
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
@@ -16,2 +16,3 @@ import _inherits from '@babel/runtime/helpers/inherits'; | ||
import 'core-js/modules/web.url.js'; | ||
import 'core-js/modules/web.url-search-params.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
@@ -23,2 +24,4 @@ import 'core-js/modules/es.object.keys.js'; | ||
import { Buffer } from './buffer.js'; | ||
import { StreamingError, ERR } from './error.js'; | ||
import { isBrowser } from './env.js'; | ||
@@ -28,7 +31,11 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
var MediaSource = window.MediaSource || window.WebKitMediaSource; | ||
function getMediaSource() { | ||
return isBrowser ? MediaSource : null; | ||
} | ||
var MediaSource = getMediaSource(); | ||
/** @enum {string} */ | ||
var MSEErrorType = { | ||
CANCELLED: 'canceled', | ||
UPDATE_ERROR: 'updateError' | ||
@@ -56,3 +63,3 @@ }; | ||
return MSEError; | ||
return _createClass(MSEError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
@@ -103,3 +110,3 @@ var MSE = /*#__PURE__*/function () { | ||
if (op) { | ||
op.promise.reject(new MSEError(MSEErrorType.UPDATE_ERROR, event)); // Do not shift from queue, 'updateend' event will fire next | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_APPEND_BUFFER, event)); // Do not shift from queue, 'updateend' event will fire next | ||
} | ||
@@ -245,3 +252,3 @@ } | ||
queue.forEach(function (x) { | ||
return x.promise.reject(new MSEError(MSEErrorType.CANCELLED)); | ||
return x.promise.resolve; | ||
}); | ||
@@ -305,3 +312,10 @@ } | ||
if (this._sourceBuffer[type] || !this.mediaSource) return; | ||
var sb = this._sourceBuffer[type] = this.mediaSource.addSourceBuffer(mimeType); | ||
var sb; | ||
try { | ||
sb = this._sourceBuffer[type] = this.mediaSource.addSourceBuffer(mimeType); | ||
} catch (error) { | ||
throw new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_ADD_SB, error); | ||
} | ||
sb.mimeType = mimeType; | ||
@@ -355,5 +369,6 @@ sb.addEventListener('updateend', this._onSBUpdateEnd.bind(this, type)); | ||
return this._enqueueOp(type, function () { | ||
var _this7$_sourceBuffer$; | ||
if (!_this7.mediaSource) return; | ||
_this7._sourceBuffer[type].appendBuffer(buffer); | ||
(_this7$_sourceBuffer$ = _this7._sourceBuffer[type]) === null || _this7$_sourceBuffer$ === void 0 ? void 0 : _this7$_sourceBuffer$.appendBuffer(buffer); | ||
}); | ||
@@ -388,4 +403,4 @@ } | ||
}, { | ||
key: "clearAllBuffer", | ||
value: function clearAllBuffer() { | ||
key: "clearBuffer", | ||
value: function clearBuffer(startTime, endTime) { | ||
var _this9 = this; | ||
@@ -398,2 +413,17 @@ | ||
var sb = _this9._sourceBuffer[k]; | ||
sb.remove(startTime, endTime); | ||
}); | ||
}); | ||
return p; | ||
} | ||
}, { | ||
key: "clearAllBuffer", | ||
value: function clearAllBuffer() { | ||
var _this10 = this; | ||
var p; | ||
Object.keys(this._sourceBuffer).forEach(function (k) { | ||
p = _this10._enqueueOp(k, function () { | ||
if (!_this10.mediaSource) return; | ||
var sb = _this10._sourceBuffer[k]; | ||
sb.remove(0, Buffer.end(Buffer.get(sb))); | ||
@@ -412,7 +442,7 @@ }); | ||
value: function endOfStream(reason) { | ||
var _this10 = this; | ||
var _this11 = this; | ||
if (!this.mediaSource || this.mediaSource.readyState !== 'open') return Promise.resolve(); | ||
return this._enqueueBlockingOp(function () { | ||
var ms = _this10.mediaSource; | ||
var ms = _this11.mediaSource; | ||
if (!ms || ms.readyState !== 'open') return; | ||
@@ -485,3 +515,3 @@ | ||
var _enqueueBlockingOp2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(exec) { | ||
var _this11 = this; | ||
var _this12 = this; | ||
@@ -513,3 +543,3 @@ var types, waiters; | ||
types.forEach(function (t) { | ||
var queue = _this11._queue[t]; | ||
var queue = _this12._queue[t]; | ||
var prom = createPublicPromise(); | ||
@@ -525,3 +555,3 @@ waiters.push(prom); | ||
if (queue.length === 1) { | ||
_this11._startQueue(t); | ||
_this12._startQueue(t); | ||
} | ||
@@ -534,8 +564,8 @@ }); | ||
types.forEach(function (t) { | ||
var queue = _this11._queue[t]; | ||
var sb = _this11._sourceBuffer[t]; | ||
var queue = _this12._queue[t]; | ||
var sb = _this12._sourceBuffer[t]; | ||
queue === null || queue === void 0 ? void 0 : queue.shift(); | ||
if (!sb || !sb.updating) { | ||
_this11._startQueue(t); | ||
_this12._startQueue(t); | ||
} | ||
@@ -572,3 +602,3 @@ }); | ||
} catch (error) { | ||
op.promise.reject(error); | ||
op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error)); | ||
queue.shift(); | ||
@@ -603,2 +633,6 @@ | ||
_defineProperty(MSE, "VIDEO", 'video'); | ||
_defineProperty(MSE, "AUDIO", 'audio'); | ||
export { MSE, MSEError, MSEErrorType }; |
import 'core-js/modules/es.object.keys.js'; | ||
import 'core-js/modules/es.symbol.js'; | ||
import 'core-js/modules/es.array.filter.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.object.get-own-property-descriptor.js'; | ||
@@ -10,5 +11,5 @@ import 'core-js/modules/web.dom-collections.for-each.js'; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function getConfig(cfg) { | ||
@@ -15,0 +16,0 @@ return _objectSpread({ |
@@ -0,2 +1,4 @@ | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.reflect.construct.js'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
@@ -42,5 +44,5 @@ import _assertThisInitialized from '@babel/runtime/helpers/assertThisInitialized'; | ||
return NetError; | ||
return _createClass(NetError); | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
export { NetError }; |
@@ -8,3 +8,3 @@ export class FetchLoader { | ||
_aborted: boolean; | ||
load({ url, timeout, responseType, onProgress, onTimeout, range, transformResponse, request, params, method, headers, body, mode, credentials, cache, redirect, referrer, referrerPolicy, integrity }: { | ||
load({ url, timeout, responseType, onProgress, onTimeout, range, transformResponse, request, params, method, headers, body, mode, credentials, cache, redirect, referrer, referrerPolicy }: { | ||
url: any; | ||
@@ -28,3 +28,2 @@ timeout: any; | ||
referrerPolicy: any; | ||
integrity: any; | ||
}): Promise<void | { | ||
@@ -31,0 +30,0 @@ data: any; |
@@ -55,3 +55,4 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
value: function load(_ref) { | ||
var _this = this; | ||
var _this$_abortControlle, | ||
_this = this; | ||
@@ -75,6 +76,5 @@ var url = _ref.url, | ||
referrer = _ref.referrer, | ||
referrerPolicy = _ref.referrerPolicy, | ||
integrity = _ref.integrity; | ||
referrerPolicy = _ref.referrerPolicy; | ||
this._aborted = false; | ||
this._abortController = new AbortController(); | ||
this._abortController = typeof AbortController !== 'undefined' && new AbortController(); | ||
var init = { | ||
@@ -90,4 +90,3 @@ method: method, | ||
referrerPolicy: referrerPolicy, | ||
integrity: integrity, | ||
signal: this._abortController.signal | ||
signal: (_this$_abortControlle = this._abortController) === null || _this$_abortControlle === void 0 ? void 0 : _this$_abortControlle.signal | ||
}; | ||
@@ -249,3 +248,3 @@ var isTimeout = false; | ||
if (!this._response) { | ||
_context2.next = 15; | ||
_context2.next = 13; | ||
break; | ||
@@ -255,26 +254,23 @@ } | ||
_context2.prev = 4; | ||
_context2.next = 7; | ||
return this._response.body.cancel(); | ||
case 7: | ||
if (!this._reader) { | ||
_context2.next = 10; | ||
_context2.next = 8; | ||
break; | ||
} | ||
_context2.next = 10; | ||
_context2.next = 8; | ||
return this._reader.cancel(); | ||
case 10: | ||
_context2.next = 14; | ||
case 8: | ||
_context2.next = 12; | ||
break; | ||
case 12: | ||
_context2.prev = 12; | ||
case 10: | ||
_context2.prev = 10; | ||
_context2.t0 = _context2["catch"](4); | ||
case 14: | ||
case 12: | ||
this._response = this._reader = null; | ||
case 15: | ||
case 13: | ||
if (this._abortController) { | ||
@@ -289,3 +285,3 @@ try { | ||
case 16: | ||
case 14: | ||
case "end": | ||
@@ -295,3 +291,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, this, [[4, 12]]); | ||
}, _callee2, this, [[4, 10]]); | ||
})); | ||
@@ -383,13 +379,3 @@ | ||
value: function isSupported() { | ||
if (typeof ReadableStream !== 'undefined') { | ||
try { | ||
new ReadableStream({}); // eslint-disable-line no-new | ||
} catch (e) { | ||
return false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
return !!(typeof fetch !== 'undefined' && typeof AbortController !== 'undefined'); | ||
return !!(typeof fetch !== 'undefined'); | ||
} | ||
@@ -396,0 +382,0 @@ }]); |
@@ -5,2 +5,3 @@ import 'core-js/modules/es.regexp.exec.js'; | ||
import 'core-js/modules/es.array.filter.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.array.map.js'; | ||
@@ -7,0 +8,0 @@ import 'core-js/modules/es.object.keys.js'; |
@@ -11,3 +11,3 @@ export class NetLoader { | ||
load(url: any, config?: {}): Promise<any>; | ||
cancel(): Promise<any[]>; | ||
cancel(): Promise<void>; | ||
_processTask(): void; | ||
@@ -14,0 +14,0 @@ } |
@@ -0,4 +1,6 @@ | ||
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator'; | ||
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import _createClass from '@babel/runtime/helpers/createClass'; | ||
import _defineProperty from '@babel/runtime/helpers/defineProperty'; | ||
import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import 'core-js/modules/es.object.assign.js'; | ||
@@ -20,2 +22,3 @@ import 'core-js/modules/es.array.concat.js'; | ||
import { isPlainObject } from '../is.js'; | ||
import { sleep } from '../streaming-helper.js'; | ||
@@ -78,17 +81,42 @@ var NetLoader = /*#__PURE__*/function () { | ||
key: "cancel", | ||
value: function cancel() { | ||
var cancels = this._queue.map(function (t) { | ||
return t.cancel(); | ||
}).concat(this._alive.map(function (t) { | ||
return t.cancel(); | ||
value: function () { | ||
var _cancel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
var cancels; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
cancels = this._queue.map(function (t) { | ||
return t.cancel(); | ||
}).concat(this._alive.map(function (t) { | ||
return t.cancel(); | ||
})); | ||
if (this._currentTask) { | ||
cancels.push(this._currentTask.cancel()); | ||
} | ||
this._queue = []; | ||
this._alive = []; | ||
_context.next = 6; | ||
return Promise.all(cancels); | ||
case 6: | ||
_context.next = 8; | ||
return sleep(); | ||
case 8: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
if (this._currentTask) { | ||
cancels.push(this._currentTask.cancel()); | ||
function cancel() { | ||
return _cancel.apply(this, arguments); | ||
} | ||
this._queue = []; | ||
this._alive = []; | ||
return Promise.all(cancels); | ||
} | ||
return cancel; | ||
}() | ||
}, { | ||
@@ -106,3 +134,3 @@ key: "_processTask", | ||
this._currentTask.exec().finally(function () { | ||
this._currentTask.exec().catch(function () {}).finally(function () { | ||
_this._processTask(); | ||
@@ -109,0 +137,0 @@ }); |
@@ -5,2 +5,3 @@ import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; | ||
import 'core-js/modules/es.array.slice.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
@@ -7,0 +8,0 @@ var BandwidthService = /*#__PURE__*/function () { |
@@ -11,3 +11,7 @@ export function isMediaPlaying(media: any): boolean; | ||
}; | ||
export function concatUint8Array(...arr: any[]): Uint8Array; | ||
export function softDecodeProbe(): any; | ||
/** | ||
* @param {Array.<Uint8Array>} arr | ||
* @returns | ||
*/ | ||
export function concatUint8Array(...arr: Array<Uint8Array>): Uint8Array; | ||
export function sleep(t?: number): Promise<any>; |
import 'core-js/modules/es.array.filter.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.array.iterator.js'; | ||
import 'core-js/modules/es.object.to-string.js'; | ||
import 'core-js/modules/es.typed-array.uint8-array.js'; | ||
@@ -29,2 +29,3 @@ import 'core-js/modules/es.typed-array.copy-within.js'; | ||
import 'core-js/modules/web.dom-collections.for-each.js'; | ||
import 'core-js/modules/es.promise.js'; | ||
@@ -52,2 +53,7 @@ function isMediaPlaying(media) { | ||
} | ||
/** | ||
* @param {Array.<Uint8Array>} arr | ||
* @returns | ||
*/ | ||
function concatUint8Array() { | ||
@@ -59,2 +65,3 @@ for (var _len = arguments.length, arr = new Array(_len), _key = 0; _key < _len; _key++) { | ||
arr = arr.filter(Boolean); | ||
if (arr.length < 2) return arr[0]; | ||
var data = new Uint8Array(arr.reduce(function (p, c) { | ||
@@ -70,41 +77,9 @@ return p + c.byteLength; | ||
} | ||
function softDecodeProbe() { | ||
var webAudioEnable = false; | ||
var webglEnable = false; | ||
try { | ||
var AudioContext = window.AudioContext || window.webkitAudioContext; | ||
var ctx = new AudioContext(); | ||
ctx.close(); | ||
ctx = null; | ||
webAudioEnable = true; | ||
} catch (e) {} | ||
try { | ||
var cvs = document.createElement('canvas'); | ||
var validContextNames = ['webgl', 'experimental-webgl', 'moz-webgl', 'webkit-3d']; | ||
for (var i = 0; i < validContextNames.length; i++) { | ||
var glCtx = cvs.getContext(validContextNames[i]); | ||
if (glCtx) { | ||
glCtx = null; | ||
cvs = null; | ||
webglEnable = true; | ||
break; | ||
} | ||
} | ||
} catch (e) {} | ||
var WebComponentSupported = 'customElements' in window && window.customElements.define; | ||
var isComponentSupport; | ||
if (WebComponentSupported) { | ||
var Video = window.customElements.get('live-video'); | ||
isComponentSupport = Video && Video.isSupported(); | ||
} | ||
return webAudioEnable && webglEnable && isComponentSupport; | ||
function sleep() { | ||
var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
return new Promise(function (resolve) { | ||
return setTimeout(resolve, t); | ||
}); | ||
} | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, softDecodeProbe }; | ||
export { concatUint8Array, getVideoPlaybackQuality, isMediaPlaying, sleep }; |
{ | ||
"name": "xgplayer-streaming-shared", | ||
"version": "3.0.0-next.2-1", | ||
"version": "3.0.0-next.9-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
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
45
2949
214520