ckplayer-plus 1.0.3 → 1.0.6

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.3/dist/";
215
+ var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.6/dist/";
216
216
  function ckplayerEmbed(videoObj) {
217
217
  var rightMenu = [
218
218
  {
@@ -237,6 +237,11 @@ var require_ckplayer = __commonJS({
237
237
  var paused = true;
238
238
  var loadTime = 0;
239
239
  var seekTime = 0;
240
+ var seekRetryTimer = null;
241
+ var seekRetryCount = 0;
242
+ var seekApplyLock = false;
243
+ var decodeRecoverCount = 0;
244
+ var hlsStartPositionUsed = false;
240
245
  var oldTime = 0, playTime = 0, firstSeekTime = -1, maxSeeTime = 0;
241
246
  var isChangeDef = true;
242
247
  var playType = "";
@@ -375,26 +380,34 @@ var require_ckplayer = __commonJS({
375
380
  } else {
376
381
  return embed(obj2);
377
382
  }
383
+ }, isUnreliablePluginBase = function(base2) {
384
+ if (!base2 || valType(base2) != "string") {
385
+ return true;
386
+ }
387
+ return /\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2);
378
388
  }, resolveAssetPath = function(folder, file) {
379
- var base = "";
389
+ var base2 = "";
380
390
  if (vars && vars["pluginPath"]) {
381
- base = vars["pluginPath"];
391
+ base2 = vars["pluginPath"];
382
392
  } else if (typeof window !== "undefined" && window.ckplayerBasePath) {
383
- base = window.ckplayerBasePath;
393
+ base2 = window.ckplayerBasePath;
384
394
  }
385
- if (base) {
386
- if (base.slice(-1) !== "/") {
387
- base += "/";
395
+ if (base2 && isUnreliablePluginBase(base2)) {
396
+ base2 = "";
397
+ }
398
+ if (base2) {
399
+ if (base2.slice(-1) !== "/") {
400
+ base2 += "/";
388
401
  }
389
- return base + folder + "/" + file;
402
+ return base2 + folder + "/" + file;
390
403
  }
391
404
  var fromScript = getPath(folder) + file;
392
- if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1) {
405
+ if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(getPath())) {
393
406
  return fromScript;
394
407
  }
395
408
  var allowCdn = !vars || vars["cdnFallback"] !== false;
396
409
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
397
- if (!allowCdn || !cdn || cdn.indexOf("1.0.3") > -1) {
410
+ if (!allowCdn || !cdn || cdn.indexOf("1.0.6") > -1) {
398
411
  return folder + "/" + file;
399
412
  }
400
413
  if (cdn.slice(-1) !== "/") {
@@ -708,11 +721,24 @@ var require_ckplayer = __commonJS({
708
721
  }, hlsPlayer = function(url) {
709
722
  var startHls = function() {
710
723
  if (typeof Hls !== "undefined" && !isUndefined(Hls) && Hls.isSupported()) {
711
- hls = new Hls();
724
+ var hlsConf = {};
725
+ if (seekTime && seekTime > 0 && (isUndefined(vars["live"]) || !vars["live"])) {
726
+ hlsConf.startPosition = seekTime;
727
+ maxSeeTime = Math.max(maxSeeTime, seekTime);
728
+ if (firstSeekTime < 0) {
729
+ firstSeekTime = seekTime;
730
+ }
731
+ seekTime = 0;
732
+ hlsStartPositionUsed = true;
733
+ clearSeekRetry();
734
+ }
735
+ hls = new Hls(hlsConf);
712
736
  hls.loadSource(url);
713
737
  hls.attachMedia(video);
714
738
  hls.on(Hls.Events.MANIFEST_PARSED, function() {
715
- applyPendingSeek();
739
+ if (!hlsStartPositionUsed) {
740
+ applyPendingSeek();
741
+ }
716
742
  });
717
743
  hls.on(Hls.Events.ERROR, function(event2, data) {
718
744
  var code = 9;
@@ -730,6 +756,13 @@ var require_ckplayer = __commonJS({
730
756
  }
731
757
  }
732
758
  }
759
+ if (fatal && data.type === Hls.ErrorTypes.MEDIA_ERROR && hls && typeof hls.recoverMediaError === "function") {
760
+ try {
761
+ hls.recoverMediaError();
762
+ fatal = false;
763
+ } catch (errRecover) {
764
+ }
765
+ }
733
766
  CT.error = { code, message: message2 };
734
767
  eventTarget("error", CT.error);
735
768
  if (fatal) {
@@ -1411,8 +1444,28 @@ var require_ckplayer = __commonJS({
1411
1444
  checkTrack();
1412
1445
  }
1413
1446
  }
1414
- }, applyPendingSeek = function() {
1415
- if (!seekTime || !video) {
1447
+ }, timeInBuffered = function(t) {
1448
+ if (!video || isUndefined(video.buffered)) {
1449
+ return false;
1450
+ }
1451
+ try {
1452
+ var buf = video.buffered;
1453
+ for (var i2 = 0; i2 < buf.length; i2++) {
1454
+ if (t >= buf.start(i2) - 0.35 && t <= buf.end(i2) + 0.15) {
1455
+ return true;
1456
+ }
1457
+ }
1458
+ } catch (event2) {
1459
+ }
1460
+ return false;
1461
+ }, clearSeekRetry = function() {
1462
+ if (seekRetryTimer) {
1463
+ clearTimeout(seekRetryTimer);
1464
+ seekRetryTimer = null;
1465
+ }
1466
+ seekRetryCount = 0;
1467
+ }, applyPendingSeek = function(force) {
1468
+ if (!seekTime || !video || seekApplyLock) {
1416
1469
  return;
1417
1470
  }
1418
1471
  if (!isUndefined(vars["live"]) && (valType(vars["live"]) == "boolean" && vars["live"] || valType(vars["live"]) == "number")) {
@@ -1423,18 +1476,92 @@ var require_ckplayer = __commonJS({
1423
1476
  if (dur && isFinite(dur) && dur > 0 && t >= dur) {
1424
1477
  t = Math.max(0, dur - 0.3);
1425
1478
  }
1479
+ if (t <= 0) {
1480
+ seekTime = 0;
1481
+ clearSeekRetry();
1482
+ return;
1483
+ }
1484
+ var readyEnough = !isUndefined(video.readyState) && video.readyState >= 2;
1485
+ var bufferedOk = timeInBuffered(t);
1486
+ if (!force && !bufferedOk && (!readyEnough || video.readyState < 3)) {
1487
+ seekRetryCount++;
1488
+ if (seekRetryCount <= 50) {
1489
+ try {
1490
+ if (hls && typeof hls.startLoad === "function") {
1491
+ hls.startLoad(t);
1492
+ }
1493
+ } catch (event2) {
1494
+ }
1495
+ if (seekRetryTimer) {
1496
+ clearTimeout(seekRetryTimer);
1497
+ }
1498
+ seekRetryTimer = setTimeout(function() {
1499
+ applyPendingSeek(false);
1500
+ }, 200);
1501
+ return;
1502
+ }
1503
+ }
1504
+ clearSeekRetry();
1426
1505
  if (t > 0) {
1427
1506
  maxSeeTime = Math.max(maxSeeTime, t);
1428
1507
  if (firstSeekTime < 0) {
1429
1508
  firstSeekTime = t;
1430
1509
  }
1431
1510
  }
1511
+ seekApplyLock = true;
1432
1512
  seekTime = 0;
1433
1513
  try {
1434
1514
  video.currentTime = t;
1435
1515
  } catch (event2) {
1436
1516
  seekTime = t;
1517
+ seekApplyLock = false;
1437
1518
  }
1519
+ setTimeout(function() {
1520
+ seekApplyLock = false;
1521
+ }, 800);
1522
+ }, recoverDecodeError = function() {
1523
+ if (decodeRecoverCount >= 2) {
1524
+ return false;
1525
+ }
1526
+ decodeRecoverCount++;
1527
+ var resumeAt = playTime > 0 ? playTime : vars["seek"] ? parseFloat(vars["seek"]) : 0;
1528
+ if (isNaN(resumeAt) || resumeAt < 0) {
1529
+ resumeAt = 0;
1530
+ }
1531
+ try {
1532
+ if (hls && typeof hls.recoverMediaError === "function") {
1533
+ hls.recoverMediaError();
1534
+ if (resumeAt > 0) {
1535
+ seekTime = resumeAt;
1536
+ seekApplyLock = false;
1537
+ setTimeout(function() {
1538
+ applyPendingSeek(true);
1539
+ }, 300);
1540
+ }
1541
+ return true;
1542
+ }
1543
+ } catch (event2) {
1544
+ }
1545
+ try {
1546
+ var soft = Math.max(0, resumeAt - 1.5);
1547
+ seekTime = resumeAt;
1548
+ seekApplyLock = false;
1549
+ if (video) {
1550
+ video.currentTime = soft;
1551
+ }
1552
+ setTimeout(function() {
1553
+ applyPendingSeek(true);
1554
+ if (video && video.paused && vars["autoplay"]) {
1555
+ try {
1556
+ video.play();
1557
+ } catch (e2) {
1558
+ }
1559
+ }
1560
+ }, 400);
1561
+ return true;
1562
+ } catch (event2) {
1563
+ }
1564
+ return false;
1438
1565
  }, loadedMetaData = function() {
1439
1566
  eventTarget("loadedMetaData", {
1440
1567
  width: CK.getWidth(),
@@ -1611,6 +1738,11 @@ var require_ckplayer = __commonJS({
1611
1738
  if (!isUndefined(errorInfo.message)) {
1612
1739
  msg = errorInfo.message;
1613
1740
  }
1741
+ if (code === 3 && recoverDecodeError()) {
1742
+ CT.error = { code, message: msg };
1743
+ eventTarget("error", CT.error);
1744
+ return;
1745
+ }
1614
1746
  CT.error = { code, message: msg };
1615
1747
  showError();
1616
1748
  } else {
@@ -1660,6 +1792,8 @@ var require_ckplayer = __commonJS({
1660
1792
  eventTarget("error", CT.error);
1661
1793
  },
1662
1794
  seeked: function() {
1795
+ seekApplyLock = false;
1796
+ decodeRecoverCount = 0;
1663
1797
  if (paused) {
1664
1798
  player.play();
1665
1799
  }
@@ -2091,8 +2225,8 @@ var require_ckplayer = __commonJS({
2091
2225
  img = createlImg(adv["file"]);
2092
2226
  C["ad"]["picture"].append(img);
2093
2227
  img.addListener("load", function() {
2094
- var w = this.getWidth(), h = this.getHeight();
2095
- if (w > 0 || h > 0) {
2228
+ var w = this.getWidth(), h2 = this.getHeight();
2229
+ if (w > 0 || h2 > 0) {
2096
2230
  if (adv["link"]) {
2097
2231
  var a2 = createlA("", adv["link"]);
2098
2232
  a2.append(this);
@@ -2170,8 +2304,8 @@ var require_ckplayer = __commonJS({
2170
2304
  C["adPause"].htm("");
2171
2305
  C["adPause"].append(img);
2172
2306
  img.addListener("load", function() {
2173
- var w = this.getWidth(), h = this.getHeight();
2174
- if (w > 0 || h > 0) {
2307
+ var w = this.getWidth(), h2 = this.getHeight();
2308
+ if (w > 0 || h2 > 0) {
2175
2309
  C["adPause"].htm("");
2176
2310
  if (adv["link"]) {
2177
2311
  var a2 = createlA("", adv["link"]);
@@ -2182,7 +2316,7 @@ var require_ckplayer = __commonJS({
2182
2316
  }
2183
2317
  C["adPause"].css({
2184
2318
  "width": w + "px",
2185
- "height": h + "px"
2319
+ "height": h2 + "px"
2186
2320
  });
2187
2321
  if (ad["pauseClose"]) {
2188
2322
  C["adPause"].append(ad["pauseClose"]);
@@ -2611,10 +2745,6 @@ var require_ckplayer = __commonJS({
2611
2745
  firstSeekTime = target;
2612
2746
  }
2613
2747
  }
2614
- try {
2615
- video.currentTime = target;
2616
- } catch (event2) {
2617
- }
2618
2748
  return player;
2619
2749
  }
2620
2750
  if (duration && isFinite(duration) && duration > 0 && target > duration) {
@@ -2626,6 +2756,11 @@ var require_ckplayer = __commonJS({
2626
2756
  if (vars["timeScheduleAdjust"] == 5 && target > maxSeeTime && seekTime && Math.abs(seekTime - target) < 0.5) {
2627
2757
  maxSeeTime = Math.max(maxSeeTime, target);
2628
2758
  }
2759
+ if (target > 0.5 && !timeInBuffered(target) && video.readyState < 3) {
2760
+ seekTime = target;
2761
+ applyPendingSeek(false);
2762
+ return player;
2763
+ }
2629
2764
  try {
2630
2765
  video.currentTime = target;
2631
2766
  seekTime = 0;
@@ -3594,11 +3729,11 @@ var require_ckplayer = __commonJS({
3594
3729
  C["about"]["textareaEle"].hide();
3595
3730
  message(language["copySucceeded"], true);
3596
3731
  }, getBarHeight = function() {
3597
- var h = C["bar"].getHeight();
3732
+ var h2 = C["bar"].getHeight();
3598
3733
  if (parseFloat(C["bar"]["pbox"].css("top")) < 0) {
3599
- h -= parseInt(C["bar"]["pbox"].css("top"));
3734
+ h2 -= parseInt(C["bar"]["pbox"].css("top"));
3600
3735
  }
3601
- return h;
3736
+ return h2;
3602
3737
  }, hideBar = function() {
3603
3738
  if (mouseSetTime) {
3604
3739
  clearTimeout(mouseSetTime);
@@ -3661,17 +3796,17 @@ var require_ckplayer = __commonJS({
3661
3796
  if (!isUndefined(vars["playbackrateOpen"]) && vars["playbackrateOpen"]) {
3662
3797
  C["bar"]["playbackrate"].show();
3663
3798
  C["bar"]["playbackrate"]["bgbox"].show();
3664
- var w = C["bar"]["playbackrate"]["bg"].getWidth(), h = C["bar"]["playbackrate"]["bg"].getHeight();
3799
+ var w = C["bar"]["playbackrate"]["bg"].getWidth(), h2 = C["bar"]["playbackrate"]["bg"].getHeight();
3665
3800
  var bw = C["bar"]["playbackrate"]["button"].getWidth();
3666
3801
  C["bar"]["playbackrate"]["bg"].css({ "width": w + 10 + "px" });
3667
3802
  w = C["bar"]["playbackrate"]["bg"].getWidth();
3668
3803
  if (getBarHeight() > C["bar"].getHeight()) {
3669
- h += getBarHeight() - C["bar"].getHeight();
3804
+ h2 += getBarHeight() - C["bar"].getHeight();
3670
3805
  }
3671
3806
  C["bar"]["playbackrate"]["bgbox"].attr("style", "");
3672
3807
  C["bar"]["playbackrate"]["bgbox"].css({
3673
3808
  "width": w + "px",
3674
- "height": h + 2 + "px",
3809
+ "height": h2 + 2 + "px",
3675
3810
  "left": -(w - bw) * 0.5 + "px"
3676
3811
  });
3677
3812
  C["bar"]["playbackrate"]["button"].mouseover(function() {
@@ -3731,17 +3866,17 @@ var require_ckplayer = __commonJS({
3731
3866
  C["bar"]["track"].hide();
3732
3867
  C["bar"]["track"].show();
3733
3868
  C["bar"]["track"]["bgbox"].show();
3734
- var w = C["bar"]["track"]["bg"].getWidth(), h = C["bar"]["track"]["bg"].getHeight();
3869
+ var w = C["bar"]["track"]["bg"].getWidth(), h2 = C["bar"]["track"]["bg"].getHeight();
3735
3870
  var bw = C["bar"]["track"]["button"].getWidth();
3736
3871
  C["bar"]["track"]["bg"].css({ "width": w + 10 + "px" });
3737
3872
  w = C["bar"]["track"]["bg"].getWidth();
3738
3873
  if (getBarHeight() > C["bar"].getHeight()) {
3739
- h += getBarHeight() - C["bar"].getHeight();
3874
+ h2 += getBarHeight() - C["bar"].getHeight();
3740
3875
  }
3741
3876
  C["bar"]["track"]["bgbox"].attr("style", "");
3742
3877
  C["bar"]["track"]["bgbox"].css({
3743
3878
  "width": w + "px",
3744
- "height": h + 2 + "px",
3879
+ "height": h2 + 2 + "px",
3745
3880
  "left": -(w - bw) * 0.5 + "px"
3746
3881
  });
3747
3882
  C["bar"]["track"]["button"].mouseover(function() {
@@ -3801,17 +3936,17 @@ var require_ckplayer = __commonJS({
3801
3936
  }
3802
3937
  C["bar"]["definition"].show();
3803
3938
  C["bar"]["definition"]["bgbox"].show();
3804
- var w = C["bar"]["definition"]["bg"].getWidth(), h = C["bar"]["definition"]["bg"].getHeight();
3939
+ var w = C["bar"]["definition"]["bg"].getWidth(), h2 = C["bar"]["definition"]["bg"].getHeight();
3805
3940
  var bw = C["bar"]["definition"]["button"].getWidth();
3806
3941
  C["bar"]["definition"]["bg"].css({ "width": w + 10 + "px" });
3807
3942
  w = C["bar"]["definition"]["bg"].getWidth();
3808
3943
  if (getBarHeight() > C["bar"].getHeight()) {
3809
- h += getBarHeight() - C["bar"].getHeight();
3944
+ h2 += getBarHeight() - C["bar"].getHeight();
3810
3945
  }
3811
3946
  C["bar"]["definition"]["bgbox"].attr("style", "");
3812
3947
  C["bar"]["definition"]["bgbox"].css({
3813
3948
  "width": w + "px",
3814
- "height": h + 2 + "px",
3949
+ "height": h2 + 2 + "px",
3815
3950
  "left": -(w - bw) * 0.5 + "px"
3816
3951
  });
3817
3952
  C["bar"]["definition"]["button"].mouseover(function() {
@@ -4395,9 +4530,9 @@ var require_ckplayer = __commonJS({
4395
4530
  }, tipResize = function(ele, cl, align) {
4396
4531
  var offset = ele.offset();
4397
4532
  var ckOffset = CK.offset();
4398
- var w = C["tip"].getWidth(), h = C["tip"].getHeight();
4533
+ var w = C["tip"].getWidth(), h2 = C["tip"].getHeight();
4399
4534
  var ew = ele.getWidth();
4400
- var left = 0, top = offset["top"] - ckOffset["top"] - h;
4535
+ var left = 0, top = offset["top"] - ckOffset["top"] - h2;
4401
4536
  if (getBarHeight() > C["bar"].getHeight()) {
4402
4537
  top -= getBarHeight() - C["bar"].getHeight();
4403
4538
  }
@@ -4422,8 +4557,8 @@ var require_ckplayer = __commonJS({
4422
4557
  if (left > CM.getWidth() - w) {
4423
4558
  left = CM.getWidth() - w;
4424
4559
  }
4425
- if (top > CM.getHeight() - h) {
4426
- top = CM.getHeight() - h;
4560
+ if (top > CM.getHeight() - h2) {
4561
+ top = CM.getHeight() - h2;
4427
4562
  }
4428
4563
  C["tip"].css({
4429
4564
  "left": left + "px",
@@ -4721,9 +4856,9 @@ var require_ckplayer = __commonJS({
4721
4856
  e = e || window.event;
4722
4857
  var client = getClient(e);
4723
4858
  var bgOffset = bg.offset();
4724
- var h = client["y"] - bgOffset["top"];
4859
+ var h2 = client["y"] - bgOffset["top"];
4725
4860
  var max = bg.getHeight();
4726
- var vol = 1 - h / max;
4861
+ var vol = 1 - h2 / max;
4727
4862
  player.volume(vol);
4728
4863
  };
4729
4864
  bg.mousedown(bgMouseDown);
@@ -5279,7 +5414,7 @@ var require_ckplayer = __commonJS({
5279
5414
  }
5280
5415
  var thisTemp = this;
5281
5416
  var parNode = this.CK;
5282
- var w = parNode.getWidth(), h = parNode.getHeight();
5417
+ var w = parNode.getWidth(), h2 = parNode.getHeight();
5283
5418
  var speed = 10;
5284
5419
  this.timerTween = null;
5285
5420
  this.tweenPlay = true;
@@ -5480,7 +5615,7 @@ var require_ckplayer = __commonJS({
5480
5615
  case "width":
5481
5616
  current = thisTemp.getWidth();
5482
5617
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5483
- result = parseInt(vars2) * h * 0.01;
5618
+ result = parseInt(vars2) * h2 * 0.01;
5484
5619
  } else {
5485
5620
  result = parseInt(vars2);
5486
5621
  }
@@ -5488,7 +5623,7 @@ var require_ckplayer = __commonJS({
5488
5623
  case "height":
5489
5624
  current = thisTemp.getHeight();
5490
5625
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5491
- result = parseInt(vars2) * h * 0.01;
5626
+ result = parseInt(vars2) * h2 * 0.01;
5492
5627
  } else {
5493
5628
  result = parseInt(vars2);
5494
5629
  }
@@ -5526,7 +5661,7 @@ var require_ckplayer = __commonJS({
5526
5661
  current = thisTemp.offset()["top"] - parNode.offset()["top"];
5527
5662
  }
5528
5663
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5529
- result = parseInt(vars2) * h * 0.01;
5664
+ result = parseInt(vars2) * h2 * 0.01;
5530
5665
  } else {
5531
5666
  result = parseInt(vars2);
5532
5667
  }
@@ -5539,7 +5674,7 @@ var require_ckplayer = __commonJS({
5539
5674
  current = parNode.getHeight() - (thisTemp.offset()["top"] - parNode.offset()["top"] + thisTemp.getHeight());
5540
5675
  }
5541
5676
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5542
- result = parseInt(vars2) * h * 0.01;
5677
+ result = parseInt(vars2) * h2 * 0.01;
5543
5678
  } else {
5544
5679
  result = parseInt(vars2);
5545
5680
  }
@@ -5785,7 +5920,7 @@ var require_ckplayer = __commonJS({
5785
5920
  }
5786
5921
  varsTime += time;
5787
5922
  return language["lookBack"] + date("H:i:s", varsTime);
5788
- }, loadJs = function(file, callback2) {
5923
+ }, loadJs = function(file, callback2, isRetry) {
5789
5924
  var fn2 = function() {
5790
5925
  };
5791
5926
  if (!isUndefined(callback2)) {
@@ -5820,19 +5955,37 @@ var require_ckplayer = __commonJS({
5820
5955
  ;
5821
5956
  }, 10);
5822
5957
  };
5823
- var w3c = function() {
5824
- if (valType(fn2) == "function") {
5825
- fn2();
5958
+ var removeScript = function() {
5959
+ try {
5960
+ if (script.parentNode) {
5961
+ script.parentNode.removeChild(script);
5962
+ }
5963
+ } catch (event2) {
5826
5964
  }
5965
+ };
5966
+ var w3c = function() {
5827
5967
  removeListener(script, "load", w3c);
5828
5968
  removeListener(script, "error", w3cError);
5969
+ doReady();
5829
5970
  };
5830
5971
  var w3cError = function() {
5831
- if (valType(fn2) == "function") {
5832
- fn2();
5833
- }
5834
5972
  removeListener(script, "load", w3c);
5835
5973
  removeListener(script, "error", w3cError);
5974
+ removeScript();
5975
+ if (!isRetry && (!vars || vars["cdnFallback"] !== false)) {
5976
+ var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
5977
+ var m2 = String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
5978
+ if (cdn && cdn.indexOf("1.0.6") === -1 && m2) {
5979
+ if (cdn.slice(-1) !== "/") {
5980
+ cdn += "/";
5981
+ }
5982
+ var retryUrl = cdn + m2[1] + "/" + m2[2];
5983
+ if (retryUrl !== file) {
5984
+ loadJs(retryUrl, callback2, true);
5985
+ return;
5986
+ }
5987
+ }
5988
+ }
5836
5989
  };
5837
5990
  try {
5838
5991
  addListener(script, "load", w3c);
@@ -6058,14 +6211,19 @@ var require_ckplayer = __commonJS({
6058
6211
  }
6059
6212
  function getPath(siz) {
6060
6213
  if (typeof window !== "undefined" && window.ckplayerBasePath) {
6061
- var base = window.ckplayerBasePath;
6062
- if (base.slice(-1) !== "/") {
6063
- base += "/";
6214
+ var base2 = window.ckplayerBasePath;
6215
+ if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2)) {
6216
+ base2 = "";
6064
6217
  }
6065
- if (!isUndefined(siz)) {
6066
- return base + siz + "/";
6218
+ if (base2) {
6219
+ if (base2.slice(-1) !== "/") {
6220
+ base2 += "/";
6221
+ }
6222
+ if (!isUndefined(siz)) {
6223
+ return base2 + siz + "/";
6224
+ }
6225
+ return base2;
6067
6226
  }
6068
- return base;
6069
6227
  }
6070
6228
  var scriptList = document.scripts || [], thisPath = scriptList.length ? scriptList[scriptList.length - 1].src : "";
6071
6229
  for (var i2 = 0; i2 < scriptList.length; i2++) {
@@ -6121,41 +6279,41 @@ var require_ckplayer = __commonJS({
6121
6279
  };
6122
6280
  }
6123
6281
  function standardization(o, n) {
6124
- var h = {};
6282
+ var h2 = {};
6125
6283
  var k;
6126
6284
  for (k in o) {
6127
- h[k] = o[k];
6285
+ h2[k] = o[k];
6128
6286
  }
6129
6287
  for (k in n) {
6130
- if (k in h) {
6131
- h[k] = n[k];
6288
+ if (k in h2) {
6289
+ h2[k] = n[k];
6132
6290
  }
6133
6291
  }
6134
- return h;
6292
+ return h2;
6135
6293
  }
6136
6294
  function mergeObj(o, n) {
6137
- var h = {};
6295
+ var h2 = {};
6138
6296
  var k;
6139
6297
  for (k in o) {
6140
- h[k] = o[k];
6298
+ h2[k] = o[k];
6141
6299
  }
6142
6300
  for (k in n) {
6143
- if (k in h) {
6144
- switch (valType(h[k])) {
6301
+ if (k in h2) {
6302
+ switch (valType(h2[k])) {
6145
6303
  case "object":
6146
6304
  if (valType(n[k]) == "object") {
6147
- h[k] = mergeObj(h[k], n[k]);
6305
+ h2[k] = mergeObj(h2[k], n[k]);
6148
6306
  }
6149
6307
  break;
6150
6308
  default:
6151
- if (valType(h[k]) == valType(n[k])) {
6152
- h[k] = n[k];
6309
+ if (valType(h2[k]) == valType(n[k])) {
6310
+ h2[k] = n[k];
6153
6311
  }
6154
6312
  break;
6155
6313
  }
6156
6314
  }
6157
6315
  }
6158
- return h;
6316
+ return h2;
6159
6317
  }
6160
6318
  function valType(val) {
6161
6319
  if (typeof val === "undefined") return "undefined";
@@ -6269,8 +6427,8 @@ var require_ckplayer = __commonJS({
6269
6427
  var result = parseInt(val);
6270
6428
  if (isUndefined(result)) result = 0;
6271
6429
  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 + ":";
6430
+ 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 = "";
6431
+ if (h2 !== "00") res += h2 + ":";
6274
6432
  res += m2 + ":" + s;
6275
6433
  return res;
6276
6434
  }
@@ -6579,24 +6737,61 @@ __export(index_exports, {
6579
6737
  });
6580
6738
  module.exports = __toCommonJS(index_exports);
6581
6739
 
6740
+ // src/vue/CkPlayer.js
6741
+ var import_vue = require("vue");
6742
+
6582
6743
  // src/index.js
6583
6744
  var import_ckplayer = __toESM(require_ckplayer());
6584
6745
  var import_meta = {};
6585
6746
  try {
6586
6747
  if (typeof window !== "undefined" && !window.ckplayerBasePath) {
6587
- window.ckplayerBasePath = new URL("./", import_meta.url).href;
6748
+ base = new URL("./", import_meta.url).href;
6749
+ if (/\/dist\/$/i.test(base) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(base) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(base)) {
6750
+ window.ckplayerBasePath = base;
6751
+ }
6588
6752
  }
6589
6753
  } catch (e) {
6590
6754
  }
6755
+ var base;
6591
6756
  var index_default = import_ckplayer.default;
6592
6757
 
6593
- // src/vue/CkPlayer.js
6758
+ // src/shared.js
6594
6759
  var EVENT_NAMES = ["play", "pause", "ended", "volume", "muted", "full", "error", "time", "seek", "screenshot"];
6595
6760
  function createUid() {
6596
6761
  return "ckp-" + Math.random().toString(36).slice(2, 10);
6597
6762
  }
6763
+ function buildPlayerConfig(input) {
6764
+ var opts = input.options || {};
6765
+ var config = {
6766
+ container: input.container,
6767
+ video: input.video,
6768
+ poster: input.poster || "",
6769
+ autoplay: !!input.autoplay,
6770
+ live: input.live != null ? input.live : false,
6771
+ plug: input.plug || "",
6772
+ autoPlug: input.autoPlug !== false,
6773
+ volume: input.volume != null ? input.volume : 0.8,
6774
+ cookie: opts.cookie || input.cookie || createUid()
6775
+ };
6776
+ if (input.pluginPath) {
6777
+ config.pluginPath = input.pluginPath;
6778
+ }
6779
+ for (var key in opts) {
6780
+ if (Object.prototype.hasOwnProperty.call(opts, key) && key !== "container") {
6781
+ config[key] = opts[key];
6782
+ }
6783
+ }
6784
+ if (typeof config.loaded === "string") {
6785
+ delete config.loaded;
6786
+ }
6787
+ return config;
6788
+ }
6789
+
6790
+ // src/vue/CkPlayer.js
6791
+ var unmountHook = typeof import_vue.version === "string" && import_vue.version.charAt(0) === "3" ? "beforeUnmount" : "beforeDestroy";
6598
6792
  var CkPlayer = {
6599
6793
  name: "CkPlayer",
6794
+ emits: EVENT_NAMES.concat(["ready"]),
6600
6795
  props: {
6601
6796
  video: { required: true },
6602
6797
  poster: { type: String, default: "" },
@@ -6615,35 +6810,47 @@ var CkPlayer = {
6615
6810
  },
6616
6811
  data: function() {
6617
6812
  return {
6618
- player: null,
6619
- instanceId: createUid(),
6620
- destroyed: false
6813
+ instanceId: createUid()
6621
6814
  };
6622
6815
  },
6816
+ created: function() {
6817
+ this.player = null;
6818
+ this._destroyed = false;
6819
+ },
6623
6820
  mounted: function() {
6624
6821
  this.initPlayer();
6625
6822
  },
6626
- beforeDestroy: function() {
6627
- this.teardown();
6628
- },
6629
- beforeUnmount: function() {
6630
- this.teardown();
6631
- },
6632
6823
  watch: {
6633
- video: function() {
6634
- this.reinit();
6824
+ video: {
6825
+ deep: true,
6826
+ handler: function() {
6827
+ this.reinit();
6828
+ }
6635
6829
  },
6636
6830
  poster: function() {
6637
6831
  this.reinit();
6638
6832
  },
6639
6833
  plug: function() {
6640
6834
  this.reinit();
6835
+ },
6836
+ autoplay: function() {
6837
+ this.reinit();
6838
+ },
6839
+ live: function() {
6840
+ this.reinit();
6841
+ },
6842
+ pluginPath: function() {
6843
+ this.reinit();
6844
+ },
6845
+ volume: function(vol) {
6846
+ if (this.player && typeof this.player.volume === "function" && typeof vol === "number") {
6847
+ this.player.volume(vol);
6848
+ }
6641
6849
  }
6642
6850
  },
6643
6851
  methods: {
6644
6852
  buildConfig: function() {
6645
- var opts = this.options || {};
6646
- var config = {
6853
+ return buildPlayerConfig({
6647
6854
  container: this.$refs.container,
6648
6855
  video: this.video,
6649
6856
  poster: this.poster,
@@ -6652,20 +6859,10 @@ var CkPlayer = {
6652
6859
  plug: this.plug,
6653
6860
  autoPlug: this.autoPlug,
6654
6861
  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;
6862
+ pluginPath: this.pluginPath,
6863
+ options: this.options,
6864
+ cookie: this.instanceId
6865
+ });
6669
6866
  },
6670
6867
  bindEvents: function() {
6671
6868
  var self2 = this;
@@ -6680,14 +6877,13 @@ var CkPlayer = {
6680
6877
  });
6681
6878
  },
6682
6879
  initPlayer: function() {
6683
- if (typeof window === "undefined" || !this.$refs.container) return;
6684
- this.destroyed = false;
6880
+ if (typeof window === "undefined" || this._destroyed || !this.$refs.container) return;
6685
6881
  this.player = new index_default(this.buildConfig());
6686
6882
  this.bindEvents();
6687
6883
  this.$emit("ready", this.player);
6688
6884
  },
6689
6885
  teardown: function() {
6690
- this.destroyed = true;
6886
+ this._destroyed = true;
6691
6887
  if (this.player && typeof this.player.remove === "function") {
6692
6888
  try {
6693
6889
  this.player.remove();
@@ -6699,8 +6895,9 @@ var CkPlayer = {
6699
6895
  reinit: function() {
6700
6896
  var self2 = this;
6701
6897
  this.teardown();
6702
- this.destroyed = false;
6898
+ this._destroyed = false;
6703
6899
  this.$nextTick(function() {
6900
+ if (self2._destroyed) return;
6704
6901
  self2.initPlayer();
6705
6902
  });
6706
6903
  },
@@ -6735,7 +6932,7 @@ var CkPlayer = {
6735
6932
  }
6736
6933
  },
6737
6934
  render: function() {
6738
- return this.$createElement("div", {
6935
+ return (0, import_vue.h)("div", {
6739
6936
  ref: "container",
6740
6937
  class: ["ckplayer-plus", this.className].filter(Boolean).join(" "),
6741
6938
  style: {
@@ -6745,6 +6942,9 @@ var CkPlayer = {
6745
6942
  });
6746
6943
  }
6747
6944
  };
6945
+ CkPlayer[unmountHook] = function() {
6946
+ this.teardown();
6947
+ };
6748
6948
  var CkPlayer_default = CkPlayer;
6749
6949
 
6750
6950
  // src/vue/index.js