@volcengine/veplayer-plugin 2.4.2-rc.4 → 2.4.3-rc.1

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 (31) hide show
  1. package/esm/index.development.js +2124 -1344
  2. package/esm/index.production.js +4 -4
  3. package/esm/veplayer.plugin.abr.development.js +71 -3
  4. package/esm/veplayer.plugin.abr.production.js +1 -1
  5. package/esm/veplayer.plugin.drm.development.js +71 -3
  6. package/esm/veplayer.plugin.drm.production.js +1 -1
  7. package/esm/veplayer.plugin.flv.development.js +727 -196
  8. package/esm/veplayer.plugin.flv.production.js +1 -1
  9. package/esm/veplayer.plugin.hls.development.js +1346 -372
  10. package/esm/veplayer.plugin.hls.production.js +1 -1
  11. package/esm/veplayer.plugin.mp4.development.js +73 -5
  12. package/esm/veplayer.plugin.mp4.production.js +1 -1
  13. package/esm/veplayer.plugin.rtm.development.js +189 -778
  14. package/esm/veplayer.plugin.rtm.production.js +1 -1
  15. package/esm/veplayer.plugin.shaka.development.js +72 -4
  16. package/esm/veplayer.plugin.shaka.production.js +1 -1
  17. package/package.json +1 -1
  18. package/umd/veplayer.plugin.abr.development.js +71 -3
  19. package/umd/veplayer.plugin.abr.production.js +1 -1
  20. package/umd/veplayer.plugin.drm.development.js +71 -3
  21. package/umd/veplayer.plugin.drm.production.js +1 -1
  22. package/umd/veplayer.plugin.flv.development.js +727 -196
  23. package/umd/veplayer.plugin.flv.production.js +1 -1
  24. package/umd/veplayer.plugin.hls.development.js +1313 -339
  25. package/umd/veplayer.plugin.hls.production.js +1 -1
  26. package/umd/veplayer.plugin.mp4.development.js +73 -5
  27. package/umd/veplayer.plugin.mp4.production.js +1 -1
  28. package/umd/veplayer.plugin.rtm.development.js +189 -778
  29. package/umd/veplayer.plugin.rtm.production.js +1 -1
  30. package/umd/veplayer.plugin.shaka.development.js +72 -4
  31. package/umd/veplayer.plugin.shaka.production.js +1 -1
@@ -896,8 +896,7 @@ function hook(hookName, handler) {
896
896
  }
897
897
  if (this.__hooks && this.__hooks[hookName]) {
898
898
  try {
899
- var _this$__hooks$hookNam;
900
- var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
899
+ var preRet = runHooks(this, hookName, handler);
901
900
  if (preRet) {
902
901
  if (preRet.then) {
903
902
  preRet.then(function(isContinue) {
@@ -922,6 +921,19 @@ function hook(hookName, handler) {
922
921
  }
923
922
  }.bind(this);
924
923
  }
924
+ function findHookIndex(hookName, handler) {
925
+ var __hooks = this.__hooks;
926
+ if (!__hooks || !Array.isArray(__hooks[hookName])) {
927
+ return -1;
928
+ }
929
+ var hookHandlers = __hooks[hookName];
930
+ for (var i = 0; i < hookHandlers.length; i++) {
931
+ if (hookHandlers[i] === handler) {
932
+ return i;
933
+ }
934
+ }
935
+ return -1;
936
+ }
925
937
  function useHooks(hookName, handler) {
926
938
  var __hooks = this.__hooks;
927
939
  if (!__hooks) {
@@ -931,7 +943,12 @@ function useHooks(hookName, handler) {
931
943
  console.warn("has no supported hook which name [".concat(hookName, "]"));
932
944
  return false;
933
945
  }
934
- __hooks && (__hooks[hookName] = handler);
946
+ if (!Array.isArray(__hooks[hookName])) {
947
+ __hooks[hookName] = [];
948
+ }
949
+ if (findHookIndex.call(this, hookName, handler) === -1) {
950
+ __hooks[hookName].push(handler);
951
+ }
935
952
  return true;
936
953
  }
937
954
  function removeHooks(hookName, handler) {
@@ -939,6 +956,13 @@ function removeHooks(hookName, handler) {
939
956
  if (!__hooks) {
940
957
  return;
941
958
  }
959
+ if (Array.isArray(__hooks[hookName])) {
960
+ var hooks = __hooks[hookName];
961
+ var index = findHookIndex.call(this, hookName, handler);
962
+ if (index !== -1) {
963
+ hooks.splice(index, 1);
964
+ }
965
+ }
942
966
  delete __hooks[hookName];
943
967
  }
944
968
  function hooksDescriptor(instance) {
@@ -960,6 +984,38 @@ function hooksDescriptor(instance) {
960
984
  function delHooksDescriptor(instance) {
961
985
  instance.__hooks = null;
962
986
  }
987
+ function runHooks(obj, hookName, handler) {
988
+ for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
989
+ args[_key5 - 3] = arguments[_key5];
990
+ }
991
+ if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
992
+ var hooks = obj.__hooks[hookName];
993
+ var index = -1;
994
+ var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
995
+ for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
996
+ args2[_key6 - 3] = arguments[_key6];
997
+ }
998
+ index++;
999
+ if (hooks.length === 0 || index === hooks.length) {
1000
+ return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
1001
+ }
1002
+ var hook2 = hooks[index];
1003
+ var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
1004
+ if (ret && ret.then) {
1005
+ return ret.then(function(data) {
1006
+ return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1007
+ }).catch(function(e) {
1008
+ console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
1009
+ });
1010
+ } else if (ret !== false) {
1011
+ return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1012
+ }
1013
+ };
1014
+ return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
1015
+ } else {
1016
+ return handler.call.apply(handler, [obj, obj].concat(args));
1017
+ }
1018
+ }
963
1019
  function showErrorMsg(pluginName, msg) {
964
1020
  XG_DEBUG.logError("[".concat(pluginName, "] event or callback cant be undefined or null when call ").concat(msg));
965
1021
  }
@@ -1199,6 +1255,18 @@ var BasePlugin = /* @__PURE__ */ function() {
1199
1255
  }
1200
1256
  }
1201
1257
  }
1258
+ }, {
1259
+ key: "defineMethod",
1260
+ value: function defineMethod(Obj, map) {
1261
+ for (var key in map) {
1262
+ if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
1263
+ Object.defineProperty(Obj, key, {
1264
+ configurable: true,
1265
+ value: map[key]
1266
+ });
1267
+ }
1268
+ }
1269
+ }
1202
1270
  }, {
1203
1271
  key: "defaultConfig",
1204
1272
  get: function get() {