ckplayer-plus 1.0.2 → 1.0.5

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.
package/dist/vue.cjs CHANGED
@@ -212,7 +212,7 @@ var require_ckplayer = __commonJS({
212
212
  cdnFallback: true
213
213
  // getPath 失败时是否回退到 jsDelivr(内网可设 false,并配置 pluginPath)
214
214
  };
215
- var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.2/dist/";
215
+ var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.5/dist/";
216
216
  function ckplayerEmbed(videoObj) {
217
217
  var rightMenu = [
218
218
  {
@@ -375,26 +375,34 @@ var require_ckplayer = __commonJS({
375
375
  } else {
376
376
  return embed(obj2);
377
377
  }
378
+ }, isUnreliablePluginBase = function(base2) {
379
+ if (!base2 || valType(base2) != "string") {
380
+ return true;
381
+ }
382
+ return /\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2);
378
383
  }, resolveAssetPath = function(folder, file) {
379
- var base = "";
384
+ var base2 = "";
380
385
  if (vars && vars["pluginPath"]) {
381
- base = vars["pluginPath"];
386
+ base2 = vars["pluginPath"];
382
387
  } else if (typeof window !== "undefined" && window.ckplayerBasePath) {
383
- base = window.ckplayerBasePath;
388
+ base2 = window.ckplayerBasePath;
384
389
  }
385
- if (base) {
386
- if (base.slice(-1) !== "/") {
387
- base += "/";
390
+ if (base2 && isUnreliablePluginBase(base2)) {
391
+ base2 = "";
392
+ }
393
+ if (base2) {
394
+ if (base2.slice(-1) !== "/") {
395
+ base2 += "/";
388
396
  }
389
- return base + folder + "/" + file;
397
+ return base2 + folder + "/" + file;
390
398
  }
391
399
  var fromScript = getPath(folder) + file;
392
- if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1) {
400
+ if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(getPath())) {
393
401
  return fromScript;
394
402
  }
395
403
  var allowCdn = !vars || vars["cdnFallback"] !== false;
396
404
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
397
- if (!allowCdn || !cdn || cdn.indexOf("1.0.2") > -1) {
405
+ if (!allowCdn || !cdn || cdn.indexOf("1.0.5") > -1) {
398
406
  return folder + "/" + file;
399
407
  }
400
408
  if (cdn.slice(-1) !== "/") {
@@ -2091,8 +2099,8 @@ var require_ckplayer = __commonJS({
2091
2099
  img = createlImg(adv["file"]);
2092
2100
  C["ad"]["picture"].append(img);
2093
2101
  img.addListener("load", function() {
2094
- var w = this.getWidth(), h = this.getHeight();
2095
- if (w > 0 || h > 0) {
2102
+ var w = this.getWidth(), h2 = this.getHeight();
2103
+ if (w > 0 || h2 > 0) {
2096
2104
  if (adv["link"]) {
2097
2105
  var a2 = createlA("", adv["link"]);
2098
2106
  a2.append(this);
@@ -2170,8 +2178,8 @@ var require_ckplayer = __commonJS({
2170
2178
  C["adPause"].htm("");
2171
2179
  C["adPause"].append(img);
2172
2180
  img.addListener("load", function() {
2173
- var w = this.getWidth(), h = this.getHeight();
2174
- if (w > 0 || h > 0) {
2181
+ var w = this.getWidth(), h2 = this.getHeight();
2182
+ if (w > 0 || h2 > 0) {
2175
2183
  C["adPause"].htm("");
2176
2184
  if (adv["link"]) {
2177
2185
  var a2 = createlA("", adv["link"]);
@@ -2182,7 +2190,7 @@ var require_ckplayer = __commonJS({
2182
2190
  }
2183
2191
  C["adPause"].css({
2184
2192
  "width": w + "px",
2185
- "height": h + "px"
2193
+ "height": h2 + "px"
2186
2194
  });
2187
2195
  if (ad["pauseClose"]) {
2188
2196
  C["adPause"].append(ad["pauseClose"]);
@@ -3594,11 +3602,11 @@ var require_ckplayer = __commonJS({
3594
3602
  C["about"]["textareaEle"].hide();
3595
3603
  message(language["copySucceeded"], true);
3596
3604
  }, getBarHeight = function() {
3597
- var h = C["bar"].getHeight();
3605
+ var h2 = C["bar"].getHeight();
3598
3606
  if (parseFloat(C["bar"]["pbox"].css("top")) < 0) {
3599
- h -= parseInt(C["bar"]["pbox"].css("top"));
3607
+ h2 -= parseInt(C["bar"]["pbox"].css("top"));
3600
3608
  }
3601
- return h;
3609
+ return h2;
3602
3610
  }, hideBar = function() {
3603
3611
  if (mouseSetTime) {
3604
3612
  clearTimeout(mouseSetTime);
@@ -3661,17 +3669,17 @@ var require_ckplayer = __commonJS({
3661
3669
  if (!isUndefined(vars["playbackrateOpen"]) && vars["playbackrateOpen"]) {
3662
3670
  C["bar"]["playbackrate"].show();
3663
3671
  C["bar"]["playbackrate"]["bgbox"].show();
3664
- var w = C["bar"]["playbackrate"]["bg"].getWidth(), h = C["bar"]["playbackrate"]["bg"].getHeight();
3672
+ var w = C["bar"]["playbackrate"]["bg"].getWidth(), h2 = C["bar"]["playbackrate"]["bg"].getHeight();
3665
3673
  var bw = C["bar"]["playbackrate"]["button"].getWidth();
3666
3674
  C["bar"]["playbackrate"]["bg"].css({ "width": w + 10 + "px" });
3667
3675
  w = C["bar"]["playbackrate"]["bg"].getWidth();
3668
3676
  if (getBarHeight() > C["bar"].getHeight()) {
3669
- h += getBarHeight() - C["bar"].getHeight();
3677
+ h2 += getBarHeight() - C["bar"].getHeight();
3670
3678
  }
3671
3679
  C["bar"]["playbackrate"]["bgbox"].attr("style", "");
3672
3680
  C["bar"]["playbackrate"]["bgbox"].css({
3673
3681
  "width": w + "px",
3674
- "height": h + 2 + "px",
3682
+ "height": h2 + 2 + "px",
3675
3683
  "left": -(w - bw) * 0.5 + "px"
3676
3684
  });
3677
3685
  C["bar"]["playbackrate"]["button"].mouseover(function() {
@@ -3731,17 +3739,17 @@ var require_ckplayer = __commonJS({
3731
3739
  C["bar"]["track"].hide();
3732
3740
  C["bar"]["track"].show();
3733
3741
  C["bar"]["track"]["bgbox"].show();
3734
- var w = C["bar"]["track"]["bg"].getWidth(), h = C["bar"]["track"]["bg"].getHeight();
3742
+ var w = C["bar"]["track"]["bg"].getWidth(), h2 = C["bar"]["track"]["bg"].getHeight();
3735
3743
  var bw = C["bar"]["track"]["button"].getWidth();
3736
3744
  C["bar"]["track"]["bg"].css({ "width": w + 10 + "px" });
3737
3745
  w = C["bar"]["track"]["bg"].getWidth();
3738
3746
  if (getBarHeight() > C["bar"].getHeight()) {
3739
- h += getBarHeight() - C["bar"].getHeight();
3747
+ h2 += getBarHeight() - C["bar"].getHeight();
3740
3748
  }
3741
3749
  C["bar"]["track"]["bgbox"].attr("style", "");
3742
3750
  C["bar"]["track"]["bgbox"].css({
3743
3751
  "width": w + "px",
3744
- "height": h + 2 + "px",
3752
+ "height": h2 + 2 + "px",
3745
3753
  "left": -(w - bw) * 0.5 + "px"
3746
3754
  });
3747
3755
  C["bar"]["track"]["button"].mouseover(function() {
@@ -3801,17 +3809,17 @@ var require_ckplayer = __commonJS({
3801
3809
  }
3802
3810
  C["bar"]["definition"].show();
3803
3811
  C["bar"]["definition"]["bgbox"].show();
3804
- var w = C["bar"]["definition"]["bg"].getWidth(), h = C["bar"]["definition"]["bg"].getHeight();
3812
+ var w = C["bar"]["definition"]["bg"].getWidth(), h2 = C["bar"]["definition"]["bg"].getHeight();
3805
3813
  var bw = C["bar"]["definition"]["button"].getWidth();
3806
3814
  C["bar"]["definition"]["bg"].css({ "width": w + 10 + "px" });
3807
3815
  w = C["bar"]["definition"]["bg"].getWidth();
3808
3816
  if (getBarHeight() > C["bar"].getHeight()) {
3809
- h += getBarHeight() - C["bar"].getHeight();
3817
+ h2 += getBarHeight() - C["bar"].getHeight();
3810
3818
  }
3811
3819
  C["bar"]["definition"]["bgbox"].attr("style", "");
3812
3820
  C["bar"]["definition"]["bgbox"].css({
3813
3821
  "width": w + "px",
3814
- "height": h + 2 + "px",
3822
+ "height": h2 + 2 + "px",
3815
3823
  "left": -(w - bw) * 0.5 + "px"
3816
3824
  });
3817
3825
  C["bar"]["definition"]["button"].mouseover(function() {
@@ -4395,9 +4403,9 @@ var require_ckplayer = __commonJS({
4395
4403
  }, tipResize = function(ele, cl, align) {
4396
4404
  var offset = ele.offset();
4397
4405
  var ckOffset = CK.offset();
4398
- var w = C["tip"].getWidth(), h = C["tip"].getHeight();
4406
+ var w = C["tip"].getWidth(), h2 = C["tip"].getHeight();
4399
4407
  var ew = ele.getWidth();
4400
- var left = 0, top = offset["top"] - ckOffset["top"] - h;
4408
+ var left = 0, top = offset["top"] - ckOffset["top"] - h2;
4401
4409
  if (getBarHeight() > C["bar"].getHeight()) {
4402
4410
  top -= getBarHeight() - C["bar"].getHeight();
4403
4411
  }
@@ -4422,8 +4430,8 @@ var require_ckplayer = __commonJS({
4422
4430
  if (left > CM.getWidth() - w) {
4423
4431
  left = CM.getWidth() - w;
4424
4432
  }
4425
- if (top > CM.getHeight() - h) {
4426
- top = CM.getHeight() - h;
4433
+ if (top > CM.getHeight() - h2) {
4434
+ top = CM.getHeight() - h2;
4427
4435
  }
4428
4436
  C["tip"].css({
4429
4437
  "left": left + "px",
@@ -4721,9 +4729,9 @@ var require_ckplayer = __commonJS({
4721
4729
  e = e || window.event;
4722
4730
  var client = getClient(e);
4723
4731
  var bgOffset = bg.offset();
4724
- var h = client["y"] - bgOffset["top"];
4732
+ var h2 = client["y"] - bgOffset["top"];
4725
4733
  var max = bg.getHeight();
4726
- var vol = 1 - h / max;
4734
+ var vol = 1 - h2 / max;
4727
4735
  player.volume(vol);
4728
4736
  };
4729
4737
  bg.mousedown(bgMouseDown);
@@ -5279,7 +5287,7 @@ var require_ckplayer = __commonJS({
5279
5287
  }
5280
5288
  var thisTemp = this;
5281
5289
  var parNode = this.CK;
5282
- var w = parNode.getWidth(), h = parNode.getHeight();
5290
+ var w = parNode.getWidth(), h2 = parNode.getHeight();
5283
5291
  var speed = 10;
5284
5292
  this.timerTween = null;
5285
5293
  this.tweenPlay = true;
@@ -5480,7 +5488,7 @@ var require_ckplayer = __commonJS({
5480
5488
  case "width":
5481
5489
  current = thisTemp.getWidth();
5482
5490
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5483
- result = parseInt(vars2) * h * 0.01;
5491
+ result = parseInt(vars2) * h2 * 0.01;
5484
5492
  } else {
5485
5493
  result = parseInt(vars2);
5486
5494
  }
@@ -5488,7 +5496,7 @@ var require_ckplayer = __commonJS({
5488
5496
  case "height":
5489
5497
  current = thisTemp.getHeight();
5490
5498
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5491
- result = parseInt(vars2) * h * 0.01;
5499
+ result = parseInt(vars2) * h2 * 0.01;
5492
5500
  } else {
5493
5501
  result = parseInt(vars2);
5494
5502
  }
@@ -5526,7 +5534,7 @@ var require_ckplayer = __commonJS({
5526
5534
  current = thisTemp.offset()["top"] - parNode.offset()["top"];
5527
5535
  }
5528
5536
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5529
- result = parseInt(vars2) * h * 0.01;
5537
+ result = parseInt(vars2) * h2 * 0.01;
5530
5538
  } else {
5531
5539
  result = parseInt(vars2);
5532
5540
  }
@@ -5539,7 +5547,7 @@ var require_ckplayer = __commonJS({
5539
5547
  current = parNode.getHeight() - (thisTemp.offset()["top"] - parNode.offset()["top"] + thisTemp.getHeight());
5540
5548
  }
5541
5549
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5542
- result = parseInt(vars2) * h * 0.01;
5550
+ result = parseInt(vars2) * h2 * 0.01;
5543
5551
  } else {
5544
5552
  result = parseInt(vars2);
5545
5553
  }
@@ -5785,7 +5793,7 @@ var require_ckplayer = __commonJS({
5785
5793
  }
5786
5794
  varsTime += time;
5787
5795
  return language["lookBack"] + date("H:i:s", varsTime);
5788
- }, loadJs = function(file, callback2) {
5796
+ }, loadJs = function(file, callback2, isRetry) {
5789
5797
  var fn2 = function() {
5790
5798
  };
5791
5799
  if (!isUndefined(callback2)) {
@@ -5820,19 +5828,37 @@ var require_ckplayer = __commonJS({
5820
5828
  ;
5821
5829
  }, 10);
5822
5830
  };
5823
- var w3c = function() {
5824
- if (valType(fn2) == "function") {
5825
- fn2();
5831
+ var removeScript = function() {
5832
+ try {
5833
+ if (script.parentNode) {
5834
+ script.parentNode.removeChild(script);
5835
+ }
5836
+ } catch (event2) {
5826
5837
  }
5838
+ };
5839
+ var w3c = function() {
5827
5840
  removeListener(script, "load", w3c);
5828
5841
  removeListener(script, "error", w3cError);
5842
+ doReady();
5829
5843
  };
5830
5844
  var w3cError = function() {
5831
- if (valType(fn2) == "function") {
5832
- fn2();
5833
- }
5834
5845
  removeListener(script, "load", w3c);
5835
5846
  removeListener(script, "error", w3cError);
5847
+ removeScript();
5848
+ if (!isRetry && (!vars || vars["cdnFallback"] !== false)) {
5849
+ var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
5850
+ var m2 = String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
5851
+ if (cdn && cdn.indexOf("1.0.5") === -1 && m2) {
5852
+ if (cdn.slice(-1) !== "/") {
5853
+ cdn += "/";
5854
+ }
5855
+ var retryUrl = cdn + m2[1] + "/" + m2[2];
5856
+ if (retryUrl !== file) {
5857
+ loadJs(retryUrl, callback2, true);
5858
+ return;
5859
+ }
5860
+ }
5861
+ }
5836
5862
  };
5837
5863
  try {
5838
5864
  addListener(script, "load", w3c);
@@ -6058,14 +6084,19 @@ var require_ckplayer = __commonJS({
6058
6084
  }
6059
6085
  function getPath(siz) {
6060
6086
  if (typeof window !== "undefined" && window.ckplayerBasePath) {
6061
- var base = window.ckplayerBasePath;
6062
- if (base.slice(-1) !== "/") {
6063
- base += "/";
6087
+ var base2 = window.ckplayerBasePath;
6088
+ if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2)) {
6089
+ base2 = "";
6064
6090
  }
6065
- if (!isUndefined(siz)) {
6066
- return base + siz + "/";
6091
+ if (base2) {
6092
+ if (base2.slice(-1) !== "/") {
6093
+ base2 += "/";
6094
+ }
6095
+ if (!isUndefined(siz)) {
6096
+ return base2 + siz + "/";
6097
+ }
6098
+ return base2;
6067
6099
  }
6068
- return base;
6069
6100
  }
6070
6101
  var scriptList = document.scripts || [], thisPath = scriptList.length ? scriptList[scriptList.length - 1].src : "";
6071
6102
  for (var i2 = 0; i2 < scriptList.length; i2++) {
@@ -6121,41 +6152,41 @@ var require_ckplayer = __commonJS({
6121
6152
  };
6122
6153
  }
6123
6154
  function standardization(o, n) {
6124
- var h = {};
6155
+ var h2 = {};
6125
6156
  var k;
6126
6157
  for (k in o) {
6127
- h[k] = o[k];
6158
+ h2[k] = o[k];
6128
6159
  }
6129
6160
  for (k in n) {
6130
- if (k in h) {
6131
- h[k] = n[k];
6161
+ if (k in h2) {
6162
+ h2[k] = n[k];
6132
6163
  }
6133
6164
  }
6134
- return h;
6165
+ return h2;
6135
6166
  }
6136
6167
  function mergeObj(o, n) {
6137
- var h = {};
6168
+ var h2 = {};
6138
6169
  var k;
6139
6170
  for (k in o) {
6140
- h[k] = o[k];
6171
+ h2[k] = o[k];
6141
6172
  }
6142
6173
  for (k in n) {
6143
- if (k in h) {
6144
- switch (valType(h[k])) {
6174
+ if (k in h2) {
6175
+ switch (valType(h2[k])) {
6145
6176
  case "object":
6146
6177
  if (valType(n[k]) == "object") {
6147
- h[k] = mergeObj(h[k], n[k]);
6178
+ h2[k] = mergeObj(h2[k], n[k]);
6148
6179
  }
6149
6180
  break;
6150
6181
  default:
6151
- if (valType(h[k]) == valType(n[k])) {
6152
- h[k] = n[k];
6182
+ if (valType(h2[k]) == valType(n[k])) {
6183
+ h2[k] = n[k];
6153
6184
  }
6154
6185
  break;
6155
6186
  }
6156
6187
  }
6157
6188
  }
6158
- return h;
6189
+ return h2;
6159
6190
  }
6160
6191
  function valType(val) {
6161
6192
  if (typeof val === "undefined") return "undefined";
@@ -6269,8 +6300,8 @@ var require_ckplayer = __commonJS({
6269
6300
  var result = parseInt(val);
6270
6301
  if (isUndefined(result)) result = 0;
6271
6302
  if (result < 0) result = 0;
6272
- var h = Math.floor(result / 3600) < 10 ? "0" + Math.floor(result / 3600) : Math.floor(result / 3600), m2 = Math.floor(result / 60 % 60) < 10 ? "0" + Math.floor(result / 60 % 60) : Math.floor(result / 60 % 60), s = Math.floor(result % 60) < 10 ? "0" + Math.floor(result % 60) : Math.floor(result % 60), res = "";
6273
- if (h !== "00") res += h + ":";
6303
+ var h2 = Math.floor(result / 3600) < 10 ? "0" + Math.floor(result / 3600) : Math.floor(result / 3600), m2 = Math.floor(result / 60 % 60) < 10 ? "0" + Math.floor(result / 60 % 60) : Math.floor(result / 60 % 60), s = Math.floor(result % 60) < 10 ? "0" + Math.floor(result % 60) : Math.floor(result % 60), res = "";
6304
+ if (h2 !== "00") res += h2 + ":";
6274
6305
  res += m2 + ":" + s;
6275
6306
  return res;
6276
6307
  }
@@ -6579,24 +6610,61 @@ __export(index_exports, {
6579
6610
  });
6580
6611
  module.exports = __toCommonJS(index_exports);
6581
6612
 
6613
+ // src/vue/CkPlayer.js
6614
+ var import_vue = require("vue");
6615
+
6582
6616
  // src/index.js
6583
6617
  var import_ckplayer = __toESM(require_ckplayer());
6584
6618
  var import_meta = {};
6585
6619
  try {
6586
6620
  if (typeof window !== "undefined" && !window.ckplayerBasePath) {
6587
- window.ckplayerBasePath = new URL("./", import_meta.url).href;
6621
+ base = new URL("./", import_meta.url).href;
6622
+ if (/\/dist\/$/i.test(base) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(base) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(base)) {
6623
+ window.ckplayerBasePath = base;
6624
+ }
6588
6625
  }
6589
6626
  } catch (e) {
6590
6627
  }
6628
+ var base;
6591
6629
  var index_default = import_ckplayer.default;
6592
6630
 
6593
- // src/vue/CkPlayer.js
6631
+ // src/shared.js
6594
6632
  var EVENT_NAMES = ["play", "pause", "ended", "volume", "muted", "full", "error", "time", "seek", "screenshot"];
6595
6633
  function createUid() {
6596
6634
  return "ckp-" + Math.random().toString(36).slice(2, 10);
6597
6635
  }
6636
+ function buildPlayerConfig(input) {
6637
+ var opts = input.options || {};
6638
+ var config = {
6639
+ container: input.container,
6640
+ video: input.video,
6641
+ poster: input.poster || "",
6642
+ autoplay: !!input.autoplay,
6643
+ live: input.live != null ? input.live : false,
6644
+ plug: input.plug || "",
6645
+ autoPlug: input.autoPlug !== false,
6646
+ volume: input.volume != null ? input.volume : 0.8,
6647
+ cookie: opts.cookie || input.cookie || createUid()
6648
+ };
6649
+ if (input.pluginPath) {
6650
+ config.pluginPath = input.pluginPath;
6651
+ }
6652
+ for (var key in opts) {
6653
+ if (Object.prototype.hasOwnProperty.call(opts, key) && key !== "container") {
6654
+ config[key] = opts[key];
6655
+ }
6656
+ }
6657
+ if (typeof config.loaded === "string") {
6658
+ delete config.loaded;
6659
+ }
6660
+ return config;
6661
+ }
6662
+
6663
+ // src/vue/CkPlayer.js
6664
+ var unmountHook = typeof import_vue.version === "string" && import_vue.version.charAt(0) === "3" ? "beforeUnmount" : "beforeDestroy";
6598
6665
  var CkPlayer = {
6599
6666
  name: "CkPlayer",
6667
+ emits: EVENT_NAMES.concat(["ready"]),
6600
6668
  props: {
6601
6669
  video: { required: true },
6602
6670
  poster: { type: String, default: "" },
@@ -6615,35 +6683,47 @@ var CkPlayer = {
6615
6683
  },
6616
6684
  data: function() {
6617
6685
  return {
6618
- player: null,
6619
- instanceId: createUid(),
6620
- destroyed: false
6686
+ instanceId: createUid()
6621
6687
  };
6622
6688
  },
6689
+ created: function() {
6690
+ this.player = null;
6691
+ this._destroyed = false;
6692
+ },
6623
6693
  mounted: function() {
6624
6694
  this.initPlayer();
6625
6695
  },
6626
- beforeDestroy: function() {
6627
- this.teardown();
6628
- },
6629
- beforeUnmount: function() {
6630
- this.teardown();
6631
- },
6632
6696
  watch: {
6633
- video: function() {
6634
- this.reinit();
6697
+ video: {
6698
+ deep: true,
6699
+ handler: function() {
6700
+ this.reinit();
6701
+ }
6635
6702
  },
6636
6703
  poster: function() {
6637
6704
  this.reinit();
6638
6705
  },
6639
6706
  plug: function() {
6640
6707
  this.reinit();
6708
+ },
6709
+ autoplay: function() {
6710
+ this.reinit();
6711
+ },
6712
+ live: function() {
6713
+ this.reinit();
6714
+ },
6715
+ pluginPath: function() {
6716
+ this.reinit();
6717
+ },
6718
+ volume: function(vol) {
6719
+ if (this.player && typeof this.player.volume === "function" && typeof vol === "number") {
6720
+ this.player.volume(vol);
6721
+ }
6641
6722
  }
6642
6723
  },
6643
6724
  methods: {
6644
6725
  buildConfig: function() {
6645
- var opts = this.options || {};
6646
- var config = {
6726
+ return buildPlayerConfig({
6647
6727
  container: this.$refs.container,
6648
6728
  video: this.video,
6649
6729
  poster: this.poster,
@@ -6652,20 +6732,10 @@ var CkPlayer = {
6652
6732
  plug: this.plug,
6653
6733
  autoPlug: this.autoPlug,
6654
6734
  volume: this.volume,
6655
- cookie: opts.cookie || this.instanceId
6656
- };
6657
- if (this.pluginPath) {
6658
- config.pluginPath = this.pluginPath;
6659
- }
6660
- for (var key in opts) {
6661
- if (Object.prototype.hasOwnProperty.call(opts, key) && key !== "container") {
6662
- config[key] = opts[key];
6663
- }
6664
- }
6665
- if (typeof config.loaded === "string") {
6666
- delete config.loaded;
6667
- }
6668
- return config;
6735
+ pluginPath: this.pluginPath,
6736
+ options: this.options,
6737
+ cookie: this.instanceId
6738
+ });
6669
6739
  },
6670
6740
  bindEvents: function() {
6671
6741
  var self2 = this;
@@ -6680,14 +6750,13 @@ var CkPlayer = {
6680
6750
  });
6681
6751
  },
6682
6752
  initPlayer: function() {
6683
- if (typeof window === "undefined" || !this.$refs.container) return;
6684
- this.destroyed = false;
6753
+ if (typeof window === "undefined" || this._destroyed || !this.$refs.container) return;
6685
6754
  this.player = new index_default(this.buildConfig());
6686
6755
  this.bindEvents();
6687
6756
  this.$emit("ready", this.player);
6688
6757
  },
6689
6758
  teardown: function() {
6690
- this.destroyed = true;
6759
+ this._destroyed = true;
6691
6760
  if (this.player && typeof this.player.remove === "function") {
6692
6761
  try {
6693
6762
  this.player.remove();
@@ -6699,8 +6768,9 @@ var CkPlayer = {
6699
6768
  reinit: function() {
6700
6769
  var self2 = this;
6701
6770
  this.teardown();
6702
- this.destroyed = false;
6771
+ this._destroyed = false;
6703
6772
  this.$nextTick(function() {
6773
+ if (self2._destroyed) return;
6704
6774
  self2.initPlayer();
6705
6775
  });
6706
6776
  },
@@ -6735,7 +6805,7 @@ var CkPlayer = {
6735
6805
  }
6736
6806
  },
6737
6807
  render: function() {
6738
- return this.$createElement("div", {
6808
+ return (0, import_vue.h)("div", {
6739
6809
  ref: "container",
6740
6810
  class: ["ckplayer-plus", this.className].filter(Boolean).join(" "),
6741
6811
  style: {
@@ -6745,6 +6815,9 @@ var CkPlayer = {
6745
6815
  });
6746
6816
  }
6747
6817
  };
6818
+ CkPlayer[unmountHook] = function() {
6819
+ this.teardown();
6820
+ };
6748
6821
  var CkPlayer_default = CkPlayer;
6749
6822
 
6750
6823
  // src/vue/index.js