@volcengine/veplayer-plugin 2.3.0-rc.3 → 2.4.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/esm/index.development.js +4878 -1534
  2. package/esm/index.production.js +5 -5
  3. package/esm/veplayer.plugin.flv.development.js +352 -197
  4. package/esm/veplayer.plugin.flv.production.js +1 -1
  5. package/esm/veplayer.plugin.hls.development.js +656 -261
  6. package/esm/veplayer.plugin.hls.production.js +1 -1
  7. package/package.json +21 -1
  8. package/umd/veplayer.plugin.flv.development.js +348 -193
  9. package/umd/veplayer.plugin.flv.production.js +1 -1
  10. package/umd/veplayer.plugin.hls.development.js +650 -255
  11. package/umd/veplayer.plugin.hls.production.js +1 -1
  12. package/esm/veplayer.plugin.drm.development.js +0 -1577
  13. package/esm/veplayer.plugin.drm.production.js +0 -2
  14. package/esm/veplayer.plugin.mp4.development.js +0 -38039
  15. package/esm/veplayer.plugin.mp4.production.js +0 -2
  16. package/esm/veplayer.plugin.rtm.development.js +0 -5587
  17. package/esm/veplayer.plugin.rtm.production.js +0 -2
  18. package/esm/veplayer.plugin.shaka.development.js +0 -15973
  19. package/esm/veplayer.plugin.shaka.production.js +0 -20
  20. package/esm/veplayer.plugin.time.shift.development.css +0 -63
  21. package/esm/veplayer.plugin.time.shift.development.js +0 -339
  22. package/esm/veplayer.plugin.time.shift.production.css +0 -1
  23. package/esm/veplayer.plugin.time.shift.production.js +0 -2
  24. package/esm/veplayer.plugin.xgvideo.development.js +0 -19097
  25. package/esm/veplayer.plugin.xgvideo.production.js +0 -2
  26. package/umd/veplayer.plugin.drm.development.js +0 -1579
  27. package/umd/veplayer.plugin.drm.production.js +0 -1
  28. package/umd/veplayer.plugin.mp4.development.js +0 -38043
  29. package/umd/veplayer.plugin.mp4.production.js +0 -1
  30. package/umd/veplayer.plugin.rtm.development.js +0 -5589
  31. package/umd/veplayer.plugin.rtm.production.js +0 -1
  32. package/umd/veplayer.plugin.shaka.development.js +0 -15977
  33. package/umd/veplayer.plugin.shaka.production.js +0 -1
  34. package/umd/veplayer.plugin.time.shift.development.css +0 -63
  35. package/umd/veplayer.plugin.time.shift.development.js +0 -342
  36. package/umd/veplayer.plugin.time.shift.production.css +0 -1
  37. package/umd/veplayer.plugin.time.shift.production.js +0 -1
  38. package/umd/veplayer.plugin.xgvideo.development.js +0 -19099
  39. package/umd/veplayer.plugin.xgvideo.production.js +0 -1
@@ -470,7 +470,7 @@ function _possibleConstructorReturn$3(self, call) {
470
470
  }
471
471
  return _assertThisInitialized$3(self);
472
472
  }
