@volcengine/veplayer-plugin 2.8.0-rc.2 → 2.8.1-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.
@@ -1807,6 +1807,8 @@ var sniffer = {
1807
1807
  var ua = navigator.userAgent;
1808
1808
  var isWindowsPhone = /(?:Windows Phone)/.test(ua);
1809
1809
  var isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone;
1810
+ var isTizen = /(?:Tizen)/ig.test(ua);
1811
+ var isWebOS = /(?:Web0S)/ig.test(ua);
1810
1812
  var isAndroid = /(?:Android)/.test(ua);
1811
1813
  var isFireFox = /(?:Firefox)/.test(ua);
1812
1814
  var isIpad = /(?:iPad|PlayBook)/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
@@ -1822,7 +1824,9 @@ var sniffer = {
1822
1824
  isPc,
1823
1825
  isSymbian,
1824
1826
  isWindowsPhone,
1825
- isFireFox
1827
+ isFireFox,
1828
+ isTizen,
1829
+ isWebOS
1826
1830
  };
1827
1831
  },
1828
1832
  get osVersion() {
@@ -2548,6 +2552,7 @@ var Plugin = /* @__PURE__ */ function(_BasePlugin) {
2548
2552
  this.icons = {};
2549
2553
  this.root = null;
2550
2554
  this.parent = null;
2555
+ this.extraEls = [];
2551
2556
  var _orgicons = this.registerIcons() || {};
2552
2557
  registerIconsObj(_orgicons, this);
2553
2558
  this.langText = {};
@@ -2890,6 +2895,7 @@ var Plugin = /* @__PURE__ */ function(_BasePlugin) {
2890
2895
  ["root", "parent"].map(function(item) {
2891
2896
  _this7[item] = null;
2892
2897
  });
2898
+ this.extraEls = [];
2893
2899
  }
2894
2900
  }], [{
2895
2901
  key: "insert",
@@ -3006,12 +3012,6 @@ var STATES = {
3006
3012
  ENDED: 7,
3007
3013
  DESTROYED: 8
3008
3014
  };
3009
- function PlaySvg() {
3010
- return new DOMParser().parseFromString('<svg class="play" xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="3 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3011
- }
3012
- function PauseSvg() {
3013
- return new DOMParser().parseFromString('<svg class="pause" xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="3 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3014
- }
3015
3015
  function xgIconTips(plugin2, textKey, isShow) {
3016
3016
  try {
3017
3017
  return ' <div class="xg-tips '.concat(isShow ? "hide" : " ", '" lang-key="').concat(plugin2.i18nKeys[textKey], '">\n ').concat(plugin2.i18n[textKey], "\n </div>");
@@ -3019,1400 +3019,1547 @@ function xgIconTips(plugin2, textKey, isShow) {
3019
3019
  return '<div class="xg-tips hide"></div>';
3020
3020
  }
3021
3021
  }
3022
- var TPL = [{
3023
- tag: "xg-cache",
3024
- className: "xgplayer-progress-cache",
3025
- styleKey: "cachedColor"
3026
- }, {
3027
- tag: "xg-played",
3028
- className: "xgplayer-progress-played",
3029
- styleKey: "playedColor"
3030
- }];
3031
- var InnerList = /* @__PURE__ */ function() {
3032
- function InnerList2(args) {
3033
- _classCallCheck$1(this, InnerList2);
3034
- this.fragments = args.fragments || [];
3035
- if (this.fragments.length === 0) {
3036
- this.fragments.push({
3037
- percent: 1
3022
+ var Icon = /* @__PURE__ */ function(_Plugin) {
3023
+ _inherits(Icon2, _Plugin);
3024
+ var _super = _createSuper(Icon2);
3025
+ function Icon2() {
3026
+ var _this;
3027
+ _classCallCheck$1(this, Icon2);
3028
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3029
+ args[_key] = arguments[_key];
3030
+ }
3031
+ _this = _super.call.apply(_super, [this].concat(args));
3032
+ _defineProperty$1(_assertThisInitialized(_this), "_onMouseenter", function(e4) {
3033
+ _this.emit("icon_mouseenter", {
3034
+ pluginName: _this.pluginName
3035
+ });
3036
+ });
3037
+ _defineProperty$1(_assertThisInitialized(_this), "_onMouseLeave", function(e4) {
3038
+ _this.emit("icon_mouseleave", {
3039
+ pluginName: _this.pluginName
3038
3040
  });
3041
+ });
3042
+ return _this;
3043
+ }
3044
+ _createClass$1(Icon2, [{
3045
+ key: "afterCreate",
3046
+ value: function afterCreate() {
3047
+ this.bind("mouseenter", this._onMouseenter);
3048
+ this.bind("mouseleave", this._onMouseLeave);
3049
+ if (this.config.disable) {
3050
+ this.disable();
3051
+ }
3039
3052
  }
3040
- this._callBack = args.actionCallback;
3041
- this.fragConfig = {
3042
- fragFocusClass: args.fragFocusClass || "inner-focus-point",
3043
- fragAutoFocus: !!args.fragAutoFocus,
3044
- fragClass: args.fragClass || ""
3045
- };
3046
- this.style = args.style || {
3047
- playedColor: "",
3048
- cachedColor: "",
3049
- progressColor: ""
3050
- };
3051
- this.duration = 0;
3052
- this.cachedIndex = 0;
3053
- this.playedIndex = 0;
3054
- this.focusIndex = -1;
3053
+ }, {
3054
+ key: "destroy",
3055
+ value: function destroy() {
3056
+ this.unbind("mouseenter", this._onMouseenter);
3057
+ this.unbind("mouseleave", this._onMouseLeave);
3058
+ }
3059
+ }]);
3060
+ return Icon2;
3061
+ }(Plugin);
3062
+ function CssFullSceenSvg() {
3063
+ return new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg" width="31" height="40" viewBox="0 -5 31 40">
3064
+ <path fill="#fff" transform="scale(1.3, 1.3)" class='path_full' d="M9,10v1a.9.9,0,0,1-1,1,.9.9,0,0,1-1-1V9A.9.9,0,0,1,8,8h2a.9.9,0,0,1,1,1,.9.9,0,0,1-1,1Zm6,4V13a1,1,0,0,1,2,0v2a.9.9,0,0,1-1,1H14a1,1,0,0,1,0-2Zm3-7H6V17H18Zm2,0V17a2,2,0,0,1-2,2H6a2,2,0,0,1-2-2V7A2,2,0,0,1,6,5H18A2,2,0,0,1,20,7Z"></path>
3065
+ </svg>
3066
+ `, "image/svg+xml").firstChild;
3067
+ }
3068
+ function ExitCssFullSceenSvg() {
3069
+ return new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" width="31" height="40" viewBox="0 -5 31 40">\n <path fill="#fff" transform="scale(1.3, 1.3)" d="M9,10V9a.9.9,0,0,1,1-1,.9.9,0,0,1,1,1v2a.9.9,0,0,1-1,1H8a.9.9,0,0,1-1-1,.9.9,0,0,1,1-1Zm6,4v1a1,1,0,0,1-2,0V13a.9.9,0,0,1,1-1h2a1,1,0,0,1,0,2Zm3-7H6V17H18Zm2,0V17a2,2,0,0,1-2,2H6a2,2,0,0,1-2-2V7A2,2,0,0,1,6,5H18A2,2,0,0,1,20,7Z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3070
+ }
3071
+ var CssFullScreen = /* @__PURE__ */ function(_IconPlugin) {
3072
+ _inherits(CssFullScreen2, _IconPlugin);
3073
+ var _super = _createSuper(CssFullScreen2);
3074
+ function CssFullScreen2() {
3075
+ _classCallCheck$1(this, CssFullScreen2);
3076
+ return _super.apply(this, arguments);
3055
3077
  }
3056
- _createClass$1(InnerList2, [{
3057
- key: "updateDuration",
3058
- value: function updateDuration(duration) {
3059
- var _this = this;
3060
- this.duration = duration;
3061
- var start = 0;
3062
- var fragments = this.fragments;
3063
- this.fragments = fragments.map(function(item) {
3064
- item.start = parseInt(start, 10);
3065
- item.end = parseInt(start + item.percent * _this.duration, 10);
3066
- item.duration = parseInt(item.percent * _this.duration, 10);
3067
- start += item.percent * _this.duration;
3068
- return item;
3069
- });
3078
+ _createClass$1(CssFullScreen2, [{
3079
+ key: "beforeCreate",
3080
+ value: function beforeCreate(args) {
3081
+ if (typeof args.player.config.cssFullscreen === "boolean") {
3082
+ args.config.disable = !args.player.config.cssFullscreen;
3083
+ }
3070
3084
  }
3071
3085
  }, {
3072
- key: "updateProgress",
3073
- value: function updateProgress() {
3074
- var type = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "played";
3075
- var data = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
3076
- newIndex: 0,
3077
- curIndex: 0,
3078
- millisecond: 0
3079
- };
3080
- var progressList = this.progressList, fragments = this.fragments;
3081
- if (progressList.length < 1) {
3086
+ key: "afterCreate",
3087
+ value: function afterCreate() {
3088
+ var _this = this;
3089
+ _get(_getPrototypeOf(CssFullScreen2.prototype), "afterCreate", this).call(this);
3090
+ if (this.config.disable) {
3082
3091
  return;
3083
3092
  }
3084
- var newIndex = data.newIndex, curIndex = data.curIndex, millisecond = data.millisecond;
3085
- if (newIndex !== curIndex) {
3086
- progressList.map(function(item, index2) {
3087
- if (index2 < newIndex) {
3088
- item[type].style.width = "100%";
3089
- } else if (index2 > newIndex) {
3090
- item[type].style.width = 0;
3091
- }
3092
- });
3093
+ if (this.config.target) {
3094
+ this.playerConfig.fullscreenTarget = this.config.target;
3093
3095
  }
3094
- var curPFrag = fragments[newIndex];
3095
- var per = millisecond === 0 ? 0 : (millisecond - curPFrag.start) / curPFrag.duration;
3096
- progressList[newIndex][type].style.width = per < 0 ? 0 : "".concat(per * 100, "%");
3096
+ this.initIcons();
3097
+ this.on(CSS_FULLSCREEN_CHANGE, function(isCssfullScreen) {
3098
+ _this.animate(isCssfullScreen);
3099
+ });
3100
+ this.btnClick = this.btnClick.bind(this);
3101
+ this.handleCssFullscreen = this.hook("cssFullscreen_change", this.btnClick, {
3102
+ pre: function pre(e4) {
3103
+ e4.preventDefault();
3104
+ e4.stopPropagation();
3105
+ }
3106
+ });
3107
+ this.bind(["click", "touchend"], this.handleCssFullscreen);
3097
3108
  }
3098
3109
  }, {
3099
- key: "updateFocus",
3100
- value: function updateFocus(data) {
3101
- if (!this.fragConfig.fragAutoFocus || this.fragments.length < 2) {
3110
+ key: "initIcons",
3111
+ value: function initIcons() {
3112
+ var icons = this.icons;
3113
+ var contentIcon = this.find(".xgplayer-icon");
3114
+ contentIcon.appendChild(icons.cssFullscreen);
3115
+ contentIcon.appendChild(icons.exitCssFullscreen);
3116
+ }
3117
+ }, {
3118
+ key: "btnClick",
3119
+ value: function btnClick(e4) {
3120
+ e4.preventDefault();
3121
+ e4.stopPropagation();
3122
+ var isCssfullScreen = this.player.isCssfullScreen;
3123
+ this.emitUserAction(e4, "switch_cssfullscreen", {
3124
+ cssfullscreen: isCssfullScreen
3125
+ });
3126
+ if (!isCssfullScreen) {
3127
+ this.player.getCssFullscreen();
3128
+ } else {
3129
+ this.player.exitCssFullscreen();
3130
+ }
3131
+ }
3132
+ }, {
3133
+ key: "animate",
3134
+ value: function animate(isFullScreen) {
3135
+ if (!this.root) {
3102
3136
  return;
3103
3137
  }
3104
- if (!data) {
3105
- if (this.focusIndex > -1) {
3106
- this.unHightLight(this.focusIndex);
3107
- var _data = {
3108
- index: -1,
3109
- preIndex: this.focusIndex,
3110
- fragment: null
3111
- };
3112
- this._callBack && this._callBack(_data);
3113
- this.focusIndex = -1;
3138
+ isFullScreen ? this.setAttr("data-state", "full") : this.setAttr("data-state", "normal");
3139
+ this.switchTips(isFullScreen);
3140
+ }
3141
+ }, {
3142
+ key: "switchTips",
3143
+ value: function switchTips(isFullScreen) {
3144
+ var i18nKeys = this.i18nKeys;
3145
+ var tipDom = this.find(".xg-tips");
3146
+ tipDom && this.changeLangTextKey(tipDom, isFullScreen ? i18nKeys.EXITCSSFULLSCREEN_TIPS : i18nKeys.CSSFULLSCREEN_TIPS);
3147
+ }
3148
+ }, {
3149
+ key: "registerIcons",
3150
+ value: function registerIcons() {
3151
+ return {
3152
+ cssFullscreen: {
3153
+ icon: CssFullSceenSvg,
3154
+ class: "xg-get-cssfull"
3155
+ },
3156
+ exitCssFullscreen: {
3157
+ icon: ExitCssFullSceenSvg,
3158
+ class: "xg-exit-cssfull"
3114
3159
  }
3160
+ };
3161
+ }
3162
+ }, {
3163
+ key: "destroy",
3164
+ value: function destroy() {
3165
+ _get(_getPrototypeOf(CssFullScreen2.prototype), "destroy", this).call(this);
3166
+ this.unbind(["click", "touchend"], this.btnClick);
3167
+ }
3168
+ }, {
3169
+ key: "render",
3170
+ value: function render() {
3171
+ if (this.config.disable) {
3115
3172
  return;
3116
3173
  }
3117
- var newPIndex = this.findIndex(data.currentTime * 1e3, this.focusIndex);
3118
- if (newPIndex >= 0 && newPIndex !== this.focusIndex) {
3119
- this.focusIndex > -1 && this.unHightLight(this.focusIndex);
3120
- this.setHightLight(newPIndex);
3121
- var _data2 = {
3122
- index: newPIndex,
3123
- preIndex: this.focusIndex,
3124
- fragment: this.fragments[this.focusIndex]
3125
- };
3126
- this.focusIndex = newPIndex;
3127
- this._callBack && this._callBack(_data2);
3128
- }
3174
+ return `<xg-icon class='xgplayer-cssfullscreen'>
3175
+ <div class="xgplayer-icon">
3176
+ </div>
3177
+ `.concat(xgIconTips(this, "CSSFULLSCREEN_TIPS", this.playerConfig.isHideTips), "\n </xg-icon>");
3178
+ }
3179
+ }], [{
3180
+ key: "pluginName",
3181
+ get: function get() {
3182
+ return "cssFullscreen";
3129
3183
  }
3130
3184
  }, {
3131
- key: "update",
3132
- value: function update() {
3133
- var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
3134
- cached: 0,
3135
- played: 0
3185
+ key: "defaultConfig",
3186
+ get: function get() {
3187
+ return {
3188
+ position: POSITIONS.CONTROLS_RIGHT,
3189
+ index: 1,
3190
+ disable: false,
3191
+ target: null
3136
3192
  };
3137
- var duration = arguments.length > 1 ? arguments[1] : void 0;
3138
- if (!this.duration || parseInt(duration * 1e3, 10) !== this.duration) {
3139
- if (!duration && duration !== 0) {
3140
- return;
3141
- }
3142
- this.updateDuration(parseInt(duration * 1e3, 10));
3143
- }
3144
- var playedIndex = this.playedIndex, cachedIndex = this.cachedIndex;
3145
- if (util$3.typeOf(data.played) !== "Undefined") {
3146
- var newPIndex = this.findIndex(data.played * 1e3, playedIndex);
3147
- if (newPIndex < 0) {
3148
- return;
3149
- }
3150
- this.updateProgress("played", {
3151
- newIndex: newPIndex,
3152
- curIndex: playedIndex,
3153
- millisecond: parseInt(data.played * 1e3, 10)
3154
- });
3155
- this.playedIndex = newPIndex;
3156
- }
3157
- if (util$3.typeOf(data.cached) !== "Undefined") {
3158
- var newCIndex = this.findIndex(data.cached * 1e3, cachedIndex);
3159
- if (newCIndex < 0) {
3160
- return;
3161
- }
3162
- this.updateProgress("cached", {
3163
- newIndex: newCIndex,
3164
- curIndex: cachedIndex,
3165
- millisecond: parseInt(data.cached * 1e3, 10)
3166
- });
3167
- this.cachedIndex = newCIndex;
3168
- }
3169
- }
3170
- }, {
3171
- key: "findIndex",
3172
- value: function findIndex(time, curIndex) {
3173
- var fragments = this.fragments;
3174
- if (!fragments || fragments.length === 0) {
3175
- return -1;
3176
- }
3177
- if (fragments.length === 1) {
3178
- return 0;
3179
- }
3180
- if (curIndex > -1 && curIndex < fragments.length && time > fragments[curIndex].start && time < fragments[curIndex].end) {
3181
- return curIndex;
3182
- }
3183
- if (time > fragments[fragments.length - 1].start) {
3184
- return fragments.length - 1;
3185
- }
3186
- for (var i2 = 0; i2 < fragments.length; i2++) {
3187
- if (time > fragments[i2].start && time <= fragments[i2].end) {
3188
- curIndex = i2;
3189
- break;
3190
- }
3191
- }
3192
- return curIndex;
3193
3193
  }
3194
- }, {
3195
- key: "findHightLight",
3196
- value: function findHightLight() {
3197
- var children = this.root.children;
3198
- for (var i2 = 0; i2 < children.length; i2++) {
3199
- if (util$3.hasClass(children[i2], this.fragConfig.fragFocusClass)) {
3200
- return {
3201
- dom: children[i2],
3202
- pos: children[i2].getBoundingClientRect()
3203
- };
3204
- }
3205
- }
3194
+ }]);
3195
+ return CssFullScreen2;
3196
+ }(Icon);
3197
+ function BackSVG() {
3198
+ return new DOMParser().parseFromString('<svg width="32px" height="40px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <path d="M11.2374369,14 L17.6187184,7.61871843 C17.9604272,7.27700968 17.9604272,6.72299032 17.6187184,6.38128157 C17.2770097,6.03957281 16.7229903,6.03957281 16.3812816,6.38128157 L9.38128157,13.3812816 C9.03957281,13.7229903 9.03957281,14.2770097 9.38128157,14.6187184 L16.3812816,21.6187184 C16.7229903,21.9604272 17.2770097,21.9604272 17.6187184,21.6187184 C17.9604272,21.2770097 17.9604272,20.7229903 17.6187184,20.3812816 L11.2374369,14 L11.2374369,14 Z" fill="#FFFFFF"></path>\n </g>\n</svg>', "image/svg+xml").firstChild;
3199
+ }
3200
+ var TopBackIcon = /* @__PURE__ */ function(_Plugin) {
3201
+ _inherits(TopBackIcon2, _Plugin);
3202
+ var _super = _createSuper(TopBackIcon2);
3203
+ function TopBackIcon2() {
3204
+ _classCallCheck$1(this, TopBackIcon2);
3205
+ return _super.apply(this, arguments);
3206
+ }
3207
+ _createClass$1(TopBackIcon2, [{
3208
+ key: "afterCreate",
3209
+ value: function afterCreate() {
3210
+ var _this = this;
3211
+ this.initIcons();
3212
+ this.onClick = function(e4) {
3213
+ e4.preventDefault();
3214
+ e4.stopPropagation();
3215
+ _this.config.onClick(e4);
3216
+ };
3217
+ this.bind(["click", "touchend"], this.onClick);
3206
3218
  }
3207
3219
  }, {
3208
- key: "findFragment",
3209
- value: function findFragment(index2) {
3210
- var children = this.root.children;
3211
- if (index2 < 0 || index2 >= children.length) {
3212
- return null;
3213
- }
3220
+ key: "registerIcons",
3221
+ value: function registerIcons() {
3214
3222
  return {
3215
- dom: children[index2],
3216
- pos: children[index2].getBoundingClientRect()
3223
+ screenBack: {
3224
+ icon: BackSVG,
3225
+ class: "xg-fullscreen-back"
3226
+ }
3217
3227
  };
3218
3228
  }
3219
3229
  }, {
3220
- key: "unHightLight",
3221
- value: function unHightLight() {
3222
- var children = this.root.children;
3223
- for (var i2 = 0; i2 < children.length; i2++) {
3224
- util$3.removeClass(children[i2], this.fragConfig.fragFocusClass);
3225
- }
3226
- }
3227
- }, {
3228
- key: "setHightLight",
3229
- value: function setHightLight(index2) {
3230
- var children = this.root.children;
3231
- if (index2 < children.length) {
3232
- util$3.addClass(children[index2], this.fragConfig.fragFocusClass);
3233
- return {
3234
- dom: children[index2],
3235
- pos: children[index2].getBoundingClientRect()
3236
- };
3237
- }
3230
+ key: "initIcons",
3231
+ value: function initIcons() {
3232
+ var icons = this.icons;
3233
+ this.appendChild(this.root, icons.screenBack);
3238
3234
  }
3239
3235
  }, {
3240
- key: "destroy",
3241
- value: function destroy() {
3242
- this.progressList = null;
3243
- this.fragments = null;
3244
- this.root.innerHTML = "";
3236
+ key: "show",
3237
+ value: function show() {
3238
+ util$3.addClass(this.root, "show");
3245
3239
  }
3246
3240
  }, {
3247
- key: "reset",
3248
- value: function reset(newOptions) {
3249
- var _this2 = this;
3250
- Object.keys(this.fragConfig).forEach(function(key) {
3251
- if (newOptions[key] !== void 0) {
3252
- _this2.fragConfig[key] = newOptions[key];
3253
- }
3254
- });
3255
- if (newOptions.fragments) {
3256
- this.fragments = newOptions.fragments.length === 0 ? [{
3257
- percent: 1
3258
- }] : newOptions.fragments;
3259
- this.updateDuration(this.duration);
3260
- this.playedIndex = 0;
3261
- this.cachedIndex = 0;
3262
- if (this.root) {
3263
- var _c = this.root.children;
3264
- while (_c.length > 0) {
3265
- this.root.removeChild(_c[0]);
3266
- }
3267
- }
3268
- this.render();
3269
- }
3241
+ key: "hide",
3242
+ value: function hide() {
3243
+ util$3.removeClass(this.root, "show");
3270
3244
  }
3271
3245
  }, {
3272
3246
  key: "render",
3273
3247
  value: function render() {
3274
- var _this3 = this;
3275
- var progressColor = this.style.progressColor;
3276
- if (!this.root) {
3277
- this.root = util$3.createDom("xg-inners", "", {}, "progress-list");
3278
- }
3279
- if (this.fragments) {
3280
- var _this$fragConfig = this.fragConfig, fragClass = _this$fragConfig.fragClass, fragFocusClass = _this$fragConfig.fragFocusClass;
3281
- this.progressList = this.fragments.map(function(item) {
3282
- var inner = util$3.createDom("xg-inner", "", {
3283
- style: progressColor ? "background:".concat(progressColor, "; flex: ").concat(item.percent) : "flex: ".concat(item.percent)
3284
- }, "".concat(item.isFocus ? fragFocusClass : "", " xgplayer-progress-inner ").concat(fragClass));
3285
- _this3.root.appendChild(inner);
3286
- TPL.forEach(function(item2) {
3287
- inner.appendChild(util$3.createDom(item2.tag, "", {
3288
- style: item2.styleKey ? "background: ".concat(_this3.style[item2.styleKey], "; width:0;") : "width:0;"
3289
- }, item2.className));
3290
- });
3291
- return {
3292
- cached: inner.children[0],
3293
- played: inner.children[1]
3294
- };
3295
- });
3296
- }
3297
- return this.root;
3248
+ return '<xg-icon class="xgplayer-back">\n </xg-icon>';
3249
+ }
3250
+ }], [{
3251
+ key: "pluginName",
3252
+ get: function get() {
3253
+ return "topbackicon";
3254
+ }
3255
+ }, {
3256
+ key: "defaultConfig",
3257
+ get: function get() {
3258
+ return {
3259
+ position: POSITIONS.ROOT_TOP,
3260
+ index: 0
3261
+ };
3298
3262
  }
3299
3263
  }]);
3300
- return InnerList2;
3301
- }();
3302
- var FRAGMENT_FOCUS_CLASS = {
3303
- POINT: "inner-focus-point",
3304
- HIGHLIGHT: "inner-focus-highlight"
3305
- };
3306
- var Progress = /* @__PURE__ */ function(_Plugin) {
3307
- _inherits(Progress2, _Plugin);
3308
- var _super = _createSuper(Progress2);
3309
- function Progress2(args) {
3264
+ return TopBackIcon2;
3265
+ }(Plugin);
3266
+ function FullScreenSvg() {
3267
+ return new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="2 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M598 214h212v212h-84v-128h-128v-84zM726 726v-128h84v212h-212v-84h128zM214 426v-212h212v84h-128v128h-84zM298 598v128h128v84h-212v-212h84z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3268
+ }
3269
+ function ExitFullScreenSvg() {
3270
+ return new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="2 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M682 342h128v84h-212v-212h84v128zM598 810v-212h212v84h-128v128h-84zM342 342v-128h84v212h-212v-84h128zM214 682v-84h212v212h-84v-128h-128z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3271
+ }
3272
+ var Fullscreen = /* @__PURE__ */ function(_IconPlugin) {
3273
+ _inherits(Fullscreen2, _IconPlugin);
3274
+ var _super = _createSuper(Fullscreen2);
3275
+ function Fullscreen2() {
3310
3276
  var _this;
3311
- _classCallCheck$1(this, Progress2);
3312
- _this = _super.call(this, args);
3313
- _defineProperty$1(_assertThisInitialized(_this), "onMoveOnly", function(e4, data) {
3314
- var _assertThisInitialize = _assertThisInitialized(_this), pos = _assertThisInitialize.pos, config = _assertThisInitialize.config, player = _assertThisInitialize.player;
3315
- var ret = data;
3316
- if (e4) {
3317
- util$3.event(e4);
3318
- var _ePos = util$3.getEventPos(e4, player.zoom);
3319
- var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
3320
- if (pos.moving && Math.abs(pos.x - x2) < config.miniMoveStep) {
3321
- return;
3277
+ _classCallCheck$1(this, Fullscreen2);
3278
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3279
+ args[_key] = arguments[_key];
3280
+ }
3281
+ _this = _super.call.apply(_super, [this].concat(args));
3282
+ _defineProperty$1(_assertThisInitialized(_this), "_onOrientationChange", function(e4) {
3283
+ if (_this.player.fullscreen && _this.config.rotateFullscreen) {
3284
+ if (window.orientation === 90 || window.orientation === -90) {
3285
+ _this.player.setRotateDeg(0);
3286
+ } else {
3287
+ _this.player.setRotateDeg(90);
3322
3288
  }
3323
- pos.moving = true;
3324
- pos.x = x2;
3325
- ret = _this.computeTime(e4, x2);
3326
- }
3327
- _this.triggerCallbacks("dragmove", ret, e4);
3328
- _this._updateInnerFocus(ret);
3329
- });
3330
- _defineProperty$1(_assertThisInitialized(_this), "onBodyClick", function(e4) {
3331
- if (!_this.pos.isLocked) {
3332
- return;
3333
3289
  }
3334
- _this.pos.isLocked = false;
3335
- e4.preventDefault();
3336
- e4.stopPropagation();
3337
3290
  });
3338
- _defineProperty$1(_assertThisInitialized(_this), "_mouseDownHandler", function(event, data) {
3339
- _this._state.time = data.currentTime;
3340
- _this.updateWidth(data.currentTime, data.seekTime, data.percent, 0);
3341
- _this._updateInnerFocus(data);
3342
- });
3343
- _defineProperty$1(_assertThisInitialized(_this), "_mouseUpHandler", function(e4, data) {
3344
- var _assertThisInitialize2 = _assertThisInitialized(_this), pos = _assertThisInitialize2.pos;
3345
- pos.moving && _this.updateWidth(data.currentTime, data.seekTime, data.percent, 2);
3346
- });
3347
- _defineProperty$1(_assertThisInitialized(_this), "_mouseMoveHandler", function(e4, data) {
3348
- var _assertThisInitialize3 = _assertThisInitialized(_this), _state = _assertThisInitialize3._state, pos = _assertThisInitialize3.pos, config = _assertThisInitialize3.config, player = _assertThisInitialize3.player;
3349
- if (_state.time < data.currentTime) {
3350
- data.forward = true;
3351
- } else {
3352
- data.forward = false;
3353
- }
3354
- _state.time = data.currentTime;
3355
- if (pos.isDown && !pos.moving) {
3356
- pos.moving = true;
3357
- config.isPauseMoving && player.pause();
3358
- _this.triggerCallbacks("dragstart", data, e4);
3359
- _this.emitUserAction("drag", "dragstart", data);
3360
- }
3361
- _this.updateWidth(data.currentTime, data.seekTime, data.percent, 1);
3362
- _this.triggerCallbacks("dragmove", data, e4);
3363
- _this._updateInnerFocus(data);
3364
- });
3365
- _defineProperty$1(_assertThisInitialized(_this), "onMouseDown", function(e4) {
3366
- var _assertThisInitialize4 = _assertThisInitialized(_this), _state = _assertThisInitialize4._state, player = _assertThisInitialize4.player, pos = _assertThisInitialize4.pos, config = _assertThisInitialize4.config, playerConfig = _assertThisInitialize4.playerConfig;
3367
- var _ePos = util$3.getEventPos(e4, player.zoom);
3368
- var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
3369
- if (player.isMini || config.closeMoveSeek || !playerConfig.allowSeekAfterEnded && player.ended) {
3370
- return;
3371
- }
3372
- if (!player.duration && !player.isPlaying) {
3373
- player.play();
3291
+ return _this;
3292
+ }
3293
+ _createClass$1(Fullscreen2, [{
3294
+ key: "afterCreate",
3295
+ value: function afterCreate() {
3296
+ var _this2 = this;
3297
+ _get(_getPrototypeOf(Fullscreen2.prototype), "afterCreate", this).call(this);
3298
+ var config = this.config, playerConfig = this.playerConfig;
3299
+ if (config.disable) {
3374
3300
  return;
3375
3301
  }
3376
- e4.stopPropagation();
3377
- _this.focus();
3378
- util$3.checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
3379
- util$3.checkIsFunction(config.onMoveStart) && config.onMoveStart();
3380
- util$3.event(e4);
3381
- pos.x = x2;
3382
- pos.isDown = true;
3383
- pos.moving = false;
3384
- _state.prePlayTime = player.currentTime;
3385
- player.focus({
3386
- autoHide: false
3387
- });
3388
- _this.isProgressMoving = true;
3389
- util$3.addClass(_this.progressBtn, "active");
3390
- var ret = _this.computeTime(e4, x2);
3391
- ret.prePlayTime = _state.prePlayTime;
3392
- _this._mouseDownHandlerHook(e4, ret);
3393
- var eventType = e4.type;
3394
- if (eventType === "touchstart") {
3395
- _this.root.addEventListener("touchmove", _this.onMouseMove);
3396
- _this.root.addEventListener("touchend", _this.onMouseUp);
3397
- _this.root.addEventListener("touchcancel", _this.onMouseUp);
3398
- } else {
3399
- _this.unbind("mousemove", _this.onMoveOnly);
3400
- document.addEventListener("mousemove", _this.onMouseMove, false);
3401
- document.addEventListener("mouseup", _this.onMouseUp, false);
3302
+ if (config.target) {
3303
+ this.playerConfig.fullscreenTarget = this.config.target;
3402
3304
  }
3403
- return true;
3404
- });
3405
- _defineProperty$1(_assertThisInitialized(_this), "onMouseUp", function(e4) {
3406
- var _assertThisInitialize5 = _assertThisInitialized(_this), player = _assertThisInitialize5.player, config = _assertThisInitialize5.config, pos = _assertThisInitialize5.pos, playerConfig = _assertThisInitialize5.playerConfig, _state = _assertThisInitialize5._state;
3407
- e4.stopPropagation();
3408
- e4.preventDefault();
3409
- util$3.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
3410
- util$3.checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
3411
- util$3.event(e4);
3412
- util$3.removeClass(_this.progressBtn, "active");
3413
- var ret = _this.computeTime(e4, pos.x);
3414
- ret.prePlayTime = _state.prePlayTime;
3415
- if (pos.moving) {
3416
- _this.triggerCallbacks("dragend", ret, e4);
3417
- _this.emitUserAction("drag", "dragend", ret);
3418
- } else {
3419
- _this.triggerCallbacks("click", ret, e4);
3420
- _this.emitUserAction("click", "click", ret);
3305
+ var fullEl = util$3.getFullScreenEl();
3306
+ if (playerConfig.fullscreenTarget === fullEl) {
3307
+ this.player.getFullscreen().catch(function(e4) {
3308
+ });
3421
3309
  }
3422
- _this._mouseUpHandlerHook(e4, ret);
3423
- pos.moving = false;
3424
- pos.isDown = false;
3425
- pos.x = 0;
3426
- pos.y = 0;
3427
- pos.isLocked = true;
3428
- _state.prePlayTime = 0;
3429
- _state.time = 0;
3430
- var eventType = e4.type;
3431
- if (eventType === "touchend" || eventType === "touchcancel") {
3432
- _this.root.removeEventListener("touchmove", _this.onMouseMove);
3433
- _this.root.removeEventListener("touchend", _this.onMouseUp);
3434
- _this.root.removeEventListener("touchcancel", _this.onMouseUp);
3435
- _this.blur();
3436
- } else {
3437
- document.removeEventListener("mousemove", _this.onMouseMove, false);
3438
- document.removeEventListener("mouseup", _this.onMouseUp, false);
3439
- if (!pos.isEnter) {
3440
- _this.onMouseLeave(e4);
3441
- } else {
3442
- playerConfig.isMobileSimulateMode !== "mobile" && _this.bind("mousemove", _this.onMoveOnly);
3310
+ this.initIcons();
3311
+ this.handleFullscreen = this.hook("fullscreenChange", this.toggleFullScreen, {
3312
+ pre: function pre(e4) {
3313
+ var fullscreen = _this2.player.fullscreen;
3314
+ _this2.emitUserAction(e4, "switch_fullscreen", {
3315
+ prop: "fullscreen",
3316
+ from: fullscreen,
3317
+ to: !fullscreen
3318
+ });
3443
3319
  }
3320
+ });
3321
+ this.bind(".xgplayer-fullscreen", ["touchend", "click"], this.handleFullscreen);
3322
+ this.on(FULLSCREEN_CHANGE, function(isFullScreen) {
3323
+ var tipsDom = _this2.find(".xg-tips");
3324
+ tipsDom && _this2.changeLangTextKey(tipsDom, isFullScreen ? _this2.i18nKeys.EXITFULLSCREEN_TIPS : _this2.i18nKeys.FULLSCREEN_TIPS);
3325
+ _this2.animate(isFullScreen);
3326
+ });
3327
+ if (this.config.needBackIcon) {
3328
+ this.topBackIcon = this.player.registerPlugin({
3329
+ plugin: TopBackIcon,
3330
+ options: {
3331
+ config: {
3332
+ onClick: function onClick(e4) {
3333
+ _this2.handleFullscreen(e4);
3334
+ }
3335
+ }
3336
+ }
3337
+ });
3444
3338
  }
3445
- util$3.setTimeout(_assertThisInitialized(_this), function() {
3446
- _this.resetSeekState();
3447
- }, 1);
3448
- player.focus();
3449
- });
3450
- _defineProperty$1(_assertThisInitialized(_this), "onMouseMove", function(e4) {
3451
- var _assertThisInitialize6 = _assertThisInitialized(_this), _state = _assertThisInitialize6._state, pos = _assertThisInitialize6.pos, player = _assertThisInitialize6.player, config = _assertThisInitialize6.config;
3452
- if (util$3.checkTouchSupport()) {
3453
- e4.preventDefault();
3454
- }
3455
- util$3.event(e4);
3456
- var _ePos = util$3.getEventPos(e4, player.zoom);
3457
- var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
3458
- var diff = Math.abs(pos.x - x2);
3459
- if (pos.moving && diff < config.miniMoveStep || !pos.moving && diff < config.miniStartStep) {
3460
- return;
3461
- }
3462
- pos.x = x2;
3463
- var ret = _this.computeTime(e4, x2);
3464
- ret.prePlayTime = _state.prePlayTime;
3465
- _this._mouseMoveHandlerHook(e4, ret);
3466
- });
3467
- _defineProperty$1(_assertThisInitialized(_this), "onMouseOut", function(e4) {
3468
- _this.triggerCallbacks("mouseout", null, e4);
3469
- });
3470
- _defineProperty$1(_assertThisInitialized(_this), "onMouseOver", function(e4) {
3471
- _this.triggerCallbacks("mouseover", null, e4);
3472
- });
3473
- _defineProperty$1(_assertThisInitialized(_this), "onMouseEnter", function(e4) {
3474
- var _assertThisInitialize7 = _assertThisInitialized(_this), player = _assertThisInitialize7.player, pos = _assertThisInitialize7.pos;
3475
- if (pos.isDown || pos.isEnter || player.isMini || !player.config.allowSeekAfterEnded && player.ended) {
3476
- return;
3477
- }
3478
- pos.isEnter = true;
3479
- _this.bind("mousemove", _this.onMoveOnly);
3480
- _this.bind("mouseleave", _this.onMouseLeave);
3481
- util$3.event(e4);
3482
- var _ePos = util$3.getEventPos(e4, player.zoom);
3483
- var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
3484
- var ret = _this.computeTime(e4, x2);
3485
- _this.triggerCallbacks("mouseenter", ret, e4);
3486
- _this.focus();
3487
- });
3488
- _defineProperty$1(_assertThisInitialized(_this), "onMouseLeave", function(e4) {
3489
- _this.triggerCallbacks("mouseleave", null, e4);
3490
- _this.unlock();
3491
- _this._updateInnerFocus(null);
3492
- });
3493
- _defineProperty$1(_assertThisInitialized(_this), "onVideoResize", function() {
3494
- var _this$pos = _this.pos, x2 = _this$pos.x, isDown = _this$pos.isDown, isEnter = _this$pos.isEnter;
3495
- if (isEnter && !isDown) {
3496
- var ret = _this.computeTime(null, x2);
3497
- _this.onMoveOnly(null, ret);
3339
+ if (sniffer.device === "mobile") {
3340
+ window.addEventListener("orientationchange", this._onOrientationChange);
3498
3341
  }
3499
- });
3500
- _this.useable = false;
3501
- _this.isProgressMoving = false;
3502
- _this.__dragCallBacks = [];
3503
- _this._state = {
3504
- now: -1,
3505
- direc: 0,
3506
- time: 0,
3507
- prePlayTime: -1
3508
- };
3509
- _this._disableBlur = false;
3510
- if (typeof _this.config.isDragingSeek === "boolean") {
3511
- console.warn("[XGPLAYER] 'isDragingSeek' is deprecated, please use 'isDraggingSeek' instead");
3512
- _this.config.isDraggingSeek = _this.config.isDragingSeek;
3513
- }
3514
- return _this;
3515
- }
3516
- _createClass$1(Progress2, [{
3517
- key: "offsetDuration",
3518
- get: function get() {
3519
- return this.playerConfig.customDuration || this.player.offsetDuration || this.player.duration;
3520
3342
  }
3521
3343
  }, {
3522
- key: "duration",
3523
- get: function get() {
3524
- return this.playerConfig.customDuration || this.player.duration;
3344
+ key: "registerIcons",
3345
+ value: function registerIcons() {
3346
+ return {
3347
+ fullscreen: {
3348
+ icon: FullScreenSvg,
3349
+ class: "xg-get-fullscreen"
3350
+ },
3351
+ exitFullscreen: {
3352
+ icon: ExitFullScreenSvg,
3353
+ class: "xg-exit-fullscreen"
3354
+ }
3355
+ };
3525
3356
  }
3526
3357
  }, {
3527
- key: "timeOffset",
3528
- get: function get() {
3529
- return this.playerConfig.timeOffset || 0;
3358
+ key: "destroy",
3359
+ value: function destroy() {
3360
+ _get(_getPrototypeOf(Fullscreen2.prototype), "destroy", this).call(this);
3361
+ this.unbind(".xgplayer-icon", sniffer.device === "mobile" ? "touchend" : "click", this.handleFullscreen);
3362
+ if (sniffer.device === "mobile") {
3363
+ window.removeEventListener("orientationchange", this._onOrientationChange);
3364
+ }
3530
3365
  }
3531
3366
  }, {
3532
- key: "currentTime",
3533
- get: function get() {
3534
- var _this$player = this.player, offsetCurrentTime = _this$player.offsetCurrentTime, currentTime = _this$player.currentTime;
3535
- return offsetCurrentTime >= 0 ? offsetCurrentTime : currentTime + this.timeOffset;
3367
+ key: "initIcons",
3368
+ value: function initIcons() {
3369
+ var icons = this.icons;
3370
+ this.appendChild(".xgplayer-icon", icons.fullscreen);
3371
+ this.appendChild(".xgplayer-icon", icons.exitFullscreen);
3536
3372
  }
3537
3373
  }, {
3538
- key: "changeState",
3539
- value: function changeState() {
3540
- var useable = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
3541
- this.useable = useable;
3374
+ key: "toggleFullScreen",
3375
+ value: function toggleFullScreen(e4) {
3376
+ if (e4 instanceof Event) {
3377
+ e4.preventDefault();
3378
+ e4.stopPropagation();
3379
+ }
3380
+ var player = this.player, config = this.config;
3381
+ var useCssFullscreen = config.useCssFullscreen === true || typeof config.useCssFullscreen === "function" && config.useCssFullscreen();
3382
+ if (useCssFullscreen) {
3383
+ if (player.fullscreen) {
3384
+ player.exitCssFullscreen();
3385
+ } else {
3386
+ player.getCssFullscreen();
3387
+ }
3388
+ this.animate(player.fullscreen);
3389
+ } else if (config.rotateFullscreen) {
3390
+ if (player.fullscreen) {
3391
+ player.exitRotateFullscreen();
3392
+ } else {
3393
+ player.getRotateFullscreen();
3394
+ }
3395
+ this.animate(player.fullscreen);
3396
+ } else if (config.switchCallback && typeof config.switchCallback === "function") {
3397
+ config.switchCallback(player.fullscreen);
3398
+ } else {
3399
+ if (player.fullscreen) {
3400
+ player.exitFullscreen();
3401
+ if (config.useScreenOrientation) {
3402
+ this.unlockScreen();
3403
+ }
3404
+ } else {
3405
+ player.getFullscreen().catch(function(e22) {
3406
+ });
3407
+ if (config.useScreenOrientation && player.aspectRatio > 1) {
3408
+ this.lockScreen(config.lockOrientationType);
3409
+ }
3410
+ }
3411
+ }
3542
3412
  }
3543
3413
  }, {
3544
- key: "show",
3545
- value: function show(value) {
3546
- this.root && (this.root.style.display = "flex");
3414
+ key: "animate",
3415
+ value: function animate(isFullScreen) {
3416
+ isFullScreen ? this.setAttr("data-state", "full") : this.setAttr("data-state", "normal");
3417
+ if (this.topBackIcon) {
3418
+ if (isFullScreen) {
3419
+ this.topBackIcon.show();
3420
+ this.hide();
3421
+ } else {
3422
+ this.topBackIcon.hide();
3423
+ this.show();
3424
+ }
3425
+ }
3547
3426
  }
3548
3427
  }, {
3549
- key: "_initInner",
3550
- value: function _initInner() {
3551
- var _this2 = this;
3552
- var fragments = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
3553
- var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3554
- if (!fragments || fragments.length === 0) {
3555
- fragments = [{
3556
- percent: 1
3557
- }];
3428
+ key: "render",
3429
+ value: function render() {
3430
+ if (this.config.disable) {
3431
+ return;
3558
3432
  }
3559
- var _c = _objectSpread2(_objectSpread2({
3560
- fragments
3561
- }, config), {}, {
3562
- actionCallback: function actionCallback(data) {
3563
- _this2.emitUserAction("fragment_focus", "fragment_focus", data);
3564
- }
3565
- });
3566
- if (!this.innerList) {
3567
- this.innerList = new InnerList(_c);
3568
- this.outer.insertBefore(this.innerList.render(), this.outer.children[0]);
3569
- ["findHightLight", "unHightLight", "setHightLight", "findFragment"].map(function(item) {
3570
- _this2[item] = _this2.innerList[item].bind(_this2.innerList);
3433
+ var langKey = "FULLSCREEN_TIPS";
3434
+ return '<xg-icon class="xgplayer-fullscreen">\n <div class="xgplayer-icon">\n </div>\n '.concat(xgIconTips(this, langKey, this.playerConfig.isHideTips), "\n </xg-icon>");
3435
+ }
3436
+ }, {
3437
+ key: "lockScreen",
3438
+ value: function lockScreen(orientation) {
3439
+ try {
3440
+ screen.orientation.lock(orientation).catch(function(e4) {
3571
3441
  });
3572
- } else {
3573
- this.innerList.reset(_c);
3442
+ } catch (e4) {
3574
3443
  }
3575
3444
  }
3576
3445
  }, {
3577
- key: "_updateInnerFocus",
3578
- value: function _updateInnerFocus(data) {
3579
- this.innerList && this.innerList.updateFocus(data);
3446
+ key: "unlockScreen",
3447
+ value: function unlockScreen() {
3448
+ try {
3449
+ screen.orientation.unlock().catch(function(e4) {
3450
+ });
3451
+ } catch (e4) {
3452
+ }
3453
+ }
3454
+ }], [{
3455
+ key: "pluginName",
3456
+ get: function get() {
3457
+ return "fullscreen";
3580
3458
  }
3581
3459
  }, {
3460
+ key: "defaultConfig",
3461
+ get: function get() {
3462
+ return {
3463
+ position: POSITIONS.CONTROLS_RIGHT,
3464
+ index: 0,
3465
+ useCssFullscreen: false,
3466
+ rotateFullscreen: false,
3467
+ useScreenOrientation: false,
3468
+ lockOrientationType: "landscape",
3469
+ switchCallback: null,
3470
+ target: null,
3471
+ disable: false,
3472
+ needBackIcon: false
3473
+ };
3474
+ }
3475
+ }]);
3476
+ return Fullscreen2;
3477
+ }(Icon);
3478
+ function PlayIcon() {
3479
+ return new DOMParser().parseFromString('<svg class="play" xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="3 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3480
+ }
3481
+ function PauseIcon() {
3482
+ return new DOMParser().parseFromString('<svg class="pause" xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="3 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z"></path>\n</svg>\n', "image/svg+xml").firstChild;
3483
+ }
3484
+ var Play = /* @__PURE__ */ function(_IconPlugin) {
3485
+ _inherits(Play2, _IconPlugin);
3486
+ var _super = _createSuper(Play2);
3487
+ function Play2() {
3488
+ var _this;
3489
+ _classCallCheck$1(this, Play2);
3490
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3491
+ args[_key] = arguments[_key];
3492
+ }
3493
+ _this = _super.call.apply(_super, [this].concat(args));
3494
+ _defineProperty$1(_assertThisInitialized(_this), "btnClick", function(e4) {
3495
+ e4.preventDefault();
3496
+ e4.stopPropagation();
3497
+ var _assertThisInitialize = _assertThisInitialized(_this), player = _assertThisInitialize.player;
3498
+ _this.emitUserAction(e4, "switch_play_pause", {
3499
+ prop: "paused",
3500
+ from: player.paused,
3501
+ to: !player.paused
3502
+ });
3503
+ if (player.ended) {
3504
+ player.replay();
3505
+ } else if (player.paused) {
3506
+ player.play();
3507
+ _this.animate(false);
3508
+ } else {
3509
+ player.pause();
3510
+ _this.animate(true);
3511
+ }
3512
+ return false;
3513
+ });
3514
+ return _this;
3515
+ }
3516
+ _createClass$1(Play2, [{
3582
3517
  key: "afterCreate",
3583
3518
  value: function afterCreate() {
3584
- if (this.config.disable || this.playerConfig.isLive) {
3519
+ _get(_getPrototypeOf(Play2.prototype), "afterCreate", this).call(this);
3520
+ var config = this.config;
3521
+ if (config.disable) {
3585
3522
  return;
3586
3523
  }
3587
- this.pos = {
3588
- x: 0,
3589
- y: 0,
3590
- moving: false,
3591
- isDown: false,
3592
- isEnter: false,
3593
- isLocked: false
3594
- };
3595
- this.outer = this.find("xg-outer");
3596
- var _this$config = this.config, fragFocusClass = _this$config.fragFocusClass, fragAutoFocus = _this$config.fragAutoFocus, fragClass = _this$config.fragClass;
3597
- this._initInner(this.config.fragments, {
3598
- fragFocusClass,
3599
- fragAutoFocus,
3600
- fragClass,
3601
- style: this.playerConfig.commonStyle || {}
3602
- });
3603
- if (sniffer.device === "mobile") {
3604
- this.config.isDraggingSeek = false;
3605
- this.isMobile = true;
3606
- }
3607
- this.progressBtn = this.find(".xgplayer-progress-btn");
3524
+ this.initIcons();
3525
+ this.bind(["touchend", "click"], this.btnClick);
3608
3526
  this.listenEvents();
3609
- this.bindDomEvents();
3610
- this.initCustomStyle();
3527
+ this.animate(true);
3611
3528
  }
3612
3529
  }, {
3613
3530
  key: "listenEvents",
3614
3531
  value: function listenEvents() {
3615
- var _this3 = this;
3616
- this.on(DURATION_CHANGE, function() {
3617
- _this3.onMouseLeave();
3618
- });
3619
- this.on(TIME_UPDATE, function() {
3620
- _this3.onTimeupdate();
3621
- });
3622
- this.on(SEEKED, function() {
3623
- _this3.onTimeupdate();
3624
- _this3.onCacheUpdate();
3625
- });
3626
- this.on(PROGRESS, function() {
3627
- _this3.onCacheUpdate();
3628
- });
3629
- this.on(ENDED, function() {
3630
- _this3.onCacheUpdate(true);
3631
- _this3.onTimeupdate(true);
3632
- _this3._state.now = 0;
3633
- });
3634
- this.on(EMPTIED, function() {
3635
- _this3.onReset();
3636
- });
3637
- this.on(VIDEO_RESIZE, function() {
3638
- _this3.onVideoResize();
3639
- });
3640
- }
3641
- }, {
3642
- key: "setConfig",
3643
- value: function setConfig(config) {
3644
- var _this4 = this;
3645
- var frags = null;
3646
- Object.keys(config).forEach(function(key) {
3647
- _this4.config[key] = config[key];
3648
- if (key === "fragments") {
3649
- frags = config[key];
3650
- }
3532
+ var _this2 = this;
3533
+ var player = this.player;
3534
+ this.on([PLAY, PAUSE, ERROR, EMPTIED], function() {
3535
+ _this2.animate(player.paused);
3651
3536
  });
3652
- if (frags) {
3653
- this._initInner(frags, config);
3654
- }
3655
3537
  }
3656
3538
  }, {
3657
- key: "initCustomStyle",
3658
- value: function initCustomStyle() {
3659
- var _ref = this.playerConfig || {}, commonStyle = _ref.commonStyle;
3660
- var sliderBtnStyle = commonStyle.sliderBtnStyle;
3661
- var progressBtn = this.progressBtn;
3662
- if (sliderBtnStyle) {
3663
- if (typeof sliderBtnStyle === "string") {
3664
- progressBtn.style.boxShadow = sliderBtnStyle;
3665
- } else if (_typeof$1(sliderBtnStyle) === "object") {
3666
- Object.keys(sliderBtnStyle).map(function(key) {
3667
- progressBtn.style[key] = sliderBtnStyle[key];
3668
- });
3539
+ key: "registerIcons",
3540
+ value: function registerIcons() {
3541
+ return {
3542
+ play: {
3543
+ icon: PlayIcon,
3544
+ class: "xg-icon-play"
3545
+ },
3546
+ pause: {
3547
+ icon: PauseIcon,
3548
+ class: "xg-icon-pause"
3669
3549
  }
3670
- }
3550
+ };
3671
3551
  }
3672
3552
  }, {
3673
- key: "triggerCallbacks",
3674
- value: function triggerCallbacks(type, data, event) {
3675
- if (this.__dragCallBacks.length > 0) {
3676
- this.__dragCallBacks.map(function(item) {
3677
- if (item && item.handler && item.type === type) {
3678
- try {
3679
- item.handler(data, event);
3680
- } catch (error) {
3681
- console.error("[XGPLAYER][triggerCallbacks] ".concat(item, " error"), error);
3682
- }
3683
- }
3684
- });
3685
- }
3553
+ key: "initIcons",
3554
+ value: function initIcons() {
3555
+ var icons = this.icons;
3556
+ this.appendChild(".xgplayer-icon", icons.play);
3557
+ this.appendChild(".xgplayer-icon", icons.pause);
3686
3558
  }
3687
3559
  }, {
3688
- key: "addCallBack",
3689
- value: function addCallBack(type, handle) {
3690
- if (handle && typeof handle === "function") {
3691
- this.__dragCallBacks.push({
3692
- type,
3693
- handler: handle
3694
- });
3560
+ key: "animate",
3561
+ value: function animate(paused) {
3562
+ if (!this.player) {
3563
+ return;
3564
+ }
3565
+ var i18nKeys = this.i18nKeys;
3566
+ var tipDom = this.find(".xg-tips");
3567
+ if (paused) {
3568
+ this.setAttr("data-state", "pause");
3569
+ tipDom && this.changeLangTextKey(tipDom, i18nKeys.PLAY_TIPS);
3570
+ } else {
3571
+ this.setAttr("data-state", "play");
3572
+ tipDom && this.changeLangTextKey(tipDom, i18nKeys.PAUSE_TIPS);
3695
3573
  }
3696
3574
  }
3697
3575
  }, {
3698
- key: "removeCallBack",
3699
- value: function removeCallBack(type, event) {
3700
- var __dragCallBacks = this.__dragCallBacks;
3701
- var _index = -1;
3702
- __dragCallBacks.map(function(item, index2) {
3703
- if (item && item.type === type && item.handler === event) {
3704
- _index = index2;
3705
- }
3706
- });
3707
- if (_index > -1) {
3708
- __dragCallBacks.splice(_index, 1);
3709
- }
3576
+ key: "destroy",
3577
+ value: function destroy() {
3578
+ _get(_getPrototypeOf(Play2.prototype), "destroy", this).call(this);
3579
+ this.unbind(["touchend", "click"], this.btnClick);
3710
3580
  }
3711
3581
  }, {
3712
- key: "unlock",
3713
- value: function unlock() {
3714
- var player = this.player, pos = this.pos;
3715
- pos.isEnter = false;
3716
- pos.isLocked = false;
3717
- if (player.isMini) {
3718
- return;
3719
- }
3720
- this.unbind("mousemove", this.onMoveOnly);
3721
- if (pos.isDown) {
3722
- this.unbind("mouseleave", this.onMouseLeave);
3582
+ key: "render",
3583
+ value: function render() {
3584
+ if (this.config.disable) {
3723
3585
  return;
3724
3586
  }
3725
- this.blur();
3587
+ return '<xg-icon class="xgplayer-play">\n <div class="xgplayer-icon">\n </div>\n '.concat(xgIconTips(this, "PLAY_TIPS", this.playerConfig.isHideTips), "\n </xg-icon>");
3726
3588
  }
3727
- }, {
3728
- key: "bindDomEvents",
3729
- value: function bindDomEvents() {
3730
- var config = this.player.config;
3731
- this._mouseDownHandlerHook = this.hook("dragstart", this._mouseDownHandler);
3732
- this._mouseUpHandlerHook = this.hook("dragend", this._mouseUpHandler);
3733
- this._mouseMoveHandlerHook = this.hook("drag", this._mouseMoveHandler);
3734
- if (this.domEventType === "touch" || this.domEventType === "compatible") {
3735
- this.root.addEventListener("touchstart", this.onMouseDown);
3736
- }
3737
- if (this.domEventType === "mouse" || this.domEventType === "compatible") {
3738
- this.bind("mousedown", this.onMouseDown);
3739
- config.isMobileSimulateMode !== "mobile" && this.bind("mouseenter", this.onMouseEnter);
3740
- this.bind("mouseover", this.onMouseOver);
3741
- this.bind("mouseout", this.onMouseOut);
3742
- this.player.root.addEventListener("click", this.onBodyClick, true);
3743
- }
3589
+ }], [{
3590
+ key: "pluginName",
3591
+ get: function get() {
3592
+ return "play";
3744
3593
  }
3745
3594
  }, {
3746
- key: "focus",
3747
- value: function focus() {
3748
- this.player.controls.pauseAutoHide();
3749
- util$3.addClass(this.root, "active");
3595
+ key: "defaultConfig",
3596
+ get: function get() {
3597
+ return {
3598
+ position: POSITIONS.CONTROLS_LEFT,
3599
+ index: 0,
3600
+ disable: false
3601
+ };
3750
3602
  }
3751
- }, {
3752
- key: "blur",
3753
- value: function blur() {
3754
- if (this._disableBlur) {
3755
- return;
3756
- }
3757
- this.player.controls.recoverAutoHide();
3758
- util$3.removeClass(this.root, "active");
3603
+ }]);
3604
+ return Play2;
3605
+ }(Icon);
3606
+ var TPL = [{
3607
+ tag: "xg-cache",
3608
+ className: "xgplayer-progress-cache",
3609
+ styleKey: "cachedColor"
3610
+ }, {
3611
+ tag: "xg-played",
3612
+ className: "xgplayer-progress-played",
3613
+ styleKey: "playedColor"
3614
+ }];
3615
+ var InnerList = /* @__PURE__ */ function() {
3616
+ function InnerList2(args) {
3617
+ _classCallCheck$1(this, InnerList2);
3618
+ this.fragments = args.fragments || [];
3619
+ if (this.fragments.length === 0) {
3620
+ this.fragments.push({
3621
+ percent: 1
3622
+ });
3759
3623
  }
3760
- }, {
3761
- key: "disableBlur",
3762
- value: function disableBlur() {
3763
- this._disableBlur = true;
3624
+ this._callBack = args.actionCallback;
3625
+ this.fragConfig = {
3626
+ fragFocusClass: args.fragFocusClass || "inner-focus-point",
3627
+ fragAutoFocus: !!args.fragAutoFocus,
3628
+ fragClass: args.fragClass || ""
3629
+ };
3630
+ this.style = args.style || {
3631
+ playedColor: "",
3632
+ cachedColor: "",
3633
+ progressColor: ""
3634
+ };
3635
+ this.duration = 0;
3636
+ this.cachedIndex = 0;
3637
+ this.playedIndex = 0;
3638
+ this.focusIndex = -1;
3639
+ }
3640
+ _createClass$1(InnerList2, [{
3641
+ key: "updateDuration",
3642
+ value: function updateDuration(duration) {
3643
+ var _this = this;
3644
+ this.duration = duration;
3645
+ var start = 0;
3646
+ var fragments = this.fragments;
3647
+ this.fragments = fragments.map(function(item) {
3648
+ item.start = parseInt(start, 10);
3649
+ item.end = parseInt(start + item.percent * _this.duration, 10);
3650
+ item.duration = parseInt(item.percent * _this.duration, 10);
3651
+ start += item.percent * _this.duration;
3652
+ return item;
3653
+ });
3764
3654
  }
3765
3655
  }, {
3766
- key: "enableBlur",
3767
- value: function enableBlur() {
3768
- this._disableBlur = false;
3656
+ key: "updateProgress",
3657
+ value: function updateProgress() {
3658
+ var type = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "played";
3659
+ var data = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
3660
+ newIndex: 0,
3661
+ curIndex: 0,
3662
+ millisecond: 0
3663
+ };
3664
+ var progressList = this.progressList, fragments = this.fragments;
3665
+ if (progressList.length < 1) {
3666
+ return;
3667
+ }
3668
+ var newIndex = data.newIndex, curIndex = data.curIndex, millisecond = data.millisecond;
3669
+ if (newIndex !== curIndex) {
3670
+ progressList.map(function(item, index2) {
3671
+ if (index2 < newIndex) {
3672
+ item[type].style.width = "100%";
3673
+ } else if (index2 > newIndex) {
3674
+ item[type].style.width = 0;
3675
+ }
3676
+ });
3677
+ }
3678
+ var curPFrag = fragments[newIndex];
3679
+ var per = millisecond === 0 ? 0 : (millisecond - curPFrag.start) / curPFrag.duration;
3680
+ progressList[newIndex][type].style.width = per < 0 ? 0 : "".concat(per * 100, "%");
3769
3681
  }
3770
3682
  }, {
3771
- key: "updateWidth",
3772
- value: function updateWidth(currentTime, seekTime, percent, type) {
3773
- var config = this.config, player = this.player;
3774
- if (config.isCloseClickSeek && type === 0) {
3683
+ key: "updateFocus",
3684
+ value: function updateFocus(data) {
3685
+ if (!this.fragConfig.fragAutoFocus || this.fragments.length < 2) {
3775
3686
  return;
3776
3687
  }
3777
- var realTime = seekTime = seekTime >= player.duration ? player.duration - config.endedDiff : Number(seekTime).toFixed(1);
3778
- this.updatePercent(percent);
3779
- this.updateTime(currentTime);
3780
- if (type === 1 && (!config.isDraggingSeek || player.config.mediaType === "audio")) {
3688
+ if (!data) {
3689
+ if (this.focusIndex > -1) {
3690
+ this.unHightLight(this.focusIndex);
3691
+ var _data = {
3692
+ index: -1,
3693
+ preIndex: this.focusIndex,
3694
+ fragment: null
3695
+ };
3696
+ this._callBack && this._callBack(_data);
3697
+ this.focusIndex = -1;
3698
+ }
3781
3699
  return;
3782
3700
  }
3783
- this._state.now = realTime;
3784
- this._state.direc = realTime > player.currentTime ? 0 : 1;
3785
- player.seek(realTime);
3786
- }
3787
- }, {
3788
- key: "computeTime",
3789
- value: function computeTime(e4, x2) {
3790
- var player = this.player;
3791
- var _this$root$getBoundin = this.root.getBoundingClientRect(), width = _this$root$getBoundin.width, height = _this$root$getBoundin.height, top = _this$root$getBoundin.top, left = _this$root$getBoundin.left;
3792
- var rWidth, rLeft;
3793
- var clientX = x2;
3794
- if (player.rotateDeg === 90) {
3795
- rWidth = height;
3796
- rLeft = top;
3797
- } else {
3798
- rWidth = width;
3799
- rLeft = left;
3701
+ var newPIndex = this.findIndex(data.currentTime * 1e3, this.focusIndex);
3702
+ if (newPIndex >= 0 && newPIndex !== this.focusIndex) {
3703
+ this.focusIndex > -1 && this.unHightLight(this.focusIndex);
3704
+ this.setHightLight(newPIndex);
3705
+ var _data2 = {
3706
+ index: newPIndex,
3707
+ preIndex: this.focusIndex,
3708
+ fragment: this.fragments[this.focusIndex]
3709
+ };
3710
+ this.focusIndex = newPIndex;
3711
+ this._callBack && this._callBack(_data2);
3800
3712
  }
3801
- var offset = clientX - rLeft;
3802
- offset = offset > rWidth ? rWidth : offset < 0 ? 0 : offset;
3803
- var percent = offset / rWidth;
3804
- percent = percent < 0 ? 0 : percent > 1 ? 1 : percent;
3805
- var currentTime = parseInt(percent * this.offsetDuration * 1e3, 10) / 1e3;
3806
- var seekTime = util$3.getCurrentTimeByOffset(currentTime, player.timeSegments);
3807
- return {
3808
- percent,
3809
- currentTime,
3810
- seekTime,
3811
- offset,
3812
- width: rWidth,
3813
- left: rLeft,
3814
- e: e4
3815
- };
3816
3713
  }
3817
3714
  }, {
3818
- key: "updateTime",
3819
- value: function updateTime(time) {
3820
- var player = this.player, duration = this.duration;
3821
- if (time > duration) {
3822
- time = duration;
3823
- } else if (time < 0) {
3824
- time = 0;
3715
+ key: "update",
3716
+ value: function update() {
3717
+ var data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
3718
+ cached: 0,
3719
+ played: 0
3720
+ };
3721
+ var duration = arguments.length > 1 ? arguments[1] : void 0;
3722
+ if (!this.duration || parseInt(duration * 1e3, 10) !== this.duration) {
3723
+ if (!duration && duration !== 0) {
3724
+ return;
3725
+ }
3726
+ this.updateDuration(parseInt(duration * 1e3, 10));
3825
3727
  }
3826
- var timeIcon = player.plugins.time;
3827
- if (timeIcon) {
3828
- timeIcon.updateTime(time);
3728
+ var playedIndex = this.playedIndex, cachedIndex = this.cachedIndex;
3729
+ if (util$3.typeOf(data.played) !== "Undefined") {
3730
+ var newPIndex = this.findIndex(data.played * 1e3, playedIndex);
3731
+ if (newPIndex < 0) {
3732
+ return;
3733
+ }
3734
+ this.updateProgress("played", {
3735
+ newIndex: newPIndex,
3736
+ curIndex: playedIndex,
3737
+ millisecond: parseInt(data.played * 1e3, 10)
3738
+ });
3739
+ this.playedIndex = newPIndex;
3740
+ }
3741
+ if (util$3.typeOf(data.cached) !== "Undefined") {
3742
+ var newCIndex = this.findIndex(data.cached * 1e3, cachedIndex);
3743
+ if (newCIndex < 0) {
3744
+ return;
3745
+ }
3746
+ this.updateProgress("cached", {
3747
+ newIndex: newCIndex,
3748
+ curIndex: cachedIndex,
3749
+ millisecond: parseInt(data.cached * 1e3, 10)
3750
+ });
3751
+ this.cachedIndex = newCIndex;
3829
3752
  }
3830
3753
  }
3831
3754
  }, {
3832
- key: "resetSeekState",
3833
- value: function resetSeekState() {
3834
- this.isProgressMoving = false;
3835
- var timeIcon = this.player.plugins.time;
3836
- timeIcon && timeIcon.resetActive();
3755
+ key: "findIndex",
3756
+ value: function findIndex(time, curIndex) {
3757
+ var fragments = this.fragments;
3758
+ if (!fragments || fragments.length === 0) {
3759
+ return -1;
3760
+ }
3761
+ if (fragments.length === 1) {
3762
+ return 0;
3763
+ }
3764
+ if (curIndex > -1 && curIndex < fragments.length && time > fragments[curIndex].start && time < fragments[curIndex].end) {
3765
+ return curIndex;
3766
+ }
3767
+ if (time > fragments[fragments.length - 1].start) {
3768
+ return fragments.length - 1;
3769
+ }
3770
+ for (var i2 = 0; i2 < fragments.length; i2++) {
3771
+ if (time > fragments[i2].start && time <= fragments[i2].end) {
3772
+ curIndex = i2;
3773
+ break;
3774
+ }
3775
+ }
3776
+ return curIndex;
3837
3777
  }
3838
3778
  }, {
3839
- key: "updatePercent",
3840
- value: function updatePercent(percent, notSeek) {
3841
- this.isProgressMoving = true;
3842
- if (this.config.disable) {
3843
- return;
3779
+ key: "findHightLight",
3780
+ value: function findHightLight() {
3781
+ var children = this.root.children;
3782
+ for (var i2 = 0; i2 < children.length; i2++) {
3783
+ if (util$3.hasClass(children[i2], this.fragConfig.fragFocusClass)) {
3784
+ return {
3785
+ dom: children[i2],
3786
+ pos: children[i2].getBoundingClientRect()
3787
+ };
3788
+ }
3844
3789
  }
3845
- percent = percent > 1 ? 1 : percent < 0 ? 0 : percent;
3846
- this.progressBtn.style.left = "".concat(percent * 100, "%");
3847
- this.innerList.update({
3848
- played: percent * this.offsetDuration
3849
- }, this.offsetDuration);
3850
- var miniprogress = this.player.plugins.miniprogress;
3851
- miniprogress && miniprogress.update({
3852
- played: percent * this.offsetDuration
3853
- }, this.offsetDuration);
3854
3790
  }
3855
3791
  }, {
3856
- key: "onTimeupdate",
3857
- value: function onTimeupdate(isEnded) {
3858
- var player = this.player, _state = this._state, offsetDuration = this.offsetDuration;
3859
- if (player.isSeeking && player.media.seeking || this.isProgressMoving || !player.hasStart) {
3860
- return;
3861
- }
3862
- if (_state.now > -1) {
3863
- var abs = parseInt(_state.now * 1e3, 10) - parseInt(player.currentTime * 1e3, 10);
3864
- if (_state.direc === 0 && abs > 300 || _state.direc === 1 && abs > -300) {
3865
- _state.now = -1;
3866
- return;
3867
- } else {
3868
- _state.now = -1;
3869
- }
3792
+ key: "findFragment",
3793
+ value: function findFragment(index2) {
3794
+ var children = this.root.children;
3795
+ if (index2 < 0 || index2 >= children.length) {
3796
+ return null;
3870
3797
  }
3871
- var time = this.currentTime;
3872
- time = util$3.adjustTimeByDuration(time, offsetDuration, isEnded);
3873
- this.innerList.update({
3874
- played: time
3875
- }, offsetDuration);
3876
- this.progressBtn.style.left = "".concat(time / offsetDuration * 100, "%");
3798
+ return {
3799
+ dom: children[index2],
3800
+ pos: children[index2].getBoundingClientRect()
3801
+ };
3877
3802
  }
3878
3803
  }, {
3879
- key: "onCacheUpdate",
3880
- value: function onCacheUpdate(isEnded) {
3881
- var player = this.player, duration = this.duration;
3882
- if (!player) {
3883
- return;
3804
+ key: "unHightLight",
3805
+ value: function unHightLight() {
3806
+ var children = this.root.children;
3807
+ for (var i2 = 0; i2 < children.length; i2++) {
3808
+ util$3.removeClass(children[i2], this.fragConfig.fragFocusClass);
3884
3809
  }
3885
- var _end = player.bufferedPoint.end;
3886
- _end = util$3.adjustTimeByDuration(_end, duration, isEnded);
3887
- this.innerList.update({
3888
- cached: _end
3889
- }, duration);
3890
3810
  }
3891
3811
  }, {
3892
- key: "onReset",
3893
- value: function onReset() {
3894
- this.innerList.update({
3895
- played: 0,
3896
- cached: 0
3897
- }, 0);
3898
- this.progressBtn.style.left = "0%";
3812
+ key: "setHightLight",
3813
+ value: function setHightLight(index2) {
3814
+ var children = this.root.children;
3815
+ if (index2 < children.length) {
3816
+ util$3.addClass(children[index2], this.fragConfig.fragFocusClass);
3817
+ return {
3818
+ dom: children[index2],
3819
+ pos: children[index2].getBoundingClientRect()
3820
+ };
3821
+ }
3899
3822
  }
3900
3823
  }, {
3901
3824
  key: "destroy",
3902
3825
  value: function destroy() {
3903
- var player = this.player;
3904
- this.thumbnailPlugin = null;
3905
- this.innerList.destroy();
3906
- this.innerList = null;
3907
- var domEventType = this.domEventType;
3908
- if (domEventType === "touch" || domEventType === "compatible") {
3909
- this.root.removeEventListener("touchstart", this.onMouseDown);
3910
- this.root.removeEventListener("touchmove", this.onMouseMove);
3911
- this.root.removeEventListener("touchend", this.onMouseUp);
3912
- this.root.removeEventListener("touchcancel", this.onMouseUp);
3826
+ this.progressList = null;
3827
+ this.fragments = null;
3828
+ this.root.innerHTML = "";
3829
+ }
3830
+ }, {
3831
+ key: "reset",
3832
+ value: function reset(newOptions) {
3833
+ var _this2 = this;
3834
+ Object.keys(this.fragConfig).forEach(function(key) {
3835
+ if (newOptions[key] !== void 0) {
3836
+ _this2.fragConfig[key] = newOptions[key];
3837
+ }
3838
+ });
3839
+ if (newOptions.fragments) {
3840
+ this.fragments = newOptions.fragments.length === 0 ? [{
3841
+ percent: 1
3842
+ }] : newOptions.fragments;
3843
+ this.updateDuration(this.duration);
3844
+ this.playedIndex = 0;
3845
+ this.cachedIndex = 0;
3846
+ if (this.root) {
3847
+ var _c = this.root.children;
3848
+ while (_c.length > 0) {
3849
+ this.root.removeChild(_c[0]);
3850
+ }
3851
+ }
3852
+ this.render();
3913
3853
  }
3914
- if (domEventType === "mouse" || domEventType === "compatible") {
3915
- this.unbind("mousedown", this.onMouseDown);
3916
- this.unbind("mouseenter", this.onMouseEnter);
3917
- this.unbind("mousemove", this.onMoveOnly);
3918
- this.unbind("mouseleave", this.onMouseLeave);
3919
- document.removeEventListener("mousemove", this.onMouseMove, false);
3920
- document.removeEventListener("mouseup", this.onMouseUp, false);
3921
- player.root.removeEventListener("click", this.onBodyClick, true);
3854
+ }
3855
+ }, {
3856
+ key: "render",
3857
+ value: function render() {
3858
+ var _this3 = this;
3859
+ var progressColor = this.style.progressColor;
3860
+ if (!this.root) {
3861
+ this.root = util$3.createDom("xg-inners", "", {}, "progress-list");
3862
+ }
3863
+ if (this.fragments) {
3864
+ var _this$fragConfig = this.fragConfig, fragClass = _this$fragConfig.fragClass, fragFocusClass = _this$fragConfig.fragFocusClass;
3865
+ this.progressList = this.fragments.map(function(item) {
3866
+ var inner = util$3.createDom("xg-inner", "", {
3867
+ style: progressColor ? "background:".concat(progressColor, "; flex: ").concat(item.percent) : "flex: ".concat(item.percent)
3868
+ }, "".concat(item.isFocus ? fragFocusClass : "", " xgplayer-progress-inner ").concat(fragClass));
3869
+ _this3.root.appendChild(inner);
3870
+ TPL.forEach(function(item2) {
3871
+ inner.appendChild(util$3.createDom(item2.tag, "", {
3872
+ style: item2.styleKey ? "background: ".concat(_this3.style[item2.styleKey], "; width:0;") : "width:0;"
3873
+ }, item2.className));
3874
+ });
3875
+ return {
3876
+ cached: inner.children[0],
3877
+ played: inner.children[1]
3878
+ };
3879
+ });
3880
+ }
3881
+ return this.root;
3882
+ }
3883
+ }]);
3884
+ return InnerList2;
3885
+ }();
3886
+ var FRAGMENT_FOCUS_CLASS = {
3887
+ POINT: "inner-focus-point",
3888
+ HIGHLIGHT: "inner-focus-highlight"
3889
+ };
3890
+ var Progress = /* @__PURE__ */ function(_Plugin) {
3891
+ _inherits(Progress2, _Plugin);
3892
+ var _super = _createSuper(Progress2);
3893
+ function Progress2(args) {
3894
+ var _this;
3895
+ _classCallCheck$1(this, Progress2);
3896
+ _this = _super.call(this, args);
3897
+ _defineProperty$1(_assertThisInitialized(_this), "onMoveOnly", function(e4, data) {
3898
+ var _assertThisInitialize = _assertThisInitialized(_this), pos = _assertThisInitialize.pos, config = _assertThisInitialize.config, player = _assertThisInitialize.player;
3899
+ var ret = data;
3900
+ if (e4) {
3901
+ util$3.event(e4);
3902
+ var _ePos = util$3.getEventPos(e4, player.zoom);
3903
+ var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
3904
+ if (pos.moving && Math.abs(pos.x - x2) < config.miniMoveStep) {
3905
+ return;
3906
+ }
3907
+ pos.moving = true;
3908
+ pos.x = x2;
3909
+ ret = _this.computeTime(e4, x2);
3910
+ }
3911
+ _this.triggerCallbacks("dragmove", ret, e4);
3912
+ _this._updateInnerFocus(ret);
3913
+ });
3914
+ _defineProperty$1(_assertThisInitialized(_this), "onBodyClick", function(e4) {
3915
+ if (!_this.pos.isLocked) {
3916
+ return;
3917
+ }
3918
+ _this.pos.isLocked = false;
3919
+ e4.preventDefault();
3920
+ e4.stopPropagation();
3921
+ });
3922
+ _defineProperty$1(_assertThisInitialized(_this), "_mouseDownHandler", function(event, data) {
3923
+ _this._state.time = data.currentTime;
3924
+ _this.updateWidth(data.currentTime, data.seekTime, data.percent, 0);
3925
+ _this._updateInnerFocus(data);
3926
+ });
3927
+ _defineProperty$1(_assertThisInitialized(_this), "_mouseUpHandler", function(e4, data) {
3928
+ var _assertThisInitialize2 = _assertThisInitialized(_this), pos = _assertThisInitialize2.pos;
3929
+ pos.moving && _this.updateWidth(data.currentTime, data.seekTime, data.percent, 2);
3930
+ });
3931
+ _defineProperty$1(_assertThisInitialized(_this), "_mouseMoveHandler", function(e4, data) {
3932
+ var _assertThisInitialize3 = _assertThisInitialized(_this), _state = _assertThisInitialize3._state, pos = _assertThisInitialize3.pos, config = _assertThisInitialize3.config, player = _assertThisInitialize3.player;
3933
+ if (_state.time < data.currentTime) {
3934
+ data.forward = true;
3935
+ } else {
3936
+ data.forward = false;
3937
+ }
3938
+ _state.time = data.currentTime;
3939
+ if (pos.isDown && !pos.moving) {
3940
+ pos.moving = true;
3941
+ config.isPauseMoving && player.pause();
3942
+ _this.triggerCallbacks("dragstart", data, e4);
3943
+ _this.emitUserAction("drag", "dragstart", data);
3944
+ }
3945
+ _this.updateWidth(data.currentTime, data.seekTime, data.percent, 1);
3946
+ _this.triggerCallbacks("dragmove", data, e4);
3947
+ _this._updateInnerFocus(data);
3948
+ });
3949
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseDown", function(e4) {
3950
+ var _assertThisInitialize4 = _assertThisInitialized(_this), _state = _assertThisInitialize4._state, player = _assertThisInitialize4.player, pos = _assertThisInitialize4.pos, config = _assertThisInitialize4.config, playerConfig = _assertThisInitialize4.playerConfig;
3951
+ var _ePos = util$3.getEventPos(e4, player.zoom);
3952
+ var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
3953
+ if (player.isMini || config.closeMoveSeek || !playerConfig.allowSeekAfterEnded && player.ended) {
3954
+ return;
3955
+ }
3956
+ if (!player.duration && !player.isPlaying) {
3957
+ player.play();
3958
+ return;
3959
+ }
3960
+ e4.stopPropagation();
3961
+ _this.focus();
3962
+ util$3.checkIsFunction(playerConfig.disableSwipeHandler) && playerConfig.disableSwipeHandler();
3963
+ util$3.checkIsFunction(config.onMoveStart) && config.onMoveStart();
3964
+ util$3.event(e4);
3965
+ pos.x = x2;
3966
+ pos.isDown = true;
3967
+ pos.moving = false;
3968
+ _state.prePlayTime = player.currentTime;
3969
+ player.focus({
3970
+ autoHide: false
3971
+ });
3972
+ _this.isProgressMoving = true;
3973
+ util$3.addClass(_this.progressBtn, "active");
3974
+ var ret = _this.computeTime(e4, x2);
3975
+ ret.prePlayTime = _state.prePlayTime;
3976
+ _this._mouseDownHandlerHook(e4, ret);
3977
+ var eventType = e4.type;
3978
+ if (eventType === "touchstart") {
3979
+ _this.root.addEventListener("touchmove", _this.onMouseMove);
3980
+ _this.root.addEventListener("touchend", _this.onMouseUp);
3981
+ _this.root.addEventListener("touchcancel", _this.onMouseUp);
3982
+ } else {
3983
+ _this.unbind("mousemove", _this.onMoveOnly);
3984
+ document.addEventListener("mousemove", _this.onMouseMove, false);
3985
+ document.addEventListener("mouseup", _this.onMouseUp, false);
3986
+ }
3987
+ return true;
3988
+ });
3989
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseUp", function(e4) {
3990
+ var _assertThisInitialize5 = _assertThisInitialized(_this), player = _assertThisInitialize5.player, config = _assertThisInitialize5.config, pos = _assertThisInitialize5.pos, playerConfig = _assertThisInitialize5.playerConfig, _state = _assertThisInitialize5._state;
3991
+ if (!pos) {
3992
+ return;
3993
+ }
3994
+ e4.stopPropagation();
3995
+ e4.preventDefault();
3996
+ util$3.checkIsFunction(playerConfig.enableSwipeHandler) && playerConfig.enableSwipeHandler();
3997
+ util$3.checkIsFunction(config.onMoveEnd) && config.onMoveEnd();
3998
+ util$3.event(e4);
3999
+ util$3.removeClass(_this.progressBtn, "active");
4000
+ var ret = _this.computeTime(e4, pos.x);
4001
+ ret.prePlayTime = _state.prePlayTime;
4002
+ if (pos.moving) {
4003
+ _this.triggerCallbacks("dragend", ret, e4);
4004
+ _this.emitUserAction("drag", "dragend", ret);
4005
+ } else {
4006
+ _this.triggerCallbacks("click", ret, e4);
4007
+ _this.emitUserAction("click", "click", ret);
4008
+ }
4009
+ _this._mouseUpHandlerHook(e4, ret);
4010
+ pos.moving = false;
4011
+ pos.isDown = false;
4012
+ pos.x = 0;
4013
+ pos.y = 0;
4014
+ pos.isLocked = true;
4015
+ _state.prePlayTime = 0;
4016
+ _state.time = 0;
4017
+ var eventType = e4.type;
4018
+ if (eventType === "touchend" || eventType === "touchcancel") {
4019
+ _this.root.removeEventListener("touchmove", _this.onMouseMove);
4020
+ _this.root.removeEventListener("touchend", _this.onMouseUp);
4021
+ _this.root.removeEventListener("touchcancel", _this.onMouseUp);
4022
+ _this.blur();
4023
+ } else {
4024
+ document.removeEventListener("mousemove", _this.onMouseMove, false);
4025
+ document.removeEventListener("mouseup", _this.onMouseUp, false);
4026
+ if (!pos.isEnter) {
4027
+ _this.onMouseLeave(e4);
4028
+ } else {
4029
+ playerConfig.isMobileSimulateMode !== "mobile" && _this.bind("mousemove", _this.onMoveOnly);
4030
+ }
4031
+ }
4032
+ util$3.setTimeout(_assertThisInitialized(_this), function() {
4033
+ _this.resetSeekState();
4034
+ }, 1);
4035
+ player.focus();
4036
+ });
4037
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseMove", function(e4) {
4038
+ var _assertThisInitialize6 = _assertThisInitialized(_this), _state = _assertThisInitialize6._state, pos = _assertThisInitialize6.pos, player = _assertThisInitialize6.player, config = _assertThisInitialize6.config;
4039
+ if (util$3.checkTouchSupport()) {
4040
+ e4.preventDefault();
3922
4041
  }
3923
- }
3924
- }, {
3925
- key: "render",
3926
- value: function render() {
3927
- if (this.config.disable || this.playerConfig.isLive) {
4042
+ util$3.event(e4);
4043
+ var _ePos = util$3.getEventPos(e4, player.zoom);
4044
+ var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
4045
+ var diff = Math.abs(pos.x - x2);
4046
+ if (pos.moving && diff < config.miniMoveStep || !pos.moving && diff < config.miniStartStep) {
3928
4047
  return;
3929
4048
  }
3930
- var controlsMode = this.player.controls ? this.player.controls.config.mode : "";
3931
- var className = controlsMode === "bottom" ? "xgplayer-progress-bottom" : "";
3932
- return '\n <xg-progress class="xgplayer-progress '.concat(className, '">\n <xg-outer class="xgplayer-progress-outer">\n <xg-progress-btn class="xgplayer-progress-btn"></xg-progress-btn>\n </xg-outer>\n </xg-progress>\n ');
4049
+ pos.x = x2;
4050
+ var ret = _this.computeTime(e4, x2);
4051
+ ret.prePlayTime = _state.prePlayTime;
4052
+ _this._mouseMoveHandlerHook(e4, ret);
4053
+ });
4054
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseOut", function(e4) {
4055
+ _this.triggerCallbacks("mouseout", null, e4);
4056
+ });
4057
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseOver", function(e4) {
4058
+ _this.triggerCallbacks("mouseover", null, e4);
4059
+ });
4060
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseEnter", function(e4) {
4061
+ var _assertThisInitialize7 = _assertThisInitialized(_this), player = _assertThisInitialize7.player, pos = _assertThisInitialize7.pos;
4062
+ if (pos.isDown || pos.isEnter || player.isMini || !player.config.allowSeekAfterEnded && player.ended) {
4063
+ return;
4064
+ }
4065
+ pos.isEnter = true;
4066
+ _this.bind("mousemove", _this.onMoveOnly);
4067
+ _this.bind("mouseleave", _this.onMouseLeave);
4068
+ util$3.event(e4);
4069
+ var _ePos = util$3.getEventPos(e4, player.zoom);
4070
+ var x2 = player.rotateDeg === 90 ? _ePos.clientY : _ePos.clientX;
4071
+ var ret = _this.computeTime(e4, x2);
4072
+ _this.triggerCallbacks("mouseenter", ret, e4);
4073
+ _this.focus();
4074
+ });
4075
+ _defineProperty$1(_assertThisInitialized(_this), "onMouseLeave", function(e4) {
4076
+ _this.triggerCallbacks("mouseleave", null, e4);
4077
+ _this.unlock();
4078
+ _this._updateInnerFocus(null);
4079
+ });
4080
+ _defineProperty$1(_assertThisInitialized(_this), "onVideoResize", function() {
4081
+ var _this$pos = _this.pos, x2 = _this$pos.x, isDown = _this$pos.isDown, isEnter = _this$pos.isEnter;
4082
+ if (isEnter && !isDown) {
4083
+ var ret = _this.computeTime(null, x2);
4084
+ _this.onMoveOnly(null, ret);
4085
+ }
4086
+ });
4087
+ _this.useable = false;
4088
+ _this.isProgressMoving = false;
4089
+ _this.__dragCallBacks = [];
4090
+ _this._state = {
4091
+ now: -1,
4092
+ direc: 0,
4093
+ time: 0,
4094
+ prePlayTime: -1
4095
+ };
4096
+ _this._disableBlur = false;
4097
+ if (typeof _this.config.isDragingSeek === "boolean") {
4098
+ console.warn("[XGPLAYER] 'isDragingSeek' is deprecated, please use 'isDraggingSeek' instead");
4099
+ _this.config.isDraggingSeek = _this.config.isDragingSeek;
3933
4100
  }
3934
- }], [{
3935
- key: "pluginName",
4101
+ return _this;
4102
+ }
4103
+ _createClass$1(Progress2, [{
4104
+ key: "offsetDuration",
3936
4105
  get: function get() {
3937
- return "progress";
4106
+ return this.playerConfig.customDuration || this.player.offsetDuration || this.player.duration;
3938
4107
  }
3939
4108
  }, {
3940
- key: "defaultConfig",
4109
+ key: "duration",
3941
4110
  get: function get() {
3942
- return {
3943
- position: POSITIONS.CONTROLS_CENTER,
3944
- index: 0,
3945
- disable: false,
3946
- isDraggingSeek: true,
3947
- closeMoveSeek: false,
3948
- isPauseMoving: false,
3949
- isCloseClickSeek: false,
3950
- fragments: [{
3951
- percent: 1
3952
- }],
3953
- fragFocusClass: FRAGMENT_FOCUS_CLASS.POINT,
3954
- fragClass: "",
3955
- fragAutoFocus: false,
3956
- miniMoveStep: 5,
3957
- miniStartStep: 2,
3958
- onMoveStart: function onMoveStart() {
3959
- },
3960
- onMoveEnd: function onMoveEnd() {
3961
- },
3962
- endedDiff: 0.2
3963
- };
4111
+ return this.playerConfig.customDuration || this.player.duration;
3964
4112
  }
3965
4113
  }, {
3966
- key: "FRAGMENT_FOCUS_CLASS",
4114
+ key: "timeOffset",
3967
4115
  get: function get() {
3968
- return FRAGMENT_FOCUS_CLASS;
3969
- }
3970
- }]);
3971
- return Progress2;
3972
- }(Plugin);
3973
- var Icon = /* @__PURE__ */ function(_Plugin) {
3974
- _inherits(Icon2, _Plugin);
3975
- var _super = _createSuper(Icon2);
3976
- function Icon2() {
3977
- var _this;
3978
- _classCallCheck$1(this, Icon2);
3979
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3980
- args[_key] = arguments[_key];
3981
- }
3982
- _this = _super.call.apply(_super, [this].concat(args));
3983
- _defineProperty$1(_assertThisInitialized(_this), "_onMouseenter", function(e4) {
3984
- _this.emit("icon_mouseenter", {
3985
- pluginName: _this.pluginName
3986
- });
3987
- });
3988
- _defineProperty$1(_assertThisInitialized(_this), "_onMouseLeave", function(e4) {
3989
- _this.emit("icon_mouseleave", {
3990
- pluginName: _this.pluginName
3991
- });
3992
- });
3993
- return _this;
3994
- }
3995
- _createClass$1(Icon2, [{
3996
- key: "afterCreate",
3997
- value: function afterCreate() {
3998
- this.bind("mouseenter", this._onMouseenter);
3999
- this.bind("mouseleave", this._onMouseLeave);
4000
- if (this.config.disable) {
4001
- this.disable();
4002
- }
4003
- }
4004
- }, {
4005
- key: "destroy",
4006
- value: function destroy() {
4007
- this.unbind("mouseenter", this._onMouseenter);
4008
- this.unbind("mouseleave", this._onMouseLeave);
4009
- }
4010
- }]);
4011
- return Icon2;
4012
- }(Plugin);
4013
- var Play = /* @__PURE__ */ function(_IconPlugin) {
4014
- _inherits(Play2, _IconPlugin);
4015
- var _super = _createSuper(Play2);
4016
- function Play2() {
4017
- var _this;
4018
- _classCallCheck$1(this, Play2);
4019
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4020
- args[_key] = arguments[_key];
4021
- }
4022
- _this = _super.call.apply(_super, [this].concat(args));
4023
- _defineProperty$1(_assertThisInitialized(_this), "btnClick", function(e4) {
4024
- e4.preventDefault();
4025
- e4.stopPropagation();
4026
- var _assertThisInitialize = _assertThisInitialized(_this), player = _assertThisInitialize.player;
4027
- _this.emitUserAction(e4, "switch_play_pause", {
4028
- prop: "paused",
4029
- from: player.paused,
4030
- to: !player.paused
4031
- });
4032
- if (player.ended) {
4033
- player.replay();
4034
- } else if (player.paused) {
4035
- player.play();
4036
- _this.animate(false);
4037
- } else {
4038
- player.pause();
4039
- _this.animate(true);
4040
- }
4041
- return false;
4042
- });
4043
- return _this;
4044
- }
4045
- _createClass$1(Play2, [{
4046
- key: "afterCreate",
4047
- value: function afterCreate() {
4048
- _get(_getPrototypeOf(Play2.prototype), "afterCreate", this).call(this);
4049
- var config = this.config;
4050
- if (config.disable) {
4051
- return;
4052
- }
4053
- this.initIcons();
4054
- this.bind(["touchend", "click"], this.btnClick);
4055
- this.listenEvents();
4056
- this.animate(true);
4116
+ return this.playerConfig.timeOffset || 0;
4057
4117
  }
4058
4118
  }, {
4059
- key: "listenEvents",
4060
- value: function listenEvents() {
4061
- var _this2 = this;
4062
- var player = this.player;
4063
- this.on([PLAY, PAUSE, ERROR, EMPTIED], function() {
4064
- _this2.animate(player.paused);
4065
- });
4119
+ key: "currentTime",
4120
+ get: function get() {
4121
+ var _this$player = this.player, offsetCurrentTime = _this$player.offsetCurrentTime, currentTime = _this$player.currentTime;
4122
+ return offsetCurrentTime >= 0 ? offsetCurrentTime : currentTime + this.timeOffset;
4066
4123
  }
4067
4124
  }, {
4068
- key: "registerIcons",
4069
- value: function registerIcons() {
4070
- return {
4071
- play: {
4072
- icon: PlaySvg,
4073
- class: "xg-icon-play"
4074
- },
4075
- pause: {
4076
- icon: PauseSvg,
4077
- class: "xg-icon-pause"
4078
- }
4079
- };
4125
+ key: "changeState",
4126
+ value: function changeState() {
4127
+ var useable = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
4128
+ this.useable = useable;
4080
4129
  }
4081
4130
  }, {
4082
- key: "initIcons",
4083
- value: function initIcons() {
4084
- var icons = this.icons;
4085
- this.appendChild(".xgplayer-icon", icons.play);
4086
- this.appendChild(".xgplayer-icon", icons.pause);
4131
+ key: "show",
4132
+ value: function show(value) {
4133
+ this.root && (this.root.style.display = "flex");
4087
4134
  }
4088
4135
  }, {
4089
- key: "animate",
4090
- value: function animate(paused) {
4091
- if (!this.player) {
4092
- return;
4136
+ key: "_initInner",
4137
+ value: function _initInner() {
4138
+ var _this2 = this;
4139
+ var fragments = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
4140
+ var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4141
+ if (!fragments || fragments.length === 0) {
4142
+ fragments = [{
4143
+ percent: 1
4144
+ }];
4093
4145
  }
4094
- var i18nKeys = this.i18nKeys;
4095
- var tipDom = this.find(".xg-tips");
4096
- if (paused) {
4097
- this.setAttr("data-state", "pause");
4098
- tipDom && this.changeLangTextKey(tipDom, i18nKeys.PLAY_TIPS);
4146
+ var _c = _objectSpread2(_objectSpread2({
4147
+ fragments
4148
+ }, config), {}, {
4149
+ actionCallback: function actionCallback(data) {
4150
+ _this2.emitUserAction("fragment_focus", "fragment_focus", data);
4151
+ }
4152
+ });
4153
+ if (!this.innerList) {
4154
+ this.innerList = new InnerList(_c);
4155
+ this.outer.insertBefore(this.innerList.render(), this.outer.children[0]);
4156
+ ["findHightLight", "unHightLight", "setHightLight", "findFragment"].map(function(item) {
4157
+ _this2[item] = _this2.innerList[item].bind(_this2.innerList);
4158
+ });
4099
4159
  } else {
4100
- this.setAttr("data-state", "play");
4101
- tipDom && this.changeLangTextKey(tipDom, i18nKeys.PAUSE_TIPS);
4160
+ this.innerList.reset(_c);
4102
4161
  }
4103
4162
  }
4104
4163
  }, {
4105
- key: "destroy",
4106
- value: function destroy() {
4107
- _get(_getPrototypeOf(Play2.prototype), "destroy", this).call(this);
4108
- this.unbind(["touchend", "click"], this.btnClick);
4164
+ key: "_updateInnerFocus",
4165
+ value: function _updateInnerFocus(data) {
4166
+ this.innerList && this.innerList.updateFocus(data);
4109
4167
  }
4110
4168
  }, {
4111
- key: "render",
4112
- value: function render() {
4113
- if (this.config.disable) {
4169
+ key: "afterCreate",
4170
+ value: function afterCreate() {
4171
+ if (this.config.disable || this.playerConfig.isLive) {
4114
4172
  return;
4115
4173
  }
4116
- return '<xg-icon class="xgplayer-play">\n <div class="xgplayer-icon">\n </div>\n '.concat(xgIconTips(this, "PLAY_TIPS", this.playerConfig.isHideTips), "\n </xg-icon>");
4117
- }
4118
- }], [{
4119
- key: "pluginName",
4120
- get: function get() {
4121
- return "play";
4122
- }
4123
- }, {
4124
- key: "defaultConfig",
4125
- get: function get() {
4126
- return {
4127
- position: POSITIONS.CONTROLS_LEFT,
4128
- index: 0,
4129
- disable: false
4174
+ this.pos = {
4175
+ x: 0,
4176
+ y: 0,
4177
+ moving: false,
4178
+ isDown: false,
4179
+ isEnter: false,
4180
+ isLocked: false
4130
4181
  };
4182
+ this.outer = this.find("xg-outer");
4183
+ var _this$config = this.config, fragFocusClass = _this$config.fragFocusClass, fragAutoFocus = _this$config.fragAutoFocus, fragClass = _this$config.fragClass;
4184
+ this._initInner(this.config.fragments, {
4185
+ fragFocusClass,
4186
+ fragAutoFocus,
4187
+ fragClass,
4188
+ style: this.playerConfig.commonStyle || {}
4189
+ });
4190
+ if (sniffer.device === "mobile") {
4191
+ this.config.isDraggingSeek = false;
4192
+ this.isMobile = true;
4193
+ }
4194
+ this.progressBtn = this.find(".xgplayer-progress-btn");
4195
+ this.listenEvents();
4196
+ this.bindDomEvents();
4197
+ this.initCustomStyle();
4131
4198
  }
4132
- }]);
4133
- return Play2;
4134
- }(Icon);
4135
- function BackSVG() {
4136
- return new DOMParser().parseFromString('<svg width="32px" height="40px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n <path d="M11.2374369,14 L17.6187184,7.61871843 C17.9604272,7.27700968 17.9604272,6.72299032 17.6187184,6.38128157 C17.2770097,6.03957281 16.7229903,6.03957281 16.3812816,6.38128157 L9.38128157,13.3812816 C9.03957281,13.7229903 9.03957281,14.2770097 9.38128157,14.6187184 L16.3812816,21.6187184 C16.7229903,21.9604272 17.2770097,21.9604272 17.6187184,21.6187184 C17.9604272,21.2770097 17.9604272,20.7229903 17.6187184,20.3812816 L11.2374369,14 L11.2374369,14 Z" fill="#FFFFFF"></path>\n </g>\n</svg>', "image/svg+xml").firstChild;
4137
- }
4138
- var TopBackIcon = /* @__PURE__ */ function(_Plugin) {
4139
- _inherits(TopBackIcon2, _Plugin);
4140
- var _super = _createSuper(TopBackIcon2);
4141
- function TopBackIcon2() {
4142
- _classCallCheck$1(this, TopBackIcon2);
4143
- return _super.apply(this, arguments);
4144
- }
4145
- _createClass$1(TopBackIcon2, [{
4146
- key: "afterCreate",
4147
- value: function afterCreate() {
4148
- var _this = this;
4149
- this.initIcons();
4150
- this.onClick = function(e4) {
4151
- e4.preventDefault();
4152
- e4.stopPropagation();
4153
- _this.config.onClick(e4);
4154
- };
4155
- this.bind(["click", "touchend"], this.onClick);
4199
+ }, {
4200
+ key: "listenEvents",
4201
+ value: function listenEvents() {
4202
+ var _this3 = this;
4203
+ this.on(DURATION_CHANGE, function() {
4204
+ _this3.onMouseLeave();
4205
+ });
4206
+ this.on(TIME_UPDATE, function() {
4207
+ _this3.onTimeupdate();
4208
+ });
4209
+ this.on(SEEKED, function() {
4210
+ _this3.onTimeupdate();
4211
+ _this3.onCacheUpdate();
4212
+ });
4213
+ this.on(PROGRESS, function() {
4214
+ _this3.onCacheUpdate();
4215
+ });
4216
+ this.on(ENDED, function() {
4217
+ _this3.onCacheUpdate(true);
4218
+ _this3.onTimeupdate(true);
4219
+ _this3._state.now = 0;
4220
+ });
4221
+ this.on(EMPTIED, function() {
4222
+ _this3.onReset();
4223
+ });
4224
+ this.on(VIDEO_RESIZE, function() {
4225
+ _this3.onVideoResize();
4226
+ });
4156
4227
  }
4157
4228
  }, {
4158
- key: "registerIcons",
4159
- value: function registerIcons() {
4160
- return {
4161
- screenBack: {
4162
- icon: BackSVG,
4163
- class: "xg-fullscreen-back"
4229
+ key: "setConfig",
4230
+ value: function setConfig(config) {
4231
+ var _this4 = this;
4232
+ var frags = null;
4233
+ Object.keys(config).forEach(function(key) {
4234
+ _this4.config[key] = config[key];
4235
+ if (key === "fragments") {
4236
+ frags = config[key];
4164
4237
  }
4165
- };
4238
+ });
4239
+ if (frags) {
4240
+ this._initInner(frags, config);
4241
+ }
4166
4242
  }
4167
4243
  }, {
4168
- key: "initIcons",
4169
- value: function initIcons() {
4170
- var icons = this.icons;
4171
- this.appendChild(this.root, icons.screenBack);
4244
+ key: "initCustomStyle",
4245
+ value: function initCustomStyle() {
4246
+ var _ref = this.playerConfig || {}, commonStyle = _ref.commonStyle;
4247
+ var sliderBtnStyle = commonStyle.sliderBtnStyle;
4248
+ var progressBtn = this.progressBtn;
4249
+ if (sliderBtnStyle) {
4250
+ if (typeof sliderBtnStyle === "string") {
4251
+ progressBtn.style.boxShadow = sliderBtnStyle;
4252
+ } else if (_typeof$1(sliderBtnStyle) === "object") {
4253
+ Object.keys(sliderBtnStyle).map(function(key) {
4254
+ progressBtn.style[key] = sliderBtnStyle[key];
4255
+ });
4256
+ }
4257
+ }
4172
4258
  }
4173
4259
  }, {
4174
- key: "show",
4175
- value: function show() {
4176
- util$3.addClass(this.root, "show");
4260
+ key: "triggerCallbacks",
4261
+ value: function triggerCallbacks(type, data, event) {
4262
+ if (this.__dragCallBacks.length > 0) {
4263
+ this.__dragCallBacks.map(function(item) {
4264
+ if (item && item.handler && item.type === type) {
4265
+ try {
4266
+ item.handler(data, event);
4267
+ } catch (error) {
4268
+ console.error("[XGPLAYER][triggerCallbacks] ".concat(item, " error"), error);
4269
+ }
4270
+ }
4271
+ });
4272
+ }
4177
4273
  }
4178
4274
  }, {
4179
- key: "hide",
4180
- value: function hide() {
4181
- util$3.removeClass(this.root, "show");
4275
+ key: "addCallBack",
4276
+ value: function addCallBack(type, handle) {
4277
+ if (handle && typeof handle === "function") {
4278
+ this.__dragCallBacks.push({
4279
+ type,
4280
+ handler: handle
4281
+ });
4282
+ }
4182
4283
  }
4183
4284
  }, {
4184
- key: "render",
4185
- value: function render() {
4186
- return '<xg-icon class="xgplayer-back">\n </xg-icon>';
4187
- }
4188
- }], [{
4189
- key: "pluginName",
4190
- get: function get() {
4191
- return "topbackicon";
4285
+ key: "removeCallBack",
4286
+ value: function removeCallBack(type, event) {
4287
+ var __dragCallBacks = this.__dragCallBacks;
4288
+ var _index = -1;
4289
+ __dragCallBacks.map(function(item, index2) {
4290
+ if (item && item.type === type && item.handler === event) {
4291
+ _index = index2;
4292
+ }
4293
+ });
4294
+ if (_index > -1) {
4295
+ __dragCallBacks.splice(_index, 1);
4296
+ }
4192
4297
  }
4193
4298
  }, {
4194
- key: "defaultConfig",
4195
- get: function get() {
4196
- return {
4197
- position: POSITIONS.ROOT_TOP,
4198
- index: 0
4199
- };
4200
- }
4201
- }]);
4202
- return TopBackIcon2;
4203
- }(Plugin);
4204
- function FullScreenSvg() {
4205
- return new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="2 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M598 214h212v212h-84v-128h-128v-84zM726 726v-128h84v212h-212v-84h128zM214 426v-212h212v84h-128v128h-84zM298 598v128h128v84h-212v-212h84z"></path>\n</svg>\n', "image/svg+xml").firstChild;
4206
- }
4207
- function ExitFullScreenSvg() {
4208
- return new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" width="28" height="40" viewBox="2 -4 28 40">\n <path fill="#fff" transform="scale(0.0320625 0.0320625)" d="M682 342h128v84h-212v-212h84v128zM598 810v-212h212v84h-128v128h-84zM342 342v-128h84v212h-212v-84h128zM214 682v-84h212v212h-84v-128h-128z"></path>\n</svg>\n', "image/svg+xml").firstChild;
4209
- }
4210
- var Fullscreen = /* @__PURE__ */ function(_IconPlugin) {
4211
- _inherits(Fullscreen2, _IconPlugin);
4212
- var _super = _createSuper(Fullscreen2);
4213
- function Fullscreen2() {
4214
- var _this;
4215
- _classCallCheck$1(this, Fullscreen2);
4216
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4217
- args[_key] = arguments[_key];
4218
- }
4219
- _this = _super.call.apply(_super, [this].concat(args));
4220
- _defineProperty$1(_assertThisInitialized(_this), "_onOrientationChange", function(e4) {
4221
- if (_this.player.fullscreen && _this.config.rotateFullscreen) {
4222
- if (window.orientation === 90 || window.orientation === -90) {
4223
- _this.player.setRotateDeg(0);
4224
- } else {
4225
- _this.player.setRotateDeg(90);
4226
- }
4299
+ key: "unlock",
4300
+ value: function unlock() {
4301
+ var player = this.player, pos = this.pos;
4302
+ pos.isEnter = false;
4303
+ pos.isLocked = false;
4304
+ if (player.isMini) {
4305
+ return;
4227
4306
  }
4228
- });
4229
- return _this;
4230
- }
4231
- _createClass$1(Fullscreen2, [{
4232
- key: "afterCreate",
4233
- value: function afterCreate() {
4234
- var _this2 = this;
4235
- _get(_getPrototypeOf(Fullscreen2.prototype), "afterCreate", this).call(this);
4236
- var config = this.config, playerConfig = this.playerConfig;
4237
- if (config.disable) {
4307
+ this.unbind("mousemove", this.onMoveOnly);
4308
+ if (pos.isDown) {
4309
+ this.unbind("mouseleave", this.onMouseLeave);
4238
4310
  return;
4239
4311
  }
4240
- if (config.target) {
4241
- this.playerConfig.fullscreenTarget = this.config.target;
4312
+ this.blur();
4313
+ }
4314
+ }, {
4315
+ key: "bindDomEvents",
4316
+ value: function bindDomEvents() {
4317
+ var config = this.player.config;
4318
+ this._mouseDownHandlerHook = this.hook("dragstart", this._mouseDownHandler);
4319
+ this._mouseUpHandlerHook = this.hook("dragend", this._mouseUpHandler);
4320
+ this._mouseMoveHandlerHook = this.hook("drag", this._mouseMoveHandler);
4321
+ if (this.domEventType === "touch" || this.domEventType === "compatible") {
4322
+ this.root.addEventListener("touchstart", this.onMouseDown);
4323
+ }
4324
+ if (this.domEventType === "mouse" || this.domEventType === "compatible") {
4325
+ this.bind("mousedown", this.onMouseDown);
4326
+ config.isMobileSimulateMode !== "mobile" && this.bind("mouseenter", this.onMouseEnter);
4327
+ this.bind("mouseover", this.onMouseOver);
4328
+ this.bind("mouseout", this.onMouseOut);
4329
+ this.player.root.addEventListener("click", this.onBodyClick, true);
4242
4330
  }
4243
- var fullEl = util$3.getFullScreenEl();
4244
- if (playerConfig.fullscreenTarget === fullEl) {
4245
- this.player.getFullscreen().catch(function(e4) {
4246
- });
4331
+ }
4332
+ }, {
4333
+ key: "focus",
4334
+ value: function focus() {
4335
+ this.player.controls.pauseAutoHide();
4336
+ util$3.addClass(this.root, "active");
4337
+ }
4338
+ }, {
4339
+ key: "blur",
4340
+ value: function blur() {
4341
+ if (this._disableBlur) {
4342
+ return;
4247
4343
  }
4248
- this.initIcons();
4249
- this.handleFullscreen = this.hook("fullscreenChange", this.toggleFullScreen, {
4250
- pre: function pre(e4) {
4251
- var fullscreen = _this2.player.fullscreen;
4252
- _this2.emitUserAction(e4, "switch_fullscreen", {
4253
- prop: "fullscreen",
4254
- from: fullscreen,
4255
- to: !fullscreen
4256
- });
4257
- }
4258
- });
4259
- this.bind(".xgplayer-fullscreen", ["touchend", "click"], this.handleFullscreen);
4260
- this.on(FULLSCREEN_CHANGE, function(isFullScreen) {
4261
- var tipsDom = _this2.find(".xg-tips");
4262
- tipsDom && _this2.changeLangTextKey(tipsDom, isFullScreen ? _this2.i18nKeys.EXITFULLSCREEN_TIPS : _this2.i18nKeys.FULLSCREEN_TIPS);
4263
- _this2.animate(isFullScreen);
4264
- });
4265
- if (this.config.needBackIcon) {
4266
- this.topBackIcon = this.player.registerPlugin({
4267
- plugin: TopBackIcon,
4268
- options: {
4269
- config: {
4270
- onClick: function onClick(e4) {
4271
- _this2.handleFullscreen(e4);
4272
- }
4273
- }
4274
- }
4275
- });
4344
+ this.player.controls.recoverAutoHide();
4345
+ util$3.removeClass(this.root, "active");
4346
+ }
4347
+ }, {
4348
+ key: "disableBlur",
4349
+ value: function disableBlur() {
4350
+ this._disableBlur = true;
4351
+ }
4352
+ }, {
4353
+ key: "enableBlur",
4354
+ value: function enableBlur() {
4355
+ this._disableBlur = false;
4356
+ }
4357
+ }, {
4358
+ key: "updateWidth",
4359
+ value: function updateWidth(currentTime, seekTime, percent, type) {
4360
+ var config = this.config, player = this.player;
4361
+ if (config.isCloseClickSeek && type === 0) {
4362
+ return;
4276
4363
  }
4277
- if (sniffer.device === "mobile") {
4278
- window.addEventListener("orientationchange", this._onOrientationChange);
4364
+ var realTime = seekTime = seekTime >= player.duration ? player.duration - config.endedDiff : Number(seekTime).toFixed(1);
4365
+ this.updatePercent(percent);
4366
+ this.updateTime(currentTime);
4367
+ if (type === 1 && (!config.isDraggingSeek || player.config.mediaType === "audio")) {
4368
+ return;
4279
4369
  }
4370
+ this._state.now = realTime;
4371
+ this._state.direc = realTime > player.currentTime ? 0 : 1;
4372
+ player.seek(realTime);
4280
4373
  }
4281
4374
  }, {
4282
- key: "registerIcons",
4283
- value: function registerIcons() {
4375
+ key: "computeTime",
4376
+ value: function computeTime(e4, x2) {
4377
+ var player = this.player;
4378
+ var _this$root$getBoundin = this.root.getBoundingClientRect(), width = _this$root$getBoundin.width, height = _this$root$getBoundin.height, top = _this$root$getBoundin.top, left = _this$root$getBoundin.left;
4379
+ var rWidth, rLeft;
4380
+ var clientX = x2;
4381
+ if (player.rotateDeg === 90) {
4382
+ rWidth = height;
4383
+ rLeft = top;
4384
+ } else {
4385
+ rWidth = width;
4386
+ rLeft = left;
4387
+ }
4388
+ var offset = clientX - rLeft;
4389
+ offset = offset > rWidth ? rWidth : offset < 0 ? 0 : offset;
4390
+ var percent = offset / rWidth;
4391
+ percent = percent < 0 ? 0 : percent > 1 ? 1 : percent;
4392
+ if (Number.isNaN(percent)) {
4393
+ percent = this.player.currentTime / this.offsetDuration;
4394
+ }
4395
+ var currentTime = parseInt(percent * this.offsetDuration * 1e3, 10) / 1e3;
4396
+ var seekTime = util$3.getCurrentTimeByOffset(currentTime, player.timeSegments);
4284
4397
  return {
4285
- fullscreen: {
4286
- icon: FullScreenSvg,
4287
- class: "xg-get-fullscreen"
4288
- },
4289
- exitFullscreen: {
4290
- icon: ExitFullScreenSvg,
4291
- class: "xg-exit-fullscreen"
4292
- }
4398
+ percent,
4399
+ currentTime,
4400
+ seekTime,
4401
+ offset,
4402
+ width: rWidth,
4403
+ left: rLeft,
4404
+ e: e4
4293
4405
  };
4294
4406
  }
4295
4407
  }, {
4296
- key: "destroy",
4297
- value: function destroy() {
4298
- _get(_getPrototypeOf(Fullscreen2.prototype), "destroy", this).call(this);
4299
- this.unbind(".xgplayer-icon", sniffer.device === "mobile" ? "touchend" : "click", this.handleFullscreen);
4300
- if (sniffer.device === "mobile") {
4301
- window.removeEventListener("orientationchange", this._onOrientationChange);
4408
+ key: "updateTime",
4409
+ value: function updateTime(time) {
4410
+ var player = this.player, duration = this.duration;
4411
+ if (time > duration) {
4412
+ time = duration;
4413
+ } else if (time < 0) {
4414
+ time = 0;
4415
+ }
4416
+ var timeIcon = player.plugins.time;
4417
+ if (timeIcon) {
4418
+ timeIcon.updateTime(time);
4302
4419
  }
4303
4420
  }
4304
4421
  }, {
4305
- key: "initIcons",
4306
- value: function initIcons() {
4307
- var icons = this.icons;
4308
- this.appendChild(".xgplayer-icon", icons.fullscreen);
4309
- this.appendChild(".xgplayer-icon", icons.exitFullscreen);
4422
+ key: "resetSeekState",
4423
+ value: function resetSeekState() {
4424
+ this.isProgressMoving = false;
4425
+ var timeIcon = this.player.plugins.time;
4426
+ timeIcon && timeIcon.resetActive();
4310
4427
  }
4311
4428
  }, {
4312
- key: "toggleFullScreen",
4313
- value: function toggleFullScreen(e4) {
4314
- if (e4 instanceof Event) {
4315
- e4.preventDefault();
4316
- e4.stopPropagation();
4429
+ key: "updatePercent",
4430
+ value: function updatePercent(percent, notSeek) {
4431
+ this.isProgressMoving = true;
4432
+ if (this.config.disable) {
4433
+ return;
4317
4434
  }
4318
- var player = this.player, config = this.config;
4319
- var useCssFullscreen = config.useCssFullscreen === true || typeof config.useCssFullscreen === "function" && config.useCssFullscreen();
4320
- if (useCssFullscreen) {
4321
- if (player.fullscreen) {
4322
- player.exitCssFullscreen();
4323
- } else {
4324
- player.getCssFullscreen();
4325
- }
4326
- this.animate(player.fullscreen);
4327
- } else if (config.rotateFullscreen) {
4328
- if (player.fullscreen) {
4329
- player.exitRotateFullscreen();
4330
- } else {
4331
- player.getRotateFullscreen();
4332
- }
4333
- this.animate(player.fullscreen);
4334
- } else if (config.switchCallback && typeof config.switchCallback === "function") {
4335
- config.switchCallback(player.fullscreen);
4336
- } else {
4337
- if (player.fullscreen) {
4338
- player.exitFullscreen();
4339
- if (config.useScreenOrientation) {
4340
- this.unlockScreen();
4341
- }
4435
+ percent = percent > 1 ? 1 : percent < 0 ? 0 : percent;
4436
+ this.progressBtn.style.left = "".concat(percent * 100, "%");
4437
+ this.innerList.update({
4438
+ played: percent * this.offsetDuration
4439
+ }, this.offsetDuration);
4440
+ var miniprogress = this.player.plugins.miniprogress;
4441
+ miniprogress && miniprogress.update({
4442
+ played: percent * this.offsetDuration
4443
+ }, this.offsetDuration);
4444
+ }
4445
+ }, {
4446
+ key: "onTimeupdate",
4447
+ value: function onTimeupdate(isEnded) {
4448
+ var player = this.player, _state = this._state, offsetDuration = this.offsetDuration;
4449
+ if (player.isSeeking && player.media.seeking || this.isProgressMoving || !player.hasStart) {
4450
+ return;
4451
+ }
4452
+ if (_state.now > -1) {
4453
+ var abs = parseInt(_state.now * 1e3, 10) - parseInt(player.currentTime * 1e3, 10);
4454
+ if (_state.direc === 0 && abs > 300 || _state.direc === 1 && abs > -300) {
4455
+ _state.now = -1;
4456
+ return;
4342
4457
  } else {
4343
- player.getFullscreen().catch(function(e22) {
4344
- });
4345
- if (config.useScreenOrientation && player.aspectRatio > 1) {
4346
- this.lockScreen(config.lockOrientationType);
4347
- }
4458
+ _state.now = -1;
4348
4459
  }
4349
4460
  }
4461
+ var time = this.currentTime;
4462
+ time = util$3.adjustTimeByDuration(time, offsetDuration, isEnded);
4463
+ this.innerList.update({
4464
+ played: time
4465
+ }, offsetDuration);
4466
+ this.progressBtn.style.left = "".concat(time / offsetDuration * 100, "%");
4350
4467
  }
4351
4468
  }, {
4352
- key: "animate",
4353
- value: function animate(isFullScreen) {
4354
- isFullScreen ? this.setAttr("data-state", "full") : this.setAttr("data-state", "normal");
4355
- if (this.topBackIcon) {
4356
- if (isFullScreen) {
4357
- this.topBackIcon.show();
4358
- this.hide();
4359
- } else {
4360
- this.topBackIcon.hide();
4361
- this.show();
4362
- }
4469
+ key: "onCacheUpdate",
4470
+ value: function onCacheUpdate(isEnded) {
4471
+ var player = this.player, duration = this.duration;
4472
+ if (!player) {
4473
+ return;
4474
+ }
4475
+ var _end = player.bufferedPoint.end;
4476
+ _end = util$3.adjustTimeByDuration(_end, duration, isEnded);
4477
+ this.innerList.update({
4478
+ cached: _end
4479
+ }, duration);
4480
+ }
4481
+ }, {
4482
+ key: "onReset",
4483
+ value: function onReset() {
4484
+ this.innerList.update({
4485
+ played: 0,
4486
+ cached: 0
4487
+ }, 0);
4488
+ this.progressBtn.style.left = "0%";
4489
+ }
4490
+ }, {
4491
+ key: "destroy",
4492
+ value: function destroy() {
4493
+ var player = this.player;
4494
+ this.thumbnailPlugin = null;
4495
+ this.innerList.destroy();
4496
+ this.innerList = null;
4497
+ var domEventType = this.domEventType;
4498
+ if (domEventType === "touch" || domEventType === "compatible") {
4499
+ this.root.removeEventListener("touchstart", this.onMouseDown);
4500
+ this.root.removeEventListener("touchmove", this.onMouseMove);
4501
+ this.root.removeEventListener("touchend", this.onMouseUp);
4502
+ this.root.removeEventListener("touchcancel", this.onMouseUp);
4503
+ }
4504
+ if (domEventType === "mouse" || domEventType === "compatible") {
4505
+ this.unbind("mousedown", this.onMouseDown);
4506
+ this.unbind("mouseenter", this.onMouseEnter);
4507
+ this.unbind("mousemove", this.onMoveOnly);
4508
+ this.unbind("mouseleave", this.onMouseLeave);
4509
+ document.removeEventListener("mousemove", this.onMouseMove, false);
4510
+ document.removeEventListener("mouseup", this.onMouseUp, false);
4511
+ player.root.removeEventListener("click", this.onBodyClick, true);
4363
4512
  }
4364
4513
  }
4365
4514
  }, {
4366
4515
  key: "render",
4367
4516
  value: function render() {
4368
- if (this.config.disable) {
4517
+ if (this.config.disable || this.playerConfig.isLive) {
4369
4518
  return;
4370
4519
  }
4371
- var langKey = "FULLSCREEN_TIPS";
4372
- return '<xg-icon class="xgplayer-fullscreen">\n <div class="xgplayer-icon">\n </div>\n '.concat(xgIconTips(this, langKey, this.playerConfig.isHideTips), "\n </xg-icon>");
4373
- }
4374
- }, {
4375
- key: "lockScreen",
4376
- value: function lockScreen(orientation) {
4377
- try {
4378
- screen.orientation.lock(orientation).catch(function(e4) {
4379
- });
4380
- } catch (e4) {
4381
- }
4382
- }
4383
- }, {
4384
- key: "unlockScreen",
4385
- value: function unlockScreen() {
4386
- try {
4387
- screen.orientation.unlock().catch(function(e4) {
4388
- });
4389
- } catch (e4) {
4390
- }
4520
+ var controlsMode = this.player.controls ? this.player.controls.config.mode : "";
4521
+ var className = controlsMode === "bottom" ? "xgplayer-progress-bottom" : "";
4522
+ return '\n <xg-progress class="xgplayer-progress '.concat(className, '">\n <xg-outer class="xgplayer-progress-outer">\n <xg-progress-btn class="xgplayer-progress-btn"></xg-progress-btn>\n </xg-outer>\n </xg-progress>\n ');
4391
4523
  }
4392
4524
  }], [{
4393
4525
  key: "pluginName",
4394
4526
  get: function get() {
4395
- return "fullscreen";
4527
+ return "progress";
4396
4528
  }
4397
4529
  }, {
4398
4530
  key: "defaultConfig",
4399
4531
  get: function get() {
4400
4532
  return {
4401
- position: POSITIONS.CONTROLS_RIGHT,
4533
+ position: POSITIONS.CONTROLS_CENTER,
4402
4534
  index: 0,
4403
- useCssFullscreen: false,
4404
- rotateFullscreen: false,
4405
- useScreenOrientation: false,
4406
- lockOrientationType: "landscape",
4407
- switchCallback: null,
4408
- target: null,
4409
4535
  disable: false,
4410
- needBackIcon: false
4536
+ isDraggingSeek: true,
4537
+ closeMoveSeek: false,
4538
+ isPauseMoving: false,
4539
+ isCloseClickSeek: false,
4540
+ fragments: [{
4541
+ percent: 1
4542
+ }],
4543
+ fragFocusClass: FRAGMENT_FOCUS_CLASS.POINT,
4544
+ fragClass: "",
4545
+ fragAutoFocus: false,
4546
+ miniMoveStep: 5,
4547
+ miniStartStep: 2,
4548
+ onMoveStart: function onMoveStart() {
4549
+ },
4550
+ onMoveEnd: function onMoveEnd() {
4551
+ },
4552
+ endedDiff: 0.2
4411
4553
  };
4412
4554
  }
4555
+ }, {
4556
+ key: "FRAGMENT_FOCUS_CLASS",
4557
+ get: function get() {
4558
+ return FRAGMENT_FOCUS_CLASS;
4559
+ }
4413
4560
  }]);
4414
- return Fullscreen2;
4415
- }(Icon);
4561
+ return Progress2;
4562
+ }(Plugin);
4416
4563
  var Time = /* @__PURE__ */ function(_Plugin) {
4417
4564
  _inherits(Time2, _Plugin);
4418
4565
  var _super = _createSuper(Time2);
@@ -4537,6 +4684,7 @@ var Time = /* @__PURE__ */ function(_Plugin) {
4537
4684
  this.centerDurDom = util$3.createDom("xg-icon", "00:00", {}, "xgplayer-time xg-time-right");
4538
4685
  center.children.length > 0 ? center.insertBefore(this.centerCurDom, center.children[0]) : center.appendChild(this.centerCurDom);
4539
4686
  center.appendChild(this.centerDurDom);
4687
+ this.extraEls = [this.centerCurDom, this.centerDurDom];
4540
4688
  }
4541
4689
  }, {
4542
4690
  key: "afterPlayerInit",
@@ -4958,141 +5106,6 @@ var Volume = /* @__PURE__ */ function(_Plugin) {
4958
5106
  }]);
4959
5107
  return Volume2;
4960
5108
  }(Plugin);
4961
- function CssFullSceenSvg() {
4962
- return new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg" width="31" height="40" viewBox="0 -5 31 40">
4963
- <path fill="#fff" transform="scale(1.3, 1.3)" class='path_full' d="M9,10v1a.9.9,0,0,1-1,1,.9.9,0,0,1-1-1V9A.9.9,0,0,1,8,8h2a.9.9,0,0,1,1,1,.9.9,0,0,1-1,1Zm6,4V13a1,1,0,0,1,2,0v2a.9.9,0,0,1-1,1H14a1,1,0,0,1,0-2Zm3-7H6V17H18Zm2,0V17a2,2,0,0,1-2,2H6a2,2,0,0,1-2-2V7A2,2,0,0,1,6,5H18A2,2,0,0,1,20,7Z"></path>
4964
- </svg>
4965
- `, "image/svg+xml").firstChild;
4966
- }
4967
- function ExitCssFullSceenSvg() {
4968
- return new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg" width="31" height="40" viewBox="0 -5 31 40">\n <path fill="#fff" transform="scale(1.3, 1.3)" d="M9,10V9a.9.9,0,0,1,1-1,.9.9,0,0,1,1,1v2a.9.9,0,0,1-1,1H8a.9.9,0,0,1-1-1,.9.9,0,0,1,1-1Zm6,4v1a1,1,0,0,1-2,0V13a.9.9,0,0,1,1-1h2a1,1,0,0,1,0,2Zm3-7H6V17H18Zm2,0V17a2,2,0,0,1-2,2H6a2,2,0,0,1-2-2V7A2,2,0,0,1,6,5H18A2,2,0,0,1,20,7Z"></path>\n</svg>\n', "image/svg+xml").firstChild;
4969
- }
4970
- var CssFullScreen = /* @__PURE__ */ function(_IconPlugin) {
4971
- _inherits(CssFullScreen2, _IconPlugin);
4972
- var _super = _createSuper(CssFullScreen2);
4973
- function CssFullScreen2() {
4974
- _classCallCheck$1(this, CssFullScreen2);
4975
- return _super.apply(this, arguments);
4976
- }
4977
- _createClass$1(CssFullScreen2, [{
4978
- key: "beforeCreate",
4979
- value: function beforeCreate(args) {
4980
- if (typeof args.player.config.cssFullscreen === "boolean") {
4981
- args.config.disable = !args.player.config.cssFullscreen;
4982
- }
4983
- }
4984
- }, {
4985
- key: "afterCreate",
4986
- value: function afterCreate() {
4987
- var _this = this;
4988
- _get(_getPrototypeOf(CssFullScreen2.prototype), "afterCreate", this).call(this);
4989
- if (this.config.disable) {
4990
- return;
4991
- }
4992
- if (this.config.target) {
4993
- this.playerConfig.fullscreenTarget = this.config.target;
4994
- }
4995
- this.initIcons();
4996
- this.on(CSS_FULLSCREEN_CHANGE, function(isCssfullScreen) {
4997
- _this.animate(isCssfullScreen);
4998
- });
4999
- this.btnClick = this.btnClick.bind(this);
5000
- this.handleCssFullscreen = this.hook("cssFullscreen_change", this.btnClick, {
5001
- pre: function pre(e4) {
5002
- e4.preventDefault();
5003
- e4.stopPropagation();
5004
- }
5005
- });
5006
- this.bind(["click", "touchend"], this.handleCssFullscreen);
5007
- }
5008
- }, {
5009
- key: "initIcons",
5010
- value: function initIcons() {
5011
- var icons = this.icons;
5012
- var contentIcon = this.find(".xgplayer-icon");
5013
- contentIcon.appendChild(icons.cssFullscreen);
5014
- contentIcon.appendChild(icons.exitCssFullscreen);
5015
- }
5016
- }, {
5017
- key: "btnClick",
5018
- value: function btnClick(e4) {
5019
- e4.preventDefault();
5020
- e4.stopPropagation();
5021
- var isCssfullScreen = this.player.isCssfullScreen;
5022
- this.emitUserAction(e4, "switch_cssfullscreen", {
5023
- cssfullscreen: isCssfullScreen
5024
- });
5025
- if (!isCssfullScreen) {
5026
- this.player.getCssFullscreen();
5027
- } else {
5028
- this.player.exitCssFullscreen();
5029
- }
5030
- }
5031
- }, {
5032
- key: "animate",
5033
- value: function animate(isFullScreen) {
5034
- if (!this.root) {
5035
- return;
5036
- }
5037
- isFullScreen ? this.setAttr("data-state", "full") : this.setAttr("data-state", "normal");
5038
- this.switchTips(isFullScreen);
5039
- }
5040
- }, {
5041
- key: "switchTips",
5042
- value: function switchTips(isFullScreen) {
5043
- var i18nKeys = this.i18nKeys;
5044
- var tipDom = this.find(".xg-tips");
5045
- tipDom && this.changeLangTextKey(tipDom, isFullScreen ? i18nKeys.EXITCSSFULLSCREEN_TIPS : i18nKeys.CSSFULLSCREEN_TIPS);
5046
- }
5047
- }, {
5048
- key: "registerIcons",
5049
- value: function registerIcons() {
5050
- return {
5051
- cssFullscreen: {
5052
- icon: CssFullSceenSvg,
5053
- class: "xg-get-cssfull"
5054
- },
5055
- exitCssFullscreen: {
5056
- icon: ExitCssFullSceenSvg,
5057
- class: "xg-exit-cssfull"
5058
- }
5059
- };
5060
- }
5061
- }, {
5062
- key: "destroy",
5063
- value: function destroy() {
5064
- _get(_getPrototypeOf(CssFullScreen2.prototype), "destroy", this).call(this);
5065
- this.unbind(["click", "touchend"], this.btnClick);
5066
- }
5067
- }, {
5068
- key: "render",
5069
- value: function render() {
5070
- if (this.config.disable) {
5071
- return;
5072
- }
5073
- return `<xg-icon class='xgplayer-cssfullscreen'>
5074
- <div class="xgplayer-icon">
5075
- </div>
5076
- `.concat(xgIconTips(this, "CSSFULLSCREEN_TIPS", this.playerConfig.isHideTips), "\n </xg-icon>");
5077
- }
5078
- }], [{
5079
- key: "pluginName",
5080
- get: function get() {
5081
- return "cssFullscreen";
5082
- }
5083
- }, {
5084
- key: "defaultConfig",
5085
- get: function get() {
5086
- return {
5087
- position: POSITIONS.CONTROLS_RIGHT,
5088
- index: 1,
5089
- disable: false,
5090
- target: null
5091
- };
5092
- }
5093
- }]);
5094
- return CssFullScreen2;
5095
- }(Icon);
5096
5109
  function _typeof(obj) {
5097
5110
  "@babel/helpers - typeof";
5098
5111
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
@@ -5462,6 +5475,9 @@ var BaseAdManager = /* @__PURE__ */ function(_EventEmitter) {
5462
5475
  }, {
5463
5476
  key: "shouldBlockVideoContent",
5464
5477
  get: function get() {
5478
+ if (sniffer.os.isTizen || sniffer.os.isWebOS) {
5479
+ return false;
5480
+ }
5465
5481
  return this.isLinearAdRunning || this._shouldBlockVideoContent;
5466
5482
  },
5467
5483
  set: function set(flag) {
@@ -5624,12 +5640,6 @@ var ImaAdManager = /* @__PURE__ */ function(_BaseAdManager) {
5624
5640
  break;
5625
5641
  }
5626
5642
  case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED: {
5627
- if (_this._resumeCallback) {
5628
- var _this$_resumeCallback = _this._resumeCallback(), canResume = _this$_resumeCallback.canResume;
5629
- if (!canResume) {
5630
- break;
5631
- }
5632
- }
5633
5643
  _this._resumeContent();
5634
5644
  _this.emit(IMA_CONTENT_RESUME_REQUESTED, {
5635
5645
  ad
@@ -5655,8 +5665,6 @@ var ImaAdManager = /* @__PURE__ */ function(_BaseAdManager) {
5655
5665
  _this.plugin.emit(AD_PLAY, {
5656
5666
  ad
5657
5667
  });
5658
- intervalTimer = setInterval(function() {
5659
- }, 300);
5660
5668
  }
5661
5669
  break;
5662
5670
  }
@@ -5733,7 +5741,6 @@ var ImaAdManager = /* @__PURE__ */ function(_BaseAdManager) {
5733
5741
  _this.displayContainer = null;
5734
5742
  _this.adsLoader = null;
5735
5743
  _this.adsManager = null;
5736
- _this._resumeCallback = null;
5737
5744
  return _this;
5738
5745
  }
5739
5746
  _createClass$2(ImaAdManager2, [{
@@ -5782,15 +5789,9 @@ var ImaAdManager = /* @__PURE__ */ function(_BaseAdManager) {
5782
5789
  value: function destroy() {
5783
5790
  _get$1(_getPrototypeOf$1(ImaAdManager2.prototype), "destroy", this).call(this);
5784
5791
  this.reset();
5785
- this.displayContainer.destroy();
5786
5792
  this._removeMediaEvents();
5787
5793
  this._destroyLoader();
5788
5794
  }
5789
- }, {
5790
- key: "resumeCallback",
5791
- set: function set(resumeCallbackFunc) {
5792
- this._resumeCallback = resumeCallbackFunc;
5793
- }
5794
5795
  }, {
5795
5796
  key: "_initConfig",
5796
5797
  value: function _initConfig() {
@@ -6023,27 +6024,28 @@ var ImaAdManager = /* @__PURE__ */ function(_BaseAdManager) {
6023
6024
  key: "_checkAutoplaySupport",
6024
6025
  value: function() {
6025
6026
  var _checkAutoplaySupport2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3() {
6026
- var autoplay, timeout, _yield$Promise$all, _yield$Promise$all2, autoplayAllowed, autoplayMutedAllowed;
6027
+ var autoplay, timeout, isKnownAutoplayPlatform, _yield$Promise$all, _yield$Promise$all2, autoplayAllowed, autoplayMutedAllowed;
6027
6028
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6028
6029
  while (1)
6029
6030
  switch (_context3.prev = _context3.next) {
6030
6031
  case 0:
6031
6032
  autoplay = this.player.config.autoplay;
6032
6033
  timeout = 800;
6033
- _context3.next = 4;
6034
- return Promise.all([autoplay ? index.video({
6034
+ isKnownAutoplayPlatform = sniffer.os.isTizen || sniffer.os.isWebOS;
6035
+ _context3.next = 5;
6036
+ return Promise.all([autoplay ? isKnownAutoplayPlatform || index.video({
6035
6037
  timeout
6036
6038
  }).then(function(_ref3) {
6037
6039
  var result = _ref3.result;
6038
6040
  return result;
6039
- }) : Promise.resolve(false), autoplay && this.player.config.autoplayMuted ? index.video({
6041
+ }) : Promise.resolve(false), autoplay && this.player.config.autoplayMuted ? isKnownAutoplayPlatform || index.video({
6040
6042
  timeout,
6041
6043
  muted: true
6042
6044
  }).then(function(_ref4) {
6043
6045
  var result = _ref4.result;
6044
6046
  return result;
6045
6047
  }) : Promise.resolve(false)]);
6046
- case 4:
6048
+ case 5:
6047
6049
  _yield$Promise$all = _context3.sent;
6048
6050
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
6049
6051
  autoplayAllowed = _yield$Promise$all2[0];
@@ -6051,7 +6053,7 @@ var ImaAdManager = /* @__PURE__ */ function(_BaseAdManager) {
6051
6053
  this.autoplayAllowed = autoplayAllowed || autoplayMutedAllowed;
6052
6054
  this.autoplayRequiresMuted = !autoplayAllowed && autoplayMutedAllowed;
6053
6055
  logger$1.log("checkAutoplaySupport", this.autoplayAllowed, this.autoplayRequiresMuted);
6054
- case 11:
6056
+ case 12:
6055
6057
  case "end":
6056
6058
  return _context3.stop();
6057
6059
  }
@@ -6242,9 +6244,15 @@ var AdUIManager = /* @__PURE__ */ function() {
6242
6244
  if (targetPlugin) {
6243
6245
  var newDecoratorPlugin = null;
6244
6246
  if (decoratorClass && !player.getPlugin(decoratorClass.pluginName)) {
6247
+ var _newDecoratorPlugin$e;
6245
6248
  player.registerPlugin(decoratorClass);
6246
6249
  newDecoratorPlugin = player.getPlugin(decoratorClass.pluginName);
6247
6250
  fragment.appendChild(newDecoratorPlugin.root);
6251
+ if ((_newDecoratorPlugin$e = newDecoratorPlugin.extraEls) !== null && _newDecoratorPlugin$e !== void 0 && _newDecoratorPlugin$e.length) {
6252
+ newDecoratorPlugin.extraEls.forEach(function(el) {
6253
+ fragment.appendChild(el);
6254
+ });
6255
+ }
6248
6256
  }
6249
6257
  adUIPlugins.push([targetPlugin, newDecoratorPlugin]);
6250
6258
  }
@@ -6312,11 +6320,23 @@ var AdUIManager = /* @__PURE__ */ function() {
6312
6320
  if (!overrideAdPlugin) {
6313
6321
  return;
6314
6322
  }
6315
- var adRoot = overrideAdPlugin.root;
6316
- var normalRoot = normalPlugin.root;
6323
+ var adRoot = overrideAdPlugin.root, adExtraEls = overrideAdPlugin.extraEls;
6324
+ var normalRoot = normalPlugin.root, normalExtraEls = normalPlugin.extraEls;
6317
6325
  if (fragmentContainer.contains(adRoot)) {
6318
6326
  fragmentContainer.removeChild(adRoot);
6319
6327
  }
6328
+ if (Array.isArray(adExtraEls) && adExtraEls.length) {
6329
+ adExtraEls.forEach(function(adEl, index2) {
6330
+ if (fragmentContainer.contains(adEl)) {
6331
+ fragmentContainer.removeChild(adEl);
6332
+ }
6333
+ var normalEl = normalExtraEls === null || normalExtraEls === void 0 ? void 0 : normalExtraEls[index2];
6334
+ if (normalEl !== null && normalEl !== void 0 && normalEl.parentNode) {
6335
+ normalEl.parentNode.insertBefore(adEl, normalEl);
6336
+ fragmentContainer.appendChild(normalEl);
6337
+ }
6338
+ });
6339
+ }
6320
6340
  normalRoot.parentNode.insertBefore(adRoot, normalRoot);
6321
6341
  fragmentContainer.appendChild(normalRoot);
6322
6342
  });
@@ -6351,8 +6371,8 @@ var AdUIManager = /* @__PURE__ */ function() {
6351
6371
  if (!overrideAdPlugin) {
6352
6372
  return;
6353
6373
  }
6354
- var adRoot = overrideAdPlugin.root;
6355
- var normalRoot = normalPlugin.root;
6374
+ var adRoot = overrideAdPlugin.root, adExtraEl = overrideAdPlugin.extraEls;
6375
+ var normalRoot = normalPlugin.root, normalExtraEl = normalPlugin.extraEls;
6356
6376
  if (fragmentContainer.contains(normalRoot)) {
6357
6377
  fragmentContainer.removeChild(normalRoot);
6358
6378
  }
@@ -6360,6 +6380,18 @@ var AdUIManager = /* @__PURE__ */ function() {
6360
6380
  adRoot.parentNode.insertBefore(normalRoot, adRoot);
6361
6381
  fragmentContainer.appendChild(adRoot);
6362
6382
  }
6383
+ if (Array.isArray(normalExtraEl) && normalExtraEl !== null && normalExtraEl !== void 0 && normalExtraEl.length) {
6384
+ normalExtraEl.forEach(function(normalEl, index2) {
6385
+ if (fragmentContainer.contains(normalEl)) {
6386
+ fragmentContainer.removeChild(normalEl);
6387
+ }
6388
+ var adEl = adExtraEl === null || adExtraEl === void 0 ? void 0 : adExtraEl[index2];
6389
+ if (adEl && adEl.parentNode) {
6390
+ adEl.parentNode.insertBefore(normalEl, adEl);
6391
+ fragmentContainer.appendChild(adEl);
6392
+ }
6393
+ });
6394
+ }
6363
6395
  });
6364
6396
  var otherPlugins = this._getNonAdPlugin();
6365
6397
  otherPlugins.filter(function(plugin2) {
@@ -6467,7 +6499,7 @@ var AdsPlugin$1 = /* @__PURE__ */ function(_Plugin) {
6467
6499
  _createClass$2(AdsPlugin2, [{
6468
6500
  key: "version",
6469
6501
  get: function get() {
6470
- return "3.0.21-rc.4";
6502
+ return "3.0.23-rc.1";
6471
6503
  }
6472
6504
  }, {
6473
6505
  key: "paused",
@@ -6529,55 +6561,37 @@ var AdsPlugin$1 = /* @__PURE__ */ function(_Plugin) {
6529
6561
  }
6530
6562
  }, {
6531
6563
  key: "_initImaAd",
6532
- value: function() {
6533
- var _initImaAd2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
6534
- var _this = this;
6535
- return _regeneratorRuntime().wrap(function _callee$(_context) {
6536
- while (1)
6537
- switch (_context.prev = _context.next) {
6538
- case 0:
6539
- this.csManager = new ImaAdManager({
6540
- plugin: this,
6541
- config: this.config.ima,
6542
- displayContainer: this.root
6543
- });
6544
- this.csManager.once(IMA_SDK_LOAD_START, function() {
6545
- _this.uiManager.showAdContainer();
6546
- });
6547
- this.csManager.on(IMA_SDK_LOAD_ERROR, function() {
6548
- _this.uiManager.hideAdContainer();
6549
- });
6550
- this.csManager.once(IMA_AD_LOADED, function(_ref) {
6551
- var isPreroll = _ref.isPreroll;
6552
- if (!isPreroll) {
6553
- _this.uiManager.hideAdContainer();
6554
- }
6555
- });
6556
- this.csManager.once(IMA_READY_TO_PLAY, function() {
6557
- var _this$initPromise;
6558
- (_this$initPromise = _this.initPromise) === null || _this$initPromise === void 0 ? void 0 : _this$initPromise.resolve();
6559
- });
6560
- this.csManager.on(IMA_CONTENT_PAUSE_REQUESTED, function() {
6561
- _this.uiManager.showAdUI();
6562
- });
6563
- this.csManager.on(IMA_CONTENT_RESUME_REQUESTED, function() {
6564
- _this.uiManager.hideAdUI();
6565
- });
6566
- _context.next = 9;
6567
- return this.csManager.init();
6568
- case 9:
6569
- return _context.abrupt("return", this.csManager);
6570
- case 10:
6571
- case "end":
6572
- return _context.stop();
6573
- }
6574
- }, _callee, this);
6575
- }));
6576
- function _initImaAd() {
6577
- return _initImaAd2.apply(this, arguments);
6578
- }
6579
- return _initImaAd;
6580
- }()
6564
+ value: function _initImaAd() {
6565
+ var _this = this;
6566
+ this.csManager = new ImaAdManager({
6567
+ plugin: this,
6568
+ config: this.config.ima,
6569
+ displayContainer: this.root
6570
+ });
6571
+ this.csManager.once(IMA_SDK_LOAD_START, function() {
6572
+ _this.uiManager.showAdContainer();
6573
+ });
6574
+ this.csManager.on(IMA_SDK_LOAD_ERROR, function() {
6575
+ _this.uiManager.hideAdContainer();
6576
+ });
6577
+ this.csManager.once(IMA_AD_LOADED, function(_ref) {
6578
+ var isPreroll = _ref.isPreroll;
6579
+ if (!isPreroll) {
6580
+ _this.uiManager.hideAdContainer();
6581
+ }
6582
+ });
6583
+ this.csManager.once(IMA_READY_TO_PLAY, function() {
6584
+ var _this$initPromise;
6585
+ (_this$initPromise = _this.initPromise) === null || _this$initPromise === void 0 ? void 0 : _this$initPromise.resolve();
6586
+ });
6587
+ this.csManager.on(IMA_CONTENT_PAUSE_REQUESTED, function() {
6588
+ _this.uiManager.showAdUI();
6589
+ });
6590
+ this.csManager.on(IMA_CONTENT_RESUME_REQUESTED, function() {
6591
+ _this.uiManager.hideAdUI();
6592
+ });
6593
+ this.csManager.init();
6594
+ }
6581
6595
  }, {
6582
6596
  key: "requestAds",
6583
6597
  value: function requestAds() {