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.js CHANGED
@@ -207,7 +207,7 @@ var require_ckplayer = __commonJS({
207
207
  cdnFallback: true
208
208
  // getPath 失败时是否回退到 jsDelivr(内网可设 false,并配置 pluginPath)
209
209
  };
210
- var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.2/dist/";
210
+ var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.5/dist/";
211
211
  function ckplayerEmbed(videoObj) {
212
212
  var rightMenu = [
213
213
  {
@@ -370,26 +370,34 @@ var require_ckplayer = __commonJS({
370
370
  } else {
371
371
  return embed(obj2);
372
372
  }
373
+ }, isUnreliablePluginBase = function(base2) {
374
+ if (!base2 || valType(base2) != "string") {
375
+ return true;
376
+ }
377
+ return /\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2);
373
378
  }, resolveAssetPath = function(folder, file) {
374
- var base = "";
379
+ var base2 = "";
375
380
  if (vars && vars["pluginPath"]) {
376
- base = vars["pluginPath"];
381
+ base2 = vars["pluginPath"];
377
382
  } else if (typeof window !== "undefined" && window.ckplayerBasePath) {
378
- base = window.ckplayerBasePath;
383
+ base2 = window.ckplayerBasePath;
379
384
  }
380
- if (base) {
381
- if (base.slice(-1) !== "/") {
382
- base += "/";
385
+ if (base2 && isUnreliablePluginBase(base2)) {
386
+ base2 = "";
387
+ }
388
+ if (base2) {
389
+ if (base2.slice(-1) !== "/") {
390
+ base2 += "/";
383
391
  }
384
- return base + folder + "/" + file;
392
+ return base2 + folder + "/" + file;
385
393
  }
386
394
  var fromScript = getPath(folder) + file;
387
- if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1) {
395
+ if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(getPath())) {
388
396
  return fromScript;
389
397
  }
390
398
  var allowCdn = !vars || vars["cdnFallback"] !== false;
391
399
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
392
- if (!allowCdn || !cdn || cdn.indexOf("1.0.2") > -1) {
400
+ if (!allowCdn || !cdn || cdn.indexOf("1.0.5") > -1) {
393
401
  return folder + "/" + file;
394
402
  }
395
403
  if (cdn.slice(-1) !== "/") {
@@ -2086,8 +2094,8 @@ var require_ckplayer = __commonJS({
2086
2094
  img = createlImg(adv["file"]);
2087
2095
  C["ad"]["picture"].append(img);
2088
2096
  img.addListener("load", function() {
2089
- var w = this.getWidth(), h = this.getHeight();
2090
- if (w > 0 || h > 0) {
2097
+ var w = this.getWidth(), h2 = this.getHeight();
2098
+ if (w > 0 || h2 > 0) {
2091
2099
  if (adv["link"]) {
2092
2100
  var a2 = createlA("", adv["link"]);
2093
2101
  a2.append(this);
@@ -2165,8 +2173,8 @@ var require_ckplayer = __commonJS({
2165
2173
  C["adPause"].htm("");
2166
2174
  C["adPause"].append(img);
2167
2175
  img.addListener("load", function() {
2168
- var w = this.getWidth(), h = this.getHeight();
2169
- if (w > 0 || h > 0) {
2176
+ var w = this.getWidth(), h2 = this.getHeight();
2177
+ if (w > 0 || h2 > 0) {
2170
2178
  C["adPause"].htm("");
2171
2179
  if (adv["link"]) {
2172
2180
  var a2 = createlA("", adv["link"]);
@@ -2177,7 +2185,7 @@ var require_ckplayer = __commonJS({
2177
2185
  }
2178
2186
  C["adPause"].css({
2179
2187
  "width": w + "px",
2180
- "height": h + "px"
2188
+ "height": h2 + "px"
2181
2189
  });
2182
2190
  if (ad["pauseClose"]) {
2183
2191
  C["adPause"].append(ad["pauseClose"]);
@@ -3589,11 +3597,11 @@ var require_ckplayer = __commonJS({
3589
3597
  C["about"]["textareaEle"].hide();
3590
3598
  message(language["copySucceeded"], true);
3591
3599
  }, getBarHeight = function() {
3592
- var h = C["bar"].getHeight();
3600
+ var h2 = C["bar"].getHeight();
3593
3601
  if (parseFloat(C["bar"]["pbox"].css("top")) < 0) {
3594
- h -= parseInt(C["bar"]["pbox"].css("top"));
3602
+ h2 -= parseInt(C["bar"]["pbox"].css("top"));
3595
3603
  }
3596
- return h;
3604
+ return h2;
3597
3605
  }, hideBar = function() {
3598
3606
  if (mouseSetTime) {
3599
3607
  clearTimeout(mouseSetTime);
@@ -3656,17 +3664,17 @@ var require_ckplayer = __commonJS({
3656
3664
  if (!isUndefined(vars["playbackrateOpen"]) && vars["playbackrateOpen"]) {
3657
3665
  C["bar"]["playbackrate"].show();
3658
3666
  C["bar"]["playbackrate"]["bgbox"].show();
3659
- var w = C["bar"]["playbackrate"]["bg"].getWidth(), h = C["bar"]["playbackrate"]["bg"].getHeight();
3667
+ var w = C["bar"]["playbackrate"]["bg"].getWidth(), h2 = C["bar"]["playbackrate"]["bg"].getHeight();
3660
3668
  var bw = C["bar"]["playbackrate"]["button"].getWidth();
3661
3669
  C["bar"]["playbackrate"]["bg"].css({ "width": w + 10 + "px" });
3662
3670
  w = C["bar"]["playbackrate"]["bg"].getWidth();
3663
3671
  if (getBarHeight() > C["bar"].getHeight()) {
3664
- h += getBarHeight() - C["bar"].getHeight();
3672
+ h2 += getBarHeight() - C["bar"].getHeight();
3665
3673
  }
3666
3674
  C["bar"]["playbackrate"]["bgbox"].attr("style", "");
3667
3675
  C["bar"]["playbackrate"]["bgbox"].css({
3668
3676
  "width": w + "px",
3669
- "height": h + 2 + "px",
3677
+ "height": h2 + 2 + "px",
3670
3678
  "left": -(w - bw) * 0.5 + "px"
3671
3679
  });
3672
3680
  C["bar"]["playbackrate"]["button"].mouseover(function() {
@@ -3726,17 +3734,17 @@ var require_ckplayer = __commonJS({
3726
3734
  C["bar"]["track"].hide();
3727
3735
  C["bar"]["track"].show();
3728
3736
  C["bar"]["track"]["bgbox"].show();
3729
- var w = C["bar"]["track"]["bg"].getWidth(), h = C["bar"]["track"]["bg"].getHeight();
3737
+ var w = C["bar"]["track"]["bg"].getWidth(), h2 = C["bar"]["track"]["bg"].getHeight();
3730
3738
  var bw = C["bar"]["track"]["button"].getWidth();
3731
3739
  C["bar"]["track"]["bg"].css({ "width": w + 10 + "px" });
3732
3740
  w = C["bar"]["track"]["bg"].getWidth();
3733
3741
  if (getBarHeight() > C["bar"].getHeight()) {
3734
- h += getBarHeight() - C["bar"].getHeight();
3742
+ h2 += getBarHeight() - C["bar"].getHeight();
3735
3743
  }
3736
3744
  C["bar"]["track"]["bgbox"].attr("style", "");
3737
3745
  C["bar"]["track"]["bgbox"].css({
3738
3746
  "width": w + "px",
3739
- "height": h + 2 + "px",
3747
+ "height": h2 + 2 + "px",
3740
3748
  "left": -(w - bw) * 0.5 + "px"
3741
3749
  });
3742
3750
  C["bar"]["track"]["button"].mouseover(function() {
@@ -3796,17 +3804,17 @@ var require_ckplayer = __commonJS({
3796
3804
  }
3797
3805
  C["bar"]["definition"].show();
3798
3806
  C["bar"]["definition"]["bgbox"].show();
3799
- var w = C["bar"]["definition"]["bg"].getWidth(), h = C["bar"]["definition"]["bg"].getHeight();
3807
+ var w = C["bar"]["definition"]["bg"].getWidth(), h2 = C["bar"]["definition"]["bg"].getHeight();
3800
3808
  var bw = C["bar"]["definition"]["button"].getWidth();
3801
3809
  C["bar"]["definition"]["bg"].css({ "width": w + 10 + "px" });
3802
3810
  w = C["bar"]["definition"]["bg"].getWidth();
3803
3811
  if (getBarHeight() > C["bar"].getHeight()) {
3804
- h += getBarHeight() - C["bar"].getHeight();
3812
+ h2 += getBarHeight() - C["bar"].getHeight();
3805
3813
  }
3806
3814
  C["bar"]["definition"]["bgbox"].attr("style", "");
3807
3815
  C["bar"]["definition"]["bgbox"].css({
3808
3816
  "width": w + "px",
3809
- "height": h + 2 + "px",
3817
+ "height": h2 + 2 + "px",
3810
3818
  "left": -(w - bw) * 0.5 + "px"
3811
3819
  });
3812
3820
  C["bar"]["definition"]["button"].mouseover(function() {
@@ -4390,9 +4398,9 @@ var require_ckplayer = __commonJS({
4390
4398
  }, tipResize = function(ele, cl, align) {
4391
4399
  var offset = ele.offset();
4392
4400
  var ckOffset = CK.offset();
4393
- var w = C["tip"].getWidth(), h = C["tip"].getHeight();
4401
+ var w = C["tip"].getWidth(), h2 = C["tip"].getHeight();
4394
4402
  var ew = ele.getWidth();
4395
- var left = 0, top = offset["top"] - ckOffset["top"] - h;
4403
+ var left = 0, top = offset["top"] - ckOffset["top"] - h2;
4396
4404
  if (getBarHeight() > C["bar"].getHeight()) {
4397
4405
  top -= getBarHeight() - C["bar"].getHeight();
4398
4406
  }
@@ -4417,8 +4425,8 @@ var require_ckplayer = __commonJS({
4417
4425
  if (left > CM.getWidth() - w) {
4418
4426
  left = CM.getWidth() - w;
4419
4427
  }
4420
- if (top > CM.getHeight() - h) {
4421
- top = CM.getHeight() - h;
4428
+ if (top > CM.getHeight() - h2) {
4429
+ top = CM.getHeight() - h2;
4422
4430
  }
4423
4431
  C["tip"].css({
4424
4432
  "left": left + "px",
@@ -4716,9 +4724,9 @@ var require_ckplayer = __commonJS({
4716
4724
  e = e || window.event;
4717
4725
  var client = getClient(e);
4718
4726
  var bgOffset = bg.offset();
4719
- var h = client["y"] - bgOffset["top"];
4727
+ var h2 = client["y"] - bgOffset["top"];
4720
4728
  var max = bg.getHeight();
4721
- var vol = 1 - h / max;
4729
+ var vol = 1 - h2 / max;
4722
4730
  player.volume(vol);
4723
4731
  };
4724
4732
  bg.mousedown(bgMouseDown);
@@ -5274,7 +5282,7 @@ var require_ckplayer = __commonJS({
5274
5282
  }
5275
5283
  var thisTemp = this;
5276
5284
  var parNode = this.CK;
5277
- var w = parNode.getWidth(), h = parNode.getHeight();
5285
+ var w = parNode.getWidth(), h2 = parNode.getHeight();
5278
5286
  var speed = 10;
5279
5287
  this.timerTween = null;
5280
5288
  this.tweenPlay = true;
@@ -5475,7 +5483,7 @@ var require_ckplayer = __commonJS({
5475
5483
  case "width":
5476
5484
  current = thisTemp.getWidth();
5477
5485
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5478
- result = parseInt(vars2) * h * 0.01;
5486
+ result = parseInt(vars2) * h2 * 0.01;
5479
5487
  } else {
5480
5488
  result = parseInt(vars2);
5481
5489
  }
@@ -5483,7 +5491,7 @@ var require_ckplayer = __commonJS({
5483
5491
  case "height":
5484
5492
  current = thisTemp.getHeight();
5485
5493
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5486
- result = parseInt(vars2) * h * 0.01;
5494
+ result = parseInt(vars2) * h2 * 0.01;
5487
5495
  } else {
5488
5496
  result = parseInt(vars2);
5489
5497
  }
@@ -5521,7 +5529,7 @@ var require_ckplayer = __commonJS({
5521
5529
  current = thisTemp.offset()["top"] - parNode.offset()["top"];
5522
5530
  }
5523
5531
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5524
- result = parseInt(vars2) * h * 0.01;
5532
+ result = parseInt(vars2) * h2 * 0.01;
5525
5533
  } else {
5526
5534
  result = parseInt(vars2);
5527
5535
  }
@@ -5534,7 +5542,7 @@ var require_ckplayer = __commonJS({
5534
5542
  current = parNode.getHeight() - (thisTemp.offset()["top"] - parNode.offset()["top"] + thisTemp.getHeight());
5535
5543
  }
5536
5544
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5537
- result = parseInt(vars2) * h * 0.01;
5545
+ result = parseInt(vars2) * h2 * 0.01;
5538
5546
  } else {
5539
5547
  result = parseInt(vars2);
5540
5548
  }
@@ -5780,7 +5788,7 @@ var require_ckplayer = __commonJS({
5780
5788
  }
5781
5789
  varsTime += time;
5782
5790
  return language["lookBack"] + date("H:i:s", varsTime);
5783
- }, loadJs = function(file, callback2) {
5791
+ }, loadJs = function(file, callback2, isRetry) {
5784
5792
  var fn2 = function() {
5785
5793
  };
5786
5794
  if (!isUndefined(callback2)) {
@@ -5815,19 +5823,37 @@ var require_ckplayer = __commonJS({
5815
5823
  ;
5816
5824
  }, 10);
5817
5825
  };
5818
- var w3c = function() {
5819
- if (valType(fn2) == "function") {
5820
- fn2();
5826
+ var removeScript = function() {
5827
+ try {
5828
+ if (script.parentNode) {
5829
+ script.parentNode.removeChild(script);
5830
+ }
5831
+ } catch (event2) {
5821
5832
  }
5833
+ };
5834
+ var w3c = function() {
5822
5835
  removeListener(script, "load", w3c);
5823
5836
  removeListener(script, "error", w3cError);
5837
+ doReady();
5824
5838
  };
5825
5839
  var w3cError = function() {
5826
- if (valType(fn2) == "function") {
5827
- fn2();
5828
- }
5829
5840
  removeListener(script, "load", w3c);
5830
5841
  removeListener(script, "error", w3cError);
5842
+ removeScript();
5843
+ if (!isRetry && (!vars || vars["cdnFallback"] !== false)) {
5844
+ var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
5845
+ var m2 = String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
5846
+ if (cdn && cdn.indexOf("1.0.5") === -1 && m2) {
5847
+ if (cdn.slice(-1) !== "/") {
5848
+ cdn += "/";
5849
+ }
5850
+ var retryUrl = cdn + m2[1] + "/" + m2[2];
5851
+ if (retryUrl !== file) {
5852
+ loadJs(retryUrl, callback2, true);
5853
+ return;
5854
+ }
5855
+ }
5856
+ }
5831
5857
  };
5832
5858
  try {
5833
5859
  addListener(script, "load", w3c);
@@ -6053,14 +6079,19 @@ var require_ckplayer = __commonJS({
6053
6079
  }
6054
6080
  function getPath(siz) {
6055
6081
  if (typeof window !== "undefined" && window.ckplayerBasePath) {
6056
- var base = window.ckplayerBasePath;
6057
- if (base.slice(-1) !== "/") {
6058
- base += "/";
6082
+ var base2 = window.ckplayerBasePath;
6083
+ if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2)) {
6084
+ base2 = "";
6059
6085
  }
6060
- if (!isUndefined(siz)) {
6061
- return base + siz + "/";
6086
+ if (base2) {
6087
+ if (base2.slice(-1) !== "/") {
6088
+ base2 += "/";
6089
+ }
6090
+ if (!isUndefined(siz)) {
6091
+ return base2 + siz + "/";
6092
+ }
6093
+ return base2;
6062
6094
  }
6063
- return base;
6064
6095
  }
6065
6096
  var scriptList = document.scripts || [], thisPath = scriptList.length ? scriptList[scriptList.length - 1].src : "";
6066
6097
  for (var i2 = 0; i2 < scriptList.length; i2++) {
@@ -6116,41 +6147,41 @@ var require_ckplayer = __commonJS({
6116
6147
  };
6117
6148
  }
6118
6149
  function standardization(o, n) {
6119
- var h = {};
6150
+ var h2 = {};
6120
6151
  var k;
6121
6152
  for (k in o) {
6122
- h[k] = o[k];
6153
+ h2[k] = o[k];
6123
6154
  }
6124
6155
  for (k in n) {
6125
- if (k in h) {
6126
- h[k] = n[k];
6156
+ if (k in h2) {
6157
+ h2[k] = n[k];
6127
6158
  }
6128
6159
  }
6129
- return h;
6160
+ return h2;
6130
6161
  }
6131
6162
  function mergeObj(o, n) {
6132
- var h = {};
6163
+ var h2 = {};
6133
6164
  var k;
6134
6165
  for (k in o) {
6135
- h[k] = o[k];
6166
+ h2[k] = o[k];
6136
6167
  }
6137
6168
  for (k in n) {
6138
- if (k in h) {
6139
- switch (valType(h[k])) {
6169
+ if (k in h2) {
6170
+ switch (valType(h2[k])) {
6140
6171
  case "object":
6141
6172
  if (valType(n[k]) == "object") {
6142
- h[k] = mergeObj(h[k], n[k]);
6173
+ h2[k] = mergeObj(h2[k], n[k]);
6143
6174
  }
6144
6175
  break;
6145
6176
  default:
6146
- if (valType(h[k]) == valType(n[k])) {
6147
- h[k] = n[k];
6177
+ if (valType(h2[k]) == valType(n[k])) {
6178
+ h2[k] = n[k];
6148
6179
  }
6149
6180
  break;
6150
6181
  }
6151
6182
  }
6152
6183
  }
6153
- return h;
6184
+ return h2;
6154
6185
  }
6155
6186
  function valType(val) {
6156
6187
  if (typeof val === "undefined") return "undefined";
@@ -6264,8 +6295,8 @@ var require_ckplayer = __commonJS({
6264
6295
  var result = parseInt(val);
6265
6296
  if (isUndefined(result)) result = 0;
6266
6297
  if (result < 0) result = 0;
6267
- 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 = "";
6268
- if (h !== "00") res += h + ":";
6298
+ 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 = "";
6299
+ if (h2 !== "00") res += h2 + ":";
6269
6300
  res += m2 + ":" + s;
6270
6301
  return res;
6271
6302
  }
@@ -6566,24 +6597,61 @@ var require_ckplayer = __commonJS({
6566
6597
  }
6567
6598
  });
6568
6599
 
6600
+ // src/vue/CkPlayer.js
6601
+ import { h, version as vueVersion } from "vue";
6602
+
6569
6603
  // src/index.js
6570
6604
  var import_ckplayer = __toESM(require_ckplayer());
6571
6605
  var import_meta = {};
6572
6606
  try {
6573
6607
  if (typeof window !== "undefined" && !window.ckplayerBasePath) {
6574
- window.ckplayerBasePath = new URL("./", import_meta.url).href;
6608
+ base = new URL("./", import_meta.url).href;
6609
+ if (/\/dist\/$/i.test(base) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(base) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(base)) {
6610
+ window.ckplayerBasePath = base;
6611
+ }
6575
6612
  }
6576
6613
  } catch (e) {
6577
6614
  }
6615
+ var base;
6578
6616
  var index_default = import_ckplayer.default;
6579
6617
 
6580
- // src/vue/CkPlayer.js
6618
+ // src/shared.js
6581
6619
  var EVENT_NAMES = ["play", "pause", "ended", "volume", "muted", "full", "error", "time", "seek", "screenshot"];
6582
6620
  function createUid() {
6583
6621
  return "ckp-" + Math.random().toString(36).slice(2, 10);
6584
6622
  }
6623
+ function buildPlayerConfig(input) {
6624
+ var opts = input.options || {};
6625
+ var config = {
6626
+ container: input.container,
6627
+ video: input.video,
6628
+ poster: input.poster || "",
6629
+ autoplay: !!input.autoplay,
6630
+ live: input.live != null ? input.live : false,
6631
+ plug: input.plug || "",
6632
+ autoPlug: input.autoPlug !== false,
6633
+ volume: input.volume != null ? input.volume : 0.8,
6634
+ cookie: opts.cookie || input.cookie || createUid()
6635
+ };
6636
+ if (input.pluginPath) {
6637
+ config.pluginPath = input.pluginPath;
6638
+ }
6639
+ for (var key in opts) {
6640
+ if (Object.prototype.hasOwnProperty.call(opts, key) && key !== "container") {
6641
+ config[key] = opts[key];
6642
+ }
6643
+ }
6644
+ if (typeof config.loaded === "string") {
6645
+ delete config.loaded;
6646
+ }
6647
+ return config;
6648
+ }
6649
+
6650
+ // src/vue/CkPlayer.js
6651
+ var unmountHook = typeof vueVersion === "string" && vueVersion.charAt(0) === "3" ? "beforeUnmount" : "beforeDestroy";
6585
6652
  var CkPlayer = {
6586
6653
  name: "CkPlayer",
6654
+ emits: EVENT_NAMES.concat(["ready"]),
6587
6655
  props: {
6588
6656
  video: { required: true },
6589
6657
  poster: { type: String, default: "" },
@@ -6602,35 +6670,47 @@ var CkPlayer = {
6602
6670
  },
6603
6671
  data: function() {
6604
6672
  return {
6605
- player: null,
6606
- instanceId: createUid(),
6607
- destroyed: false
6673
+ instanceId: createUid()
6608
6674
  };
6609
6675
  },
6676
+ created: function() {
6677
+ this.player = null;
6678
+ this._destroyed = false;
6679
+ },
6610
6680
  mounted: function() {
6611
6681
  this.initPlayer();
6612
6682
  },
6613
- beforeDestroy: function() {
6614
- this.teardown();
6615
- },
6616
- beforeUnmount: function() {
6617
- this.teardown();
6618
- },
6619
6683
  watch: {
6620
- video: function() {
6621
- this.reinit();
6684
+ video: {
6685
+ deep: true,
6686
+ handler: function() {
6687
+ this.reinit();
6688
+ }
6622
6689
  },
6623
6690
  poster: function() {
6624
6691
  this.reinit();
6625
6692
  },
6626
6693
  plug: function() {
6627
6694
  this.reinit();
6695
+ },
6696
+ autoplay: function() {
6697
+ this.reinit();
6698
+ },
6699
+ live: function() {
6700
+ this.reinit();
6701
+ },
6702
+ pluginPath: function() {
6703
+ this.reinit();
6704
+ },
6705
+ volume: function(vol) {
6706
+ if (this.player && typeof this.player.volume === "function" && typeof vol === "number") {
6707
+ this.player.volume(vol);
6708
+ }
6628
6709
  }
6629
6710
  },
6630
6711
  methods: {
6631
6712
  buildConfig: function() {
6632
- var opts = this.options || {};
6633
- var config = {
6713
+ return buildPlayerConfig({
6634
6714
  container: this.$refs.container,
6635
6715
  video: this.video,
6636
6716
  poster: this.poster,
@@ -6639,20 +6719,10 @@ var CkPlayer = {
6639
6719
  plug: this.plug,
6640
6720
  autoPlug: this.autoPlug,
6641
6721
  volume: this.volume,
6642
- cookie: opts.cookie || this.instanceId
6643
- };
6644
- if (this.pluginPath) {
6645
- config.pluginPath = this.pluginPath;
6646
- }
6647
- for (var key in opts) {
6648
- if (Object.prototype.hasOwnProperty.call(opts, key) && key !== "container") {
6649
- config[key] = opts[key];
6650
- }
6651
- }
6652
- if (typeof config.loaded === "string") {
6653
- delete config.loaded;
6654
- }
6655
- return config;
6722
+ pluginPath: this.pluginPath,
6723
+ options: this.options,
6724
+ cookie: this.instanceId
6725
+ });
6656
6726
  },
6657
6727
  bindEvents: function() {
6658
6728
  var self2 = this;
@@ -6667,14 +6737,13 @@ var CkPlayer = {
6667
6737
  });
6668
6738
  },
6669
6739
  initPlayer: function() {
6670
- if (typeof window === "undefined" || !this.$refs.container) return;
6671
- this.destroyed = false;
6740
+ if (typeof window === "undefined" || this._destroyed || !this.$refs.container) return;
6672
6741
  this.player = new index_default(this.buildConfig());
6673
6742
  this.bindEvents();
6674
6743
  this.$emit("ready", this.player);
6675
6744
  },
6676
6745
  teardown: function() {
6677
- this.destroyed = true;
6746
+ this._destroyed = true;
6678
6747
  if (this.player && typeof this.player.remove === "function") {
6679
6748
  try {
6680
6749
  this.player.remove();
@@ -6686,8 +6755,9 @@ var CkPlayer = {
6686
6755
  reinit: function() {
6687
6756
  var self2 = this;
6688
6757
  this.teardown();
6689
- this.destroyed = false;
6758
+ this._destroyed = false;
6690
6759
  this.$nextTick(function() {
6760
+ if (self2._destroyed) return;
6691
6761
  self2.initPlayer();
6692
6762
  });
6693
6763
  },
@@ -6722,7 +6792,7 @@ var CkPlayer = {
6722
6792
  }
6723
6793
  },
6724
6794
  render: function() {
6725
- return this.$createElement("div", {
6795
+ return h("div", {
6726
6796
  ref: "container",
6727
6797
  class: ["ckplayer-plus", this.className].filter(Boolean).join(" "),
6728
6798
  style: {
@@ -6732,6 +6802,9 @@ var CkPlayer = {
6732
6802
  });
6733
6803
  }
6734
6804
  };
6805
+ CkPlayer[unmountHook] = function() {
6806
+ this.teardown();
6807
+ };
6735
6808
  var CkPlayer_default = CkPlayer;
6736
6809
 
6737
6810
  // src/vue/index.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ckplayer-plus",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "Enhanced ckplayer X3 packaging with Vue 2/3 and React wrappers — ESM-ready HTML5 video player",
5
5
  "keywords": [
6
6
  "ckplayer",
package/types/index.d.ts CHANGED
@@ -34,6 +34,8 @@ export interface CkplayerConfig {
34
34
  pluginPath?: string;
35
35
  /** 初始跳转秒数;续播时会同步 maxSeeTime(兼容 timeScheduleAdjust=5) */
36
36
  seek?: number | string;
37
+ language?: string;
38
+ timeScheduleAdjust?: 0 | 1 | 2 | 3 | 4 | 5;
37
39
  crossOrigin?: string;
38
40
  cookie?: string | object | any[];
39
41
  /** 仅支持函数;字符串形式已禁用 */
package/types/vue.d.ts CHANGED
@@ -15,6 +15,17 @@ export interface CkPlayerProps {
15
15
  width?: string;
16
16
  height?: string;
17
17
  className?: string;
18
+ onReady?: (player: CkplayerInstance) => void;
19
+ onPlay?: (...args: any[]) => void;
20
+ onPause?: (...args: any[]) => void;
21
+ onEnded?: (...args: any[]) => void;
22
+ onVolume?: (vol: number) => void;
23
+ onMuted?: (state: boolean) => void;
24
+ onFull?: (state: boolean) => void;
25
+ onError?: (err: any) => void;
26
+ onTime?: (t: number) => void;
27
+ onSeek?: (...args: any[]) => void;
28
+ onScreenshot?: (...args: any[]) => void;
18
29
  }
19
30
 
20
31
  declare const CkPlayer: {