473
- function _createSuper$3(Derived) {
473
+ function _createSuper$2(Derived) {
474
474
  var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
475
475
  return function _createSuperInternal() {
476
476
  var Super = _getPrototypeOf$3(Derived), result;
@@ -1387,6 +1387,9 @@ util.cancelAnimationFrame = function(frameId) {
1387
1387
  _fun && _fun(frameId);
1388
1388
  };
1389
1389
  util.isMSE = function(video) {
1390
+ if (video.media) {
1391
+ video = video.media;
1392
+ }
1390
1393
  if (!video || !(video instanceof HTMLMediaElement)) {
1391
1394
  return false;
1392
1395
  }
@@ -1535,7 +1538,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
1535
1538
  }
1536
1539
  return offsetTime;
1537
1540
  };
1538
- var version = "3.0.12";
1541
+ var version = "3.0.17";
1539
1542
  var ERROR_MAP = {
1540
1543
  1: 5101,
1541
1544
  2: 5102,
@@ -2510,7 +2513,7 @@ function _possibleConstructorReturn$2(self, call) {
2510
2513
  }
2511
2514
  return _assertThisInitialized$2(self);
2512
2515
  }
2513
- function _createSuper$2(Derived) {
2516
+ function _createSuper$1(Derived) {
2514
2517
  var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
2515
2518
  return function _createSuperInternal() {
2516
2519
  var Super = _getPrototypeOf$2(Derived), result;
@@ -2638,30 +2641,6 @@ function _toPropertyKey$2(arg) {
2638
2641
  var key = _toPrimitive$2(arg, "string");
2639
2642
  return typeof key === "symbol" ? key : String(key);
2640
2643
  }
2641
- function createPublicPromise() {
2642
- var res, rej;
2643
- var promise = new Promise(function(resolve, reject) {
2644
- res = resolve;
2645
- rej = reject;
2646
- });
2647
- promise.used = false;
2648
- promise.resolve = function() {
2649
- promise.used = true;
2650
- return res.apply(void 0, arguments);
2651
- };
2652
- promise.reject = function() {
2653
- promise.used = true;
2654
- return rej.apply(void 0, arguments);
2655
- };
2656
- return promise;
2657
- }
2658
- function nowTime$1() {
2659
- try {
2660
- return parseInt(performance.now(), 10);
2661
- } catch (e) {
2662
- return (/* @__PURE__ */ new Date()).getTime();
2663
- }
2664
- }
2665
2644
  var Buffer$1 = /* @__PURE__ */ function() {
2666
2645
  function Buffer2() {
2667
2646
  _classCallCheck$2(this, Buffer2);
@@ -2783,6 +2762,7 @@ var Buffer$1 = /* @__PURE__ */ function() {
2783
2762
  }]);
2784
2763
  return Buffer2;
2785
2764
  }();
2765
+ var isBrowser$1 = typeof window !== "undefined";
2786
2766
  var _ERR_CODE;
2787
2767
  var ERR = {
2788
2768
  MANIFEST: "manifest",
@@ -2859,7 +2839,7 @@ var ERR_CODE = (_ERR_CODE = {}, _defineProperty$1(_ERR_CODE, ERR.MANIFEST, {
2859
2839
  }), _ERR_CODE);
2860
2840
  var StreamingError = /* @__PURE__ */ function(_Error) {
2861
2841
  _inherits$2(StreamingError2, _Error);
2862
- var _super = _createSuper$2(StreamingError2);
2842
+ var _super = _createSuper$1(StreamingError2);
2863
2843
  function StreamingError2(type, subType, origin, payload, msg) {
2864
2844
  var _this;
2865
2845
  _classCallCheck$2(this, StreamingError2);
@@ -2901,7 +2881,6 @@ var StreamingError = /* @__PURE__ */ function(_Error) {
2901
2881
  }]);
2902
2882
  return StreamingError2;
2903
2883
  }(/* @__PURE__ */ _wrapNativeSuper(Error));
2904
- var isBrowser$1 = typeof window !== "undefined";
2905
2884
  var LogCacheLevel = {
2906
2885
  "DEBUG": 1,
2907
2886
  "LOG": 2,
@@ -2930,7 +2909,7 @@ var Logger$2 = /* @__PURE__ */ function() {
2930
2909
  this.logCache.apply(this, [LogCacheLevel.DEBUG].concat(args));
2931
2910
  if (Logger2.disabled)
2932
2911
  return;
2933
- (_console = console).debug.apply(_console, [this._prefix, nowTime()].concat(args));
2912
+ (_console = console).debug.apply(_console, [this._prefix, nowTime$1()].concat(args));
2934
2913
  }
2935
2914
  }, {
2936
2915
  key: "log",
@@ -2942,7 +2921,7 @@ var Logger$2 = /* @__PURE__ */ function() {
2942
2921
  this.logCache.apply(this, [LogCacheLevel.LOG].concat(args));
2943
2922
  if (Logger2.disabled)
2944
2923
  return;
2945
- (_console2 = console).log.apply(_console2, [this._prefix, nowTime()].concat(args));
2924
+ (_console2 = console).log.apply(_console2, [this._prefix, nowTime$1()].concat(args));
2946
2925
  }
2947
2926
  }, {
2948
2927
  key: "warn",
@@ -2954,7 +2933,7 @@ var Logger$2 = /* @__PURE__ */ function() {
2954
2933
  this.logCache.apply(this, [LogCacheLevel.WARN].concat(args));
2955
2934
  if (Logger2.disabled)
2956
2935
  return;
2957
- (_console3 = console).warn.apply(_console3, [this._prefix, nowTime()].concat(args));
2936
+ (_console3 = console).warn.apply(_console3, [this._prefix, nowTime$1()].concat(args));
2958
2937
  }
2959
2938
  }, {
2960
2939
  key: "error",
@@ -2966,7 +2945,7 @@ var Logger$2 = /* @__PURE__ */ function() {
2966
2945
  this.logCache.apply(this, [LogCacheLevel.ERROR].concat(args));
2967
2946
  if (Logger2.disabled)
2968
2947
  return;
2969
- (_console4 = console).error.apply(_console4, [this._prefix, nowTime()].concat(args));
2948
+ (_console4 = console).error.apply(_console4, [this._prefix, nowTime$1()].concat(args));
2970
2949
  }
2971
2950
  }, {
2972
2951
  key: "logCache",
@@ -2981,7 +2960,7 @@ var Logger$2 = /* @__PURE__ */ function() {
2981
2960
  var finLogText = logText.map(function(item) {
2982
2961
  return logable(item);
2983
2962
  });
2984
- text = this._prefix + nowTime() + JSON.stringify(finLogText);
2963
+ text = this._prefix + nowTime$1() + JSON.stringify(finLogText);
2985
2964
  } catch (e) {
2986
2965
  return;
2987
2966
  }
@@ -3036,7 +3015,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3036
3015
  return Logger2;
3037
3016
  }();
3038
3017
  _defineProperty$1(Logger$2, "disabled", true);
3039
- function nowTime() {
3018
+ function nowTime$1() {
3040
3019
  return (/* @__PURE__ */ new Date()).toLocaleString();
3041
3020
  }
3042
3021
  function reduceDepth(val) {
@@ -3084,13 +3063,72 @@ function logable(obj, maxDepth, depth) {
3084
3063
  }
3085
3064
  return result;
3086
3065
  }
3066
+ function createPublicPromise() {
3067
+ var res, rej;
3068
+ var promise = new Promise(function(resolve, reject) {
3069
+ res = resolve;
3070
+ rej = reject;
3071
+ });
3072
+ promise.used = false;
3073
+ promise.resolve = function() {
3074
+ promise.used = true;
3075
+ return res.apply(void 0, arguments);
3076
+ };
3077
+ promise.reject = function() {
3078
+ promise.used = true;
3079
+ return rej.apply(void 0, arguments);
3080
+ };
3081
+ return promise;
3082
+ }
3083
+ function nowTime() {
3084
+ try {
3085
+ return parseInt(performance.now(), 10);
3086
+ } catch (e) {
3087
+ return (/* @__PURE__ */ new Date()).getTime();
3088
+ }
3089
+ }
3090
+ var SafeJSON = {
3091
+ stringify: function stringify(obj) {
3092
+ try {
3093
+ return JSON.stringify(obj);
3094
+ } catch (e) {
3095
+ return "";
3096
+ }
3097
+ },
3098
+ parse: function parse(obj) {
3099
+ try {
3100
+ return JSON.parse(obj);
3101
+ } catch (e) {
3102
+ return void 0;
3103
+ }
3104
+ }
3105
+ };
3087
3106
  function getMediaSource() {
3107
+ var preferMMS = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
3088
3108
  try {
3089
- return isBrowser$1 ? window.MediaSource : null;
3109
+ if (!isBrowser$1)
3110
+ return null;
3111
+ if (preferMMS && typeof ManagedMediaSource !== "undefined")
3112
+ return ManagedMediaSource;
3113
+ return window.MediaSource;
3090
3114
  } catch (e) {
3091
3115
  }
3092
3116
  }
3093
- var MediaSource = getMediaSource();
3117
+ function isMMS(mediaSource) {
3118
+ return /ManagedMediaSource/gi.test(Object.prototype.toString.call(mediaSource));
3119
+ }
3120
+ function getTimeRanges(buffered) {
3121
+ var ranges = [];
3122
+ if (buffered instanceof TimeRanges) {
3123
+ for (var i = 0; i < buffered.length; i++) {
3124
+ ranges.push({
3125
+ start: buffered.start(i),
3126
+ end: buffered.end(i)
3127
+ });
3128
+ }
3129
+ }
3130
+ return ranges;
3131
+ }
3094
3132
  var OP_NAME = {
3095
3133
  APPEND: "appendBuffer",
3096
3134
  REMOVE: "removeBuffer",
@@ -3111,6 +3149,12 @@ var MSE = /* @__PURE__ */ function() {
3111
3149
  _defineProperty$1(this, "_logger", null);
3112
3150
  _defineProperty$1(this, "_config", null);
3113
3151
  _defineProperty$1(this, "_url", null);
3152
+ _defineProperty$1(this, "_onStartStreaming", function() {
3153
+ _this2._logger.debug("startstreaming");
3154
+ });
3155
+ _defineProperty$1(this, "_onEndStreaming", function() {
3156
+ _this2._logger.debug("endstreaming");
3157
+ });
3114
3158
  _defineProperty$1(this, "_onSBUpdateEnd", function(type) {
3115
3159
  var queue = _this2._queue[type];
3116
3160
  if (queue) {
@@ -3119,8 +3163,9 @@ var MSE = /* @__PURE__ */ function() {
3119
3163
  queue.shift();
3120
3164
  }
3121
3165
  if (op) {
3122
- var costtime = nowTime$1() - _this2._opst;
3123
- _this2._logger.debug("UpdateEnd", op.opName, costtime, op.context);
3166
+ var _this2$_sourceBuffer$;
3167
+ var costtime = nowTime() - _this2._opst;
3168
+ _this2._logger.debug("UpdateEnd(".concat(type, "/").concat(op.opName, ")"), SafeJSON.stringify(getTimeRanges((_this2$_sourceBuffer$ = _this2._sourceBuffer[type]) === null || _this2$_sourceBuffer$ === void 0 ? void 0 : _this2$_sourceBuffer$.buffered)), costtime, op.context);
3124
3169
  op.promise.resolve({
3125
3170
  name: op.opName,
3126
3171
  context: op.context,
@@ -3154,6 +3199,19 @@ var MSE = /* @__PURE__ */ function() {
3154
3199
  var _this$mediaSource;
3155
3200
  return ((_this$mediaSource = this.mediaSource) === null || _this$mediaSource === void 0 ? void 0 : _this$mediaSource.readyState) === "open";
3156
3201
  }
3202
+ }, {
3203
+ key: "hasOpTasks",
3204
+ get: function get() {
3205
+ var _this3 = this;
3206
+ var flag = false;
3207
+ Object.keys(this._queue).forEach(function(k) {
3208
+ var queue = _this3._queue[k];
3209
+ if (Array.isArray(queue)) {
3210
+ flag || (flag = queue.length > 0);
3211
+ }
3212
+ });
3213
+ return flag;
3214
+ }
3157
3215
  }, {
3158
3216
  key: "url",
3159
3217
  get: function get() {
@@ -3170,6 +3228,11 @@ var MSE = /* @__PURE__ */ function() {
3170
3228
  get: function get() {
3171
3229
  return this.mediaSource ? this.mediaSource.readyState === "ended" : false;
3172
3230
  }
3231
+ }, {
3232
+ key: "streaming",
3233
+ get: function get() {
3234
+ return isMMS(this.mediaSource) ? this.mediaSource.streaming : true;
3235
+ }
3173
3236
  }, {
3174
3237
  key: "isFull",
3175
3238
  value: function isFull(type) {
@@ -3178,13 +3241,13 @@ var MSE = /* @__PURE__ */ function() {
3178
3241
  }, {
3179
3242
  key: "updateDuration",
3180
3243
  value: function updateDuration(duration) {
3181
- var _this3 = this;
3244
+ var _this4 = this;
3182
3245
  var isReduceDuration = this.mediaSource && this.mediaSource.duration > duration;
3183
3246
  if (this.mediaSource && this.mediaSource.duration > duration) {
3184
3247
  var bufferEnd = 0;
3185
3248
  Object.keys(this._sourceBuffer).forEach(function(k) {
3186
3249
  try {
3187
- bufferEnd = Math.max(_this3.bufferEnd(k) || 0, bufferEnd);
3250
+ bufferEnd = Math.max(_this4.bufferEnd(k) || 0, bufferEnd);
3188
3251
  } catch (error) {
3189
3252
  }
3190
3253
  });
@@ -3193,13 +3256,13 @@ var MSE = /* @__PURE__ */ function() {
3193
3256
  }
3194
3257
  }
3195
3258
  return this._enqueueBlockingOp(function() {
3196
- if (_this3.isEnded) {
3197
- _this3._logger.debug("[debug mse] setDuration ended");
3259
+ if (_this4.isEnded) {
3260
+ _this4._logger.debug("setDuration but ended");
3198
3261
  return;
3199
3262
  }
3200
- if (_this3.mediaSource) {
3201
- _this3.mediaSource.duration = duration;
3202
- _this3._logger.debug("[debug mse] setDuration");
3263
+ if (_this4.mediaSource) {
3264
+ _this4.mediaSource.duration = duration;
3265
+ _this4._logger.debug("setDuration", duration);
3203
3266
  }
3204
3267
  }, OP_NAME.UPDATE_DURATION, {
3205
3268
  isReduceDuration
@@ -3208,15 +3271,15 @@ var MSE = /* @__PURE__ */ function() {
3208
3271
  }, {
3209
3272
  key: "open",
3210
3273
  value: function open() {
3211
- var _this4 = this;
3274
+ var _this5 = this;
3212
3275
  if (this._openPromise.used && !this.isOpened && this.mediaSource) {
3213
3276
  var ms = this.mediaSource;
3214
3277
  var onOpen = function onOpen2() {
3215
- var costtime = nowTime$1() - _this4._st;
3216
- _this4._logger.debug("MSE OPEN", costtime);
3278
+ var costTime = nowTime() - _this5._st;
3279
+ _this5._logger.debug("sourceopen", costTime);
3217
3280
  ms.removeEventListener("sourceopen", onOpen2);
3218
- _this4._openPromise.resolve({
3219
- costtime
3281
+ _this5._openPromise.resolve({
3282
+ costtime: costTime
3220
3283
  });
3221
3284
  };
3222
3285
  ms.addEventListener("sourceopen", onOpen);
@@ -3228,8 +3291,8 @@ var MSE = /* @__PURE__ */ function() {
3228
3291
  key: "bindMedia",
3229
3292
  value: function() {
3230
3293
  var _bindMedia = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(media) {
3231
- var _this5 = this;
3232
- var ms, onOpen;
3294
+ var _this6 = this;
3295
+ var MediaSource2, ms, useMMS, onOpen;
3233
3296
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3234
3297
  while (1)
3235
3298
  switch (_context.prev = _context.next) {
@@ -3241,29 +3304,36 @@ var MSE = /* @__PURE__ */ function() {
3241
3304
  _context.next = 3;
3242
3305
  return this.unbindMedia();
3243
3306
  case 3:
3244
- if (!(!media || !MediaSource)) {
3245
- _context.next = 5;
3307
+ MediaSource2 = getMediaSource(this._config.preferMMS);
3308
+ if (!(!media || !MediaSource2)) {
3309
+ _context.next = 6;
3246
3310
  break;
3247
3311
  }
3248
3312
  throw new Error("Param media or MediaSource does not exist");
3249
- case 5:
3313
+ case 6:
3250
3314
  this.media = media;
3251
- ms = this.mediaSource = new MediaSource();
3252
- this._st = nowTime$1();
3315
+ ms = this.mediaSource = new MediaSource2();
3316
+ useMMS = isMMS(ms);
3317
+ this._st = nowTime();
3253
3318
  onOpen = function onOpen2() {
3254
- var costtime = nowTime$1() - _this5._st;
3255
- _this5._logger.debug("MSE OPEN");
3319
+ var costTime = nowTime() - _this6._st;
3320
+ _this6._logger.debug("sourceopen");
3256
3321
  ms.removeEventListener("sourceopen", onOpen2);
3257
3322
  URL.revokeObjectURL(media.src);
3258
- _this5._openPromise.resolve({
3259
- costtime
3323
+ _this6._openPromise.resolve({
3324
+ costtime: costTime
3260
3325
  });
3261
3326
  };
3262
3327
  ms.addEventListener("sourceopen", onOpen);
3328
+ if (useMMS) {
3329
+ ms.addEventListener("startstreaming", this._onStartStreaming);
3330
+ ms.addEventListener("endstreaming", this._onEndStreaming);
3331
+ }
3263
3332
  this._url = URL.createObjectURL(ms);
3264
3333
  media.src = this._url;
3334
+ media.disableRemotePlayback = useMMS;
3265
3335
  return _context.abrupt("return", this._openPromise);
3266
- case 13:
3336
+ case 17:
3267
3337
  case "end":
3268
3338
  return _context.stop();
3269
3339
  }
@@ -3278,7 +3348,7 @@ var MSE = /* @__PURE__ */ function() {
3278
3348
  key: "unbindMedia",
3279
3349
  value: function() {
3280
3350
  var _unbindMedia = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2() {
3281
- var _this6 = this;
3351
+ var _this7 = this;
3282
3352
  var ms, hasMetadata, mseOpen;
3283
3353
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3284
3354
  while (1)
@@ -3289,7 +3359,7 @@ var MSE = /* @__PURE__ */ function() {
3289
3359
  ms = this.mediaSource;
3290
3360
  if (ms) {
3291
3361
  Object.keys(this._queue).forEach(function(t) {
3292
- var queue = _this6._queue[t];
3362
+ var queue = _this7._queue[t];
3293
3363
  if (queue) {
3294
3364
  queue.forEach(function(x) {
3295
3365
  var _x$promise, _x$promise$resolve;
@@ -3307,12 +3377,17 @@ var MSE = /* @__PURE__ */ function() {
3307
3377
  }
3308
3378
  Object.keys(this._sourceBuffer).forEach(function(k) {
3309
3379
  try {
3310
- ms.removeSourceBuffer(_this6._sourceBuffer[k]);
3380
+ ms.removeSourceBuffer(_this7._sourceBuffer[k]);
3311
3381
  } catch (error) {
3312
3382
  }
3313
3383
  });
3384
+ if (isMMS(ms)) {
3385
+ ms.removeEventListener("startstreaming", this._onStartStreaming);
3386
+ ms.removeEventListener("endstreaming", this._onEndStreaming);
3387
+ }
3314
3388
  }
3315
3389
  if (this.media) {
3390
+ this.media.disableRemotePlayback = false;
3316
3391
  this.media.removeAttribute("src");
3317
3392
  try {
3318
3393
  this.media.load();
@@ -3353,7 +3428,7 @@ var MSE = /* @__PURE__ */ function() {
3353
3428
  }, {
3354
3429
  key: "changeType",
3355
3430
  value: function changeType(type, mimeType) {
3356
- var _this7 = this;
3431
+ var _this8 = this;
3357
3432
  var sb = this._sourceBuffer[type];
3358
3433
  if (!this.mediaSource || !sb || sb.mimeType === mimeType)
3359
3434
  return Promise.resolve();
@@ -3362,7 +3437,7 @@ var MSE = /* @__PURE__ */ function() {
3362
3437
  return this._enqueueOp(type, function() {
3363
3438
  sb.changeType(mimeType);
3364
3439
  sb.mimeType = mimeType;
3365
- _this7._onSBUpdateEnd(type);
3440
+ _this8._onSBUpdateEnd(type);
3366
3441
  }, "changeType", {
3367
3442
  mimeType
3368
3443
  });
@@ -3376,60 +3451,60 @@ var MSE = /* @__PURE__ */ function() {
3376
3451
  }, {
3377
3452
  key: "append",
3378
3453
  value: function append(type, buffer, context) {
3379
- var _this8 = this;
3454
+ var _this9 = this;
3380
3455
  if (!buffer || !buffer.byteLength) {
3381
3456
  return Promise.resolve();
3382
3457
  }
3383
3458
  if (!this._sourceBuffer[type])
3384
3459
  return Promise.resolve();
3385
3460
  return this._enqueueOp(type, function() {
3386
- var _this8$_sourceBuffer$;
3387
- if (!_this8.mediaSource || _this8.media.error)
3461
+ var _this9$_sourceBuffer$;
3462
+ if (!_this9.mediaSource || _this9.media.error)
3388
3463
  return;
3389
- _this8._logger.debug("MSE APPEND START", context);
3390
- _this8._opst = nowTime$1();
3391
- (_this8$_sourceBuffer$ = _this8._sourceBuffer[type]) === null || _this8$_sourceBuffer$ === void 0 ? void 0 : _this8$_sourceBuffer$.appendBuffer(buffer);
3464
+ _this9._logger.debug("MSE APPEND START", context);
3465
+ _this9._opst = nowTime();
3466
+ (_this9$_sourceBuffer$ = _this9._sourceBuffer[type]) === null || _this9$_sourceBuffer$ === void 0 ? void 0 : _this9$_sourceBuffer$.appendBuffer(buffer);
3392
3467
  }, OP_NAME.APPEND, context);
3393
3468
  }
3394
3469
  }, {
3395
3470
  key: "remove",
3396
3471
  value: function remove(type, startTime, endTime, context) {
3397
- var _this9 = this;
3472
+ var _this10 = this;
3398
3473
  var isInsertHead = false;
3399
3474
  if (this._mseFullFlag[type]) {
3400
3475
  isInsertHead = true;
3401
3476
  }
3402
3477
  return this._enqueueOp(type, function() {
3403
- if (!_this9.mediaSource || _this9.media.error)
3478
+ if (!_this10.mediaSource || _this10.media.error)
3404
3479
  return;
3405
- var sb = _this9._sourceBuffer[type];
3480
+ var sb = _this10._sourceBuffer[type];
3406
3481
  if (startTime >= endTime || !sb) {
3407
- _this9._onSBUpdateEnd(type);
3482
+ _this10._onSBUpdateEnd(type);
3408
3483
  return;
3409
3484
  }
3410
- _this9._opst = nowTime$1();
3411
- _this9._logger.debug("MSE REMOVE START", type, startTime, endTime, context);
3485
+ _this10._opst = nowTime();
3486
+ _this10._logger.debug("MSE REMOVE START", type, startTime, endTime, context);
3412
3487
  sb.remove(startTime, endTime);
3413
3488
  }, OP_NAME.REMOVE, context, isInsertHead);
3414
3489
  }
3415
3490
  }, {
3416
3491
  key: "clearBuffer",
3417
3492
  value: function clearBuffer(startTime, endTime) {
3418
- var _this10 = this;
3493
+ var _this11 = this;
3419
3494
  var p;
3420
3495
  Object.keys(this._sourceBuffer).forEach(function(k) {
3421
- p = _this10.remove(k, startTime, endTime);
3496
+ p = _this11.remove(k, startTime, endTime);
3422
3497
  });
3423
3498
  return p || Promise.resolve();
3424
3499
  }
3425
3500
  }, {
3426
3501
  key: "clearAllBuffer",
3427
3502
  value: function clearAllBuffer() {
3428
- var _this11 = this;
3503
+ var _this12 = this;
3429
3504
  var p;
3430
3505
  Object.keys(this._sourceBuffer).forEach(function(k) {
3431
- var sb = _this11._sourceBuffer[k];
3432
- p = _this11.remove(k, 0, Buffer$1.end(Buffer$1.get(sb)));
3506
+ var sb = _this12._sourceBuffer[k];
3507
+ p = _this12.remove(k, 0, Buffer$1.end(Buffer$1.get(sb)));
3433
3508
  });
3434
3509
  return p;
3435
3510
  }
@@ -3445,26 +3520,26 @@ var MSE = /* @__PURE__ */ function() {
3445
3520
  }
3446
3521
  if (!queue || !queue[type] || queue.length < 5)
3447
3522
  return;
3448
- var initOpque = [];
3523
+ var initQueue = [];
3449
3524
  queue.forEach(function(op) {
3450
3525
  if (op.context && op.context.isinit) {
3451
- initOpque.push(op);
3526
+ initQueue.push(op);
3452
3527
  }
3453
3528
  });
3454
3529
  this._queue[type] = queue.slice(0, 2);
3455
- initOpque.length > 0 && (_this$_queue$type = this._queue[type]).push.apply(_this$_queue$type, initOpque);
3530
+ initQueue.length > 0 && (_this$_queue$type = this._queue[type]).push.apply(_this$_queue$type, initQueue);
3456
3531
  }
3457
3532
  }, {
3458
3533
  key: "endOfStream",
3459
3534
  value: function endOfStream(reason) {
3460
- var _this12 = this;
3535
+ var _this13 = this;
3461
3536
  if (!this.mediaSource || this.mediaSource.readyState !== "open")
3462
3537
  return Promise.resolve();
3463
3538
  return this._enqueueBlockingOp(function() {
3464
- var ms = _this12.mediaSource;
3539
+ var ms = _this13.mediaSource;
3465
3540
  if (!ms || ms.readyState !== "open")
3466
3541
  return;
3467
- _this12._logger.debug("MSE endOfStream START");
3542
+ _this13._logger.debug("MSE endOfStream START");
3468
3543
  if (reason) {
3469
3544
  ms.endOfStream(reason);
3470
3545
  } else {
@@ -3503,7 +3578,7 @@ var MSE = /* @__PURE__ */ function() {
3503
3578
  }, {
3504
3579
  key: "_enqueueOp",
3505
3580
  value: function _enqueueOp(type, exec, opName, context, isInsertHead) {
3506
- var _this13 = this;
3581
+ var _this14 = this;
3507
3582
  if (!this.mediaSource)
3508
3583
  return Promise.resolve();
3509
3584
  var queue = this._queue[type] = this._queue[type] || [];
@@ -3527,7 +3602,7 @@ var MSE = /* @__PURE__ */ function() {
3527
3602
  } else {
3528
3603
  this._openPromise.then(function() {
3529
3604
  if (queue.length === 1) {
3530
- _this13._startQueue(type);
3605
+ _this14._startQueue(type);
3531
3606
  }
3532
3607
  });
3533
3608
  }
@@ -3537,7 +3612,7 @@ var MSE = /* @__PURE__ */ function() {
3537
3612
  key: "_enqueueBlockingOp",
3538
3613
  value: function() {
3539
3614
  var _enqueueBlockingOp2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(exec, opName, context) {
3540
- var _this14 = this;
3615
+ var _this15 = this;
3541
3616
  var types, waiters;
3542
3617
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3543
3618
  while (1)
@@ -3558,7 +3633,7 @@ var MSE = /* @__PURE__ */ function() {
3558
3633
  case 5:
3559
3634
  waiters = [];
3560
3635
  types.forEach(function(t) {
3561
- var queue = _this14._queue[t];
3636
+ var queue = _this15._queue[t];
3562
3637
  var prom = createPublicPromise();
3563
3638
  waiters.push(prom);
3564
3639
  queue.push({
@@ -3570,7 +3645,7 @@ var MSE = /* @__PURE__ */ function() {
3570
3645
  context
3571
3646
  });
3572
3647
  if (queue.length === 1) {
3573
- _this14._startQueue(t);
3648
+ _this15._startQueue(t);
3574
3649
  }
3575
3650
  });
3576
3651
  return _context3.abrupt("return", Promise.all(waiters).then(function() {
@@ -3578,11 +3653,11 @@ var MSE = /* @__PURE__ */ function() {
3578
3653
  return exec();
3579
3654
  } finally {
3580
3655
  types.forEach(function(t) {
3581
- var queue = _this14._queue[t];
3582
- var sb = _this14._sourceBuffer[t];
3656
+ var queue = _this15._queue[t];
3657
+ var sb = _this15._sourceBuffer[t];
3583
3658
  queue === null || queue === void 0 ? void 0 : queue.shift();
3584
3659
  if (!sb || !sb.updating) {
3585
- _this14._startQueue(t);
3660
+ _this15._startQueue(t);
3586
3661
  }
3587
3662
  });
3588
3663
  }
@@ -3625,47 +3700,54 @@ var MSE = /* @__PURE__ */ function() {
3625
3700
  }, {
3626
3701
  key: "setTimeoffset",
3627
3702
  value: function setTimeoffset(type, timestampOffset, context) {
3628
- var _this15 = this;
3703
+ var _this16 = this;
3629
3704
  return this._enqueueOp(type, function() {
3630
3705
  if (timestampOffset < 0) {
3631
3706
  timestampOffset += 1e-3;
3632
3707
  }
3633
- _this15._sourceBuffer[type].timestampOffset = timestampOffset;
3634
- _this15._onSBUpdateEnd(type);
3708
+ _this16._sourceBuffer[type].timestampOffset = timestampOffset;
3709
+ _this16._onSBUpdateEnd(type);
3635
3710
  }, "setTimeoffset", context);
3636
3711
  }
3637
3712
  }, {
3638
3713
  key: "abort",
3639
3714
  value: function abort(type, context) {
3640
- var _this16 = this;
3715
+ var _this17 = this;
3641
3716
  if (!this.isOpened) {
3642
3717
  return Promise.resolve();
3643
3718
  }
3644
3719
  return this._enqueueOp(type, function() {
3645
- _this16._sourceBuffer[type].abort();
3646
- _this16._onSBUpdateEnd(type);
3720
+ _this17._sourceBuffer[type].abort();
3721
+ _this17._onSBUpdateEnd(type);
3647
3722
  }, "abort", context);
3648
3723
  }
3649
3724
  }], [{
3650
- key: "getDefaultConfig",
3651
- value: function getDefaultConfig() {
3652
- return {
3653
- openLog: false
3654
- };
3655
- }
3656
- }, {
3657
3725
  key: "isSupported",
3658
3726
  value: function isSupported() {
3659
3727
  var mime = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
3660
- if (!MediaSource)
3728
+ var MediaSource2 = getMediaSource();
3729
+ if (!MediaSource2)
3661
3730
  return false;
3662
3731
  try {
3663
- return MediaSource.isTypeSupported(mime);
3732
+ return MediaSource2.isTypeSupported(mime);
3664
3733
  } catch (error) {
3665
3734
  this._logger.error(mime, error);
3666
3735
  return false;
3667
3736
  }
3668
3737
  }
3738
+ }, {
3739
+ key: "isMMSOnly",
3740
+ value: function isMMSOnly() {
3741
+ return typeof ManagedMediaSource !== "undefined" && typeof MediaSource === "undefined";
3742
+ }
3743
+ }, {
3744
+ key: "getDefaultConfig",
3745
+ value: function getDefaultConfig() {
3746
+ return {
3747
+ openLog: false,
3748
+ preferMMS: false
3749
+ };
3750
+ }
3669
3751
  }]);
3670
3752
  return MSE2;
3671
3753
  }();
@@ -3682,7 +3764,7 @@ var ResponseType = {
3682
3764
  };
3683
3765
  var NetError = /* @__PURE__ */ function(_Error) {
3684
3766
  _inherits$2(NetError2, _Error);
3685
- var _super = _createSuper$2(NetError2);
3767
+ var _super = _createSuper$1(NetError2);
3686
3768
  function NetError2(url, request, response, msg) {
3687
3769
  var _this;
3688
3770
  _classCallCheck$2(this, NetError2);
@@ -3793,10 +3875,12 @@ var EVENT = {
3793
3875
  LOAD_COMPLETE: "core.loadcomplete",
3794
3876
  LOAD_RETRY: "core.loadretry",
3795
3877
  SOURCEBUFFER_CREATED: "core.sourcebuffercreated",
3878
+ MEDIASOURCE_OPENED: "core.mediasourceopened",
3796
3879
  ANALYZE_DURATION_EXCEEDED: "core.analyzedurationexceeded",
3797
3880
  REMOVE_BUFFER: "core.removebuffer",
3798
3881
  BUFFEREOS: "core.buffereos",
3799
3882
  KEYFRAME: "core.keyframe",
3883
+ CHASEFRAME: "core.chaseframe",
3800
3884
  METADATA_PARSED: "core.metadataparsed",
3801
3885
  SEI: "core.sei",
3802
3886
  SEI_IN_TIME: "core.seiintime",
@@ -3820,7 +3904,7 @@ var EVENT = {
3820
3904
  var CACHESIZE = 2 * 1024 * 1024;
3821
3905
  var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
3822
3906
  _inherits$2(FetchLoader2, _EventEmitter);
3823
- var _super = _createSuper$2(FetchLoader2);
3907
+ var _super = _createSuper$1(FetchLoader2);
3824
3908
  function FetchLoader2() {
3825
3909
  var _this;
3826
3910
  _classCallCheck$2(this, FetchLoader2);
@@ -4272,7 +4356,7 @@ function getConfig(cfg) {
4272
4356
  }
4273
4357
  var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
4274
4358
  _inherits$2(XhrLoader2, _EventEmitter);
4275
- var _super = _createSuper$2(XhrLoader2);
4359
+ var _super = _createSuper$1(XhrLoader2);
4276
4360
  function XhrLoader2() {
4277
4361
  var _this;
4278
4362
  _classCallCheck$2(this, XhrLoader2);
@@ -4756,7 +4840,7 @@ function sleep() {
4756
4840
  }
4757
4841
  var NetLoader = /* @__PURE__ */ function(_EventEmitter) {
4758
4842
  _inherits$2(NetLoader2, _EventEmitter);
4759
- var _super = _createSuper$2(NetLoader2);
4843
+ var _super = _createSuper$1(NetLoader2);
4760
4844
  function NetLoader2(cfg) {
4761
4845
  var _this;
4762
4846
  _classCallCheck$2(this, NetLoader2);
@@ -5299,7 +5383,7 @@ function _possibleConstructorReturn$1(self, call) {
5299
5383
  }
5300
5384
  return _assertThisInitialized$1(self);
5301
5385
  }
5302
- function _createSuper$1(Derived) {
5386
+ function _createSuper(Derived) {
5303
5387
  var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
5304
5388
  return function _createSuperInternal() {
5305
5389
  var Super = _getPrototypeOf$1(Derived), result;
@@ -5443,6 +5527,26 @@ var VideoTrack = /* @__PURE__ */ function() {
5443
5527
  this.warnings = [];
5444
5528
  this.hvcC = null;
5445
5529
  }
5530
+ }, {
5531
+ key: "firstDts",
5532
+ get: function get() {
5533
+ return this.samples.length ? this.samples[0].dts : null;
5534
+ }
5535
+ }, {
5536
+ key: "firstPts",
5537
+ get: function get() {
5538
+ return this.samples.length ? this.samples[0].pts : null;
5539
+ }
5540
+ }, {
5541
+ key: "samplesDuration",
5542
+ get: function get() {
5543
+ if (this.samples.length > 0) {
5544
+ var first = this.samples[0];
5545
+ var last = this.samples[this.samples.length - 1];
5546
+ return last.dts - first.dts + last.duration;
5547
+ }
5548
+ return 0;
5549
+ }
5446
5550
  }, {
5447
5551
  key: "exist",
5448
5552
  value: function exist() {
@@ -5521,6 +5625,26 @@ var AudioTrack = /* @__PURE__ */ function() {
5521
5625
  get: function get() {
5522
5626
  return this.isAudioEncryption;
5523
5627
  }
5628
+ }, {
5629
+ key: "firstDts",
5630
+ get: function get() {
5631
+ return this.samples.length ? this.samples[0].dts : null;
5632
+ }
5633
+ }, {
5634
+ key: "firstPts",
5635
+ get: function get() {
5636
+ return this.samples.length ? this.samples[0].pts : null;
5637
+ }
5638
+ }, {
5639
+ key: "samplesDuration",
5640
+ get: function get() {
5641
+ if (this.samples.length > 0) {
5642
+ var first = this.samples[0];
5643
+ var last = this.samples[this.samples.length - 1];
5644
+ return last.dts - first.dts + last.duration;
5645
+ }
5646
+ return 0;
5647
+ }
5524
5648
  }]);
5525
5649
  return AudioTrack2;
5526
5650
  }();
@@ -5581,7 +5705,7 @@ var Sample = /* @__PURE__ */ _createClass$1(
5581
5705
  );
5582
5706
  var FlvScriptSample = /* @__PURE__ */ function(_Sample) {
5583
5707
  _inherits$1(FlvScriptSample2, _Sample);
5584
- var _super = _createSuper$1(FlvScriptSample2);
5708
+ var _super = _createSuper(FlvScriptSample2);
5585
5709
  function FlvScriptSample2() {
5586
5710
  _classCallCheck$1(this, FlvScriptSample2);
5587
5711
  return _super.apply(this, arguments);
@@ -5590,7 +5714,7 @@ var FlvScriptSample = /* @__PURE__ */ function(_Sample) {
5590
5714
  }(Sample);
5591
5715
  var SeiSample = /* @__PURE__ */ function(_Sample2) {
5592
5716
  _inherits$1(SeiSample2, _Sample2);
5593
- var _super2 = _createSuper$1(SeiSample2);
5717
+ var _super2 = _createSuper(SeiSample2);
5594
5718
  function SeiSample2() {
5595
5719
  _classCallCheck$1(this, SeiSample2);
5596
5720
  return _super2.apply(this, arguments);
@@ -6198,7 +6322,7 @@ function getAvcCodec(codecs) {
6198
6322
  }
6199
6323
  return codec;
6200
6324
  }
6201
- function parse(a) {
6325
+ function parse2(a) {
6202
6326
  if (!Array.isArray(a)) {
6203
6327
  var arr = [];
6204
6328
  var value = "";
@@ -6948,7 +7072,7 @@ var AMF = /* @__PURE__ */ function() {
6948
7072
  }
6949
7073
  _createClass$1(AMF2, null, [{
6950
7074
  key: "parse",
6951
- value: function parse2(data) {
7075
+ value: function parse3(data) {
6952
7076
  if (data.length < 3)
6953
7077
  return;
6954
7078
  var ret = {};
@@ -7513,7 +7637,7 @@ var MP4 = /* @__PURE__ */ function() {
7513
7637
  0,
7514
7638
  0,
7515
7639
  0
7516
- ].concat([16, 119, 239, 236, 192, 178, 77, 2, 172, 227, 60, 30, 82, 226, 251, 75], [0, 0, 0, 1], parse(data.kid), [0, 0, 0, 0]));
7640
+ ].concat([16, 119, 239, 236, 192, 178, 77, 2, 172, 227, 60, 30, 82, 226, 251, 75], [0, 0, 0, 1], parse2(data.kid), [0, 0, 0, 0]));
7517
7641
  return MP42.box(MP42.types.pssh, content);
7518
7642
  }
7519
7643
  }, {
@@ -8001,7 +8125,7 @@ var MP4 = /* @__PURE__ */ function() {
8001
8125
  0,
8002
8126
  data.default_IsEncrypted & 255,
8003
8127
  data.default_IV_size & 255
8004
- ].concat(parse(data.default_KID)));
8128
+ ].concat(parse2(data.default_KID)));
8005
8129
  return MP42.box(MP42.types.tenc, content);
8006
8130
  }
8007
8131
  }, {
@@ -9388,7 +9512,8 @@ var FMP4Remuxer = /* @__PURE__ */ function() {
9388
9512
  }();
9389
9513
  var logger$1 = new Logger$2("BufferService");
9390
9514
  var BufferService = /* @__PURE__ */ function() {
9391
- function BufferService2(flv, softVideo, opts) {
9515
+ function BufferService2(flv, softVideo) {
9516
+ var opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
9392
9517
  _classCallCheck$4(this, BufferService2);
9393
9518
  _defineProperty$3(this, "flv", null);
9394
9519
  _defineProperty$3(this, "_demuxer", new FlvDemuxer());
@@ -9409,7 +9534,9 @@ var BufferService = /* @__PURE__ */ function() {
9409
9534
  this._softVideo = softVideo;
9410
9535
  } else {
9411
9536
  this._remuxer = new FMP4Remuxer(this._demuxer.videoTrack, this._demuxer.audioTrack);
9412
- this._mse = new MSE();
9537
+ this._mse = new MSE(null, {
9538
+ preferMMS: typeof opts.preferMMS === "boolean" ? opts.preferMMS : !!opts.perferMMS
9539
+ });
9413
9540
  this._mse.bindMedia(flv.media);
9414
9541
  }
9415
9542
  }
@@ -9419,6 +9546,12 @@ var BufferService = /* @__PURE__ */ function() {
9419
9546
  var _this$_demuxer, _this$_demuxer$_fixer;
9420
9547
  return (_this$_demuxer = this._demuxer) === null || _this$_demuxer === void 0 ? void 0 : (_this$_demuxer$_fixer = _this$_demuxer._fixer) === null || _this$_demuxer$_fixer === void 0 ? void 0 : _this$_demuxer$_fixer._baseDts;
9421
9548
  }
9549
+ }, {
9550
+ key: "blobUrl",
9551
+ get: function get() {
9552
+ var _this$_mse;
9553
+ return (_this$_mse = this._mse) === null || _this$_mse === void 0 ? void 0 : _this$_mse.url;
9554
+ }
9422
9555
  }, {
9423
9556
  key: "isFull",
9424
9557
  value: function isFull() {
@@ -9658,7 +9791,7 @@ var BufferService = /* @__PURE__ */ function() {
9658
9791
  this._emitMetaParsedEvent(videoTrack, audioTrack);
9659
9792
  }
9660
9793
  if (!mse) {
9661
- _context5.next = 65;
9794
+ _context5.next = 66;
9662
9795
  break;
9663
9796
  }
9664
9797
  if (this._sourceCreated) {
@@ -9680,20 +9813,24 @@ var BufferService = /* @__PURE__ */ function() {
9680
9813
  this.flv.emit(EVENT.SOURCEBUFFER_CREATED);
9681
9814
  case 47:
9682
9815
  _context5.prev = 47;
9816
+ if (this._needInitSegment && !this._opts.mseLowLatency) {
9817
+ videoTrack.duration = this._opts.durationForMSELowLatencyOff * videoTrack.timescale;
9818
+ audioTrack.duration = this._opts.durationForMSELowLatencyOff * audioExist.timescale;
9819
+ }
9683
9820
  remuxResult = this._remuxer.remux(this._needInitSegment);
9684
- _context5.next = 54;
9821
+ _context5.next = 55;
9685
9822
  break;
9686
- case 51:
9687
- _context5.prev = 51;
9823
+ case 52:
9824
+ _context5.prev = 52;
9688
9825
  _context5.t1 = _context5["catch"](47);
9689
9826
  throw new StreamingError(ERR.REMUX, ERR.SUB_TYPES.FMP4, _context5.t1);
9690
- case 54:
9827
+ case 55:
9691
9828
  if (!(this._needInitSegment && !remuxResult.videoInitSegment && !remuxResult.audioInitSegment)) {
9692
- _context5.next = 56;
9829
+ _context5.next = 57;
9693
9830
  break;
9694
9831
  }
9695
9832
  return _context5.abrupt("return");
9696
- case 56:
9833
+ case 57:
9697
9834
  this._needInitSegment = false;
9698
9835
  p = [];
9699
9836
  if (remuxResult.videoInitSegment)
@@ -9705,15 +9842,15 @@ var BufferService = /* @__PURE__ */ function() {
9705
9842
  if (remuxResult.audioSegment)
9706
9843
  p.push(mse.append(audioType, remuxResult.audioSegment));
9707
9844
  return _context5.abrupt("return", Promise.all(p));
9708
- case 65:
9845
+ case 66:
9709
9846
  if (this._softVideo) {
9710
9847
  this._softVideo.appendBuffer(videoTrack, audioTrack);
9711
9848
  }
9712
- case 66:
9849
+ case 67:
9713
9850
  case "end":
9714
9851
  return _context5.stop();
9715
9852
  }
9716
- }, _callee5, this, [[4, 8], [47, 51]]);
9853
+ }, _callee5, this, [[4, 8], [47, 52]]);
9717
9854
  }));
9718
9855
  function appendBuffer(_x2) {
9719
9856
  return _appendBuffer.apply(this, arguments);
@@ -9884,7 +10021,10 @@ function getOption(opts) {
9884
10021
  seamlesslyReload: false,
9885
10022
  keepStatusAfterSwitch: true,
9886
10023
  onlyVideo: false,
9887
- onlyAudio: false
10024
+ onlyAudio: false,
10025
+ preferMMS: false,
10026
+ mseLowLatency: true,
10027
+ durationForMSELowLatencyOff: 6
9888
10028
  }, opts);
9889
10029
  if (ret.isLive) {
9890
10030
  if (ret.preloadTime) {
@@ -9926,9 +10066,10 @@ function searchKeyframeIndex(list, value) {
9926
10066
  }
9927
10067
  var logger = new Logger$2("flv");
9928
10068
  var MAX_HOLE = 0.1;
10069
+ var MAX_START_GAP = 0.3;
9929
10070
  var Flv = /* @__PURE__ */ function(_EventEmitter) {
9930
10071
  _inherits$3(Flv2, _EventEmitter);
9931
- var _super = _createSuper$3(Flv2);
10072
+ var _super = _createSuper$2(Flv2);
9932
10073
  function Flv2(_opts) {
9933
10074
  var _this;
9934
10075
  _classCallCheck$4(this, Flv2);
@@ -10096,10 +10237,13 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10096
10237
  }
10097
10238
  } else {
10098
10239
  if (!media.currentTime && _this._gapService) {
10099
- _this._gapService.do(media, opts.maxJumpDistance, _this.isLive, 3);
10240
+ var gapJump = _this._opts.mseLowLatency || _this._opts.mseLowLatency === false && _this.bufferInfo(MAX_START_GAP).nextStart;
10241
+ if (gapJump) {
10242
+ _this._gapService.do(media, opts.maxJumpDistance, _this.isLive, 3);
10243
+ }
10100
10244
  return;
10101
10245
  }
10102
- if (opts.isLive && bufferEnd > opts.disconnectTime) {
10246
+ if (opts.isLive && media.readyState === 4 && bufferEnd > opts.disconnectTime) {
10103
10247
  _this.disconnect();
10104
10248
  }
10105
10249
  }
@@ -10118,6 +10262,14 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10118
10262
  _this._tick();
10119
10263
  }
10120
10264
  });
10265
+ _defineProperty$3(_assertThisInitialized$3(_this), "_onLoadeddata", function() {
10266
+ if (_this.isLive && !_this._opts.mseLowLatency) {
10267
+ if (_this.media.duration !== Infinity) {
10268
+ _this._bufferService.updateDuration(Infinity).catch(function(e) {
10269
+ });
10270
+ }
10271
+ }
10272
+ });
10121
10273
  _defineProperty$3(_assertThisInitialized$3(_this), "_onSeeking", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
10122
10274
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
10123
10275
  while (1)
@@ -10143,6 +10295,10 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10143
10295
  var latency = bufferEnd - currentTime;
10144
10296
  if (latency >= opts.maxLatency) {
10145
10297
  _this.media.currentTime = bufferEnd - opts.targetLatency;
10298
+ _this.emit(EVENT.CHASEFRAME, {
10299
+ currentTime: _this.media.currentTime,
10300
+ latency: opts.targetLatency
10301
+ });
10146
10302
  }
10147
10303
  }
10148
10304
  _this._seiService.throw(currentTime, true);
@@ -10244,6 +10400,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10244
10400
  _this._gapService = new GapService();
10245
10401
  }
10246
10402
  _this.media.addEventListener("play", _this._onPlay);
10403
+ _this.media.addEventListener("loadeddata", _this._onLoadeddata);
10247
10404
  _this.media.addEventListener("seeking", _this._onSeeking);
10248
10405
  _this.media.addEventListener("timeupdate", _this._onTimeupdate);
10249
10406
  _this.media.addEventListener("progress", _this._onBufferUpdate);
@@ -10254,7 +10411,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10254
10411
  _createClass$4(Flv2, [{
10255
10412
  key: "version",
10256
10413
  get: function get() {
10257
- return "3.0.12";
10414
+ return "3.0.17";
10258
10415
  }
10259
10416
  }, {
10260
10417
  key: "isLive",
@@ -10277,6 +10434,12 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10277
10434
  get: function get() {
10278
10435
  return this._mediaLoader;
10279
10436
  }
10437
+ }, {
10438
+ key: "blobUrl",
10439
+ get: function get() {
10440
+ var _this$_bufferService3;
10441
+ return (_this$_bufferService3 = this._bufferService) === null || _this$_bufferService3 === void 0 ? void 0 : _this$_bufferService3.blobUrl;
10442
+ }
10280
10443
  }, {
10281
10444
  key: "speedInfo",
10282
10445
  value: function speedInfo() {
@@ -10422,10 +10585,10 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10422
10585
  return this._clear();
10423
10586
  case 10:
10424
10587
  setTimeout(function() {
10425
- _this3._loadData(url);
10426
- _this3._bufferService.seamlessSwitch();
10427
10588
  _this3._urlSwitching = true;
10428
10589
  _this3._seamlessSwitching = true;
10590
+ _this3._loadData(url);
10591
+ _this3._bufferService.seamlessSwitch();
10429
10592
  });
10430
10593
  case 11:
10431
10594
  case "end":
@@ -10455,16 +10618,17 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10455
10618
  this.removeAllListeners();
10456
10619
  this._seiService.reset();
10457
10620
  this.media.removeEventListener("play", this._onPlay);
10621
+ this.media.removeEventListener("loadeddata", this._onLoadeddata);
10458
10622
  this.media.removeEventListener("seeking", this._onSeeking);
10459
10623
  this.media.removeEventListener("timeupdate", this._onTimeupdate);
10460
10624
  this.media.removeEventListener("waiting", this._onWaiting);
10461
10625
  this.media.removeEventListener("progress", this._onBufferUpdate);
10462
- _context7.next = 11;
10626
+ _context7.next = 12;
10463
10627
  return Promise.all([this._clear(), this._bufferService.destroy()]);
10464
- case 11:
10628
+ case 12:
10465
10629
  this.media = null;
10466
10630
  this._bufferService = null;
10467
- case 13:
10631
+ case 14:
10468
10632
  case "end":
10469
10633
  return _context7.stop();
10470
10634
  }
@@ -10546,7 +10710,8 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10546
10710
  }
10547
10711
  this._mediaLoader.finnalUrl = finnalUrl;
10548
10712
  this.emit(EVENT.LOAD_START, {
10549
- url: finnalUrl
10713
+ url: finnalUrl,
10714
+ seamlessSwitching: this._seamlessSwitching
10550
10715
  });
10551
10716
  logger.debug("load data, loading:", this._loading, finnalUrl);
10552
10717
  if (!this._loading) {
@@ -10724,7 +10889,7 @@ var PluginExtension = /* @__PURE__ */ function() {
10724
10889
  }();
10725
10890
  var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
10726
10891
  _inherits$3(FlvPlugin2, _BasePlugin);
10727
- var _super = _createSuper$3(FlvPlugin2);
10892
+ var _super = _createSuper$2(FlvPlugin2);
10728
10893
  function FlvPlugin2() {
10729
10894
  var _this;
10730
10895
  _classCallCheck$4(this, FlvPlugin2);
@@ -10829,8 +10994,8 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
10829
10994
  BasePlugin.defineGetterOrSetter(this.player, {
10830
10995
  url: {
10831
10996
  get: function get() {
10832
- var _this2$flv, _this2$flv$media;
10833
- return (_this2$flv = _this2.flv) === null || _this2$flv === void 0 ? void 0 : (_this2$flv$media = _this2$flv.media) === null || _this2$flv$media === void 0 ? void 0 : _this2$flv$media.src;
10997
+ var _this2$flv;
10998
+ return (_this2$flv = _this2.flv) === null || _this2$flv === void 0 ? void 0 : _this2$flv.blobUrl;
10834
10999
  },
10835
11000
  configurable: true
10836
11001
  }
@@ -10868,6 +11033,7 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
10868
11033
  this._transCoreEvent(EVENT.REMOVE_BUFFER);
10869
11034
  this._transCoreEvent(EVENT.BUFFEREOS);
10870
11035
  this._transCoreEvent(EVENT.KEYFRAME);
11036
+ this._transCoreEvent(EVENT.CHASEFRAME);
10871
11037
  this._transCoreEvent(EVENT.METADATA_PARSED);
10872
11038
  this._transCoreEvent(EVENT.SEI);
10873
11039
  this._transCoreEvent(EVENT.SEI_IN_TIME);
@@ -10909,10 +11075,44 @@ var FlvPlugin = /* @__PURE__ */ function(_BasePlugin) {
10909
11075
  value: function isSupported(mediaType, codec) {
10910
11076
  return Flv.isSupported(mediaType, codec);
10911
11077
  }
11078
+ }, {
11079
+ key: "isSupportedMMS",
11080
+ value: function isSupportedMMS() {
11081
+ return typeof ManagedMediaSource !== "undefined";
11082
+ }
10912
11083
  }]);
10913
11084
  return FlvPlugin2;
10914
11085
  }(BasePlugin);
10915
11086
  _defineProperty$3(FlvPlugin, "Flv", Flv);
11087
+ function _callSuper(t, o, e) {
11088
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
11089
+ }
11090
+ function _isNativeReflectConstruct() {
11091
+ try {
11092
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
11093
+ }));
11094
+ } catch (t2) {
11095
+ }
11096
+ return (_isNativeReflectConstruct = function() {
11097
+ return !!t;
11098
+ })();
11099
+ }
11100
+ function _toPrimitive(t, r) {
11101
+ if ("object" != typeof t || !t)
11102
+ return t;
11103
+ var e = t[Symbol.toPrimitive];
11104
+ if (void 0 !== e) {
11105
+ var i = e.call(t, r || "default");
11106
+ if ("object" != typeof i)
11107
+ return i;
11108
+ throw new TypeError("@@toPrimitive must return a primitive value.");
11109
+ }
11110
+ return ("string" === r ? String : Number)(t);
11111
+ }
11112
+ function _toPropertyKey(t) {
11113
+ var i = _toPrimitive(t, "string");
11114
+ return "symbol" == typeof i ? i : String(i);
11115
+ }
10916
11116
  function _classCallCheck(instance, Constructor) {
10917
11117
  if (!(instance instanceof Constructor)) {
10918
11118
  throw new TypeError("Cannot call a class as a function");
@@ -10968,21 +11168,6 @@ function _setPrototypeOf(o, p) {
10968
11168
  };
10969
11169
  return _setPrototypeOf(o, p);
10970
11170
  }
10971
- function _isNativeReflectConstruct() {
10972
- if (typeof Reflect === "undefined" || !Reflect.construct)
10973
- return false;
10974
- if (Reflect.construct.sham)
10975
- return false;
10976
- if (typeof Proxy === "function")
10977
- return true;
10978
- try {
10979
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
10980
- }));
10981
- return true;
10982
- } catch (e) {
10983
- return false;
10984
- }
10985
- }
10986
11171
  function _assertThisInitialized(self) {
10987
11172
  if (self === void 0) {
10988
11173
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -10997,41 +11182,11 @@ function _possibleConstructorReturn(self, call) {
10997
11182
  }
10998
11183
  return _assertThisInitialized(self);
10999
11184
  }
11000
- function _createSuper(Derived) {
11001
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
11002
- return function _createSuperInternal() {
11003
- var Super = _getPrototypeOf(Derived), result;
11004
- if (hasNativeReflectConstruct) {
11005
- var NewTarget = _getPrototypeOf(this).constructor;
11006
- result = Reflect.construct(Super, arguments, NewTarget);
11007
- } else {
11008
- result = Super.apply(this, arguments);
11009
- }
11010
- return _possibleConstructorReturn(this, result);
11011
- };
11012
- }
11013
- function _toPrimitive(input, hint) {
11014
- if (typeof input !== "object" || input === null)
11015
- return input;
11016
- var prim = input[Symbol.toPrimitive];
11017
- if (prim !== void 0) {
11018
- var res = prim.call(input, hint || "default");
11019
- if (typeof res !== "object")
11020
- return res;
11021
- throw new TypeError("@@toPrimitive must return a primitive value.");
11022
- }
11023
- return (hint === "string" ? String : Number)(input);
11024
- }
11025
- function _toPropertyKey(arg) {
11026
- var key = _toPrimitive(arg, "string");
11027
- return typeof key === "symbol" ? key : String(key);
11028
- }
11029
11185
  var Adaptive = /* @__PURE__ */ function(_BasePlugin) {
11030
11186
  _inherits(Adaptive2, _BasePlugin);
11031
- var _super = _createSuper(Adaptive2);
11032
11187
  function Adaptive2() {
11033
11188
  _classCallCheck(this, Adaptive2);
11034
- return _super.apply(this, arguments);
11189
+ return _callSuper(this, Adaptive2, arguments);
11035
11190
  }
11036
11191
  _createClass(Adaptive2, [{
11037
11192
  key: "afterCreate",