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.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.3/dist/";
210
+ var ckplayerPlusDefaultCdn = "https://cdn.jsdelivr.net/npm/ckplayer-plus@1.0.6/dist/";
211
211
  function ckplayerEmbed(videoObj) {
212
212
  var rightMenu = [
213
213
  {
@@ -232,6 +232,11 @@ var require_ckplayer = __commonJS({
232
232
  var paused = true;
233
233
  var loadTime = 0;
234
234
  var seekTime = 0;
235
+ var seekRetryTimer = null;
236
+ var seekRetryCount = 0;
237
+ var seekApplyLock = false;
238
+ var decodeRecoverCount = 0;
239
+ var hlsStartPositionUsed = false;
235
240
  var oldTime = 0, playTime = 0, firstSeekTime = -1, maxSeeTime = 0;
236
241
  var isChangeDef = true;
237
242
  var playType = "";
@@ -370,26 +375,34 @@ var require_ckplayer = __commonJS({
370
375
  } else {
371
376
  return embed(obj2);
372
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);
373
383
  }, resolveAssetPath = function(folder, file) {
374
- var base = "";
384
+ var base2 = "";
375
385
  if (vars && vars["pluginPath"]) {
376
- base = vars["pluginPath"];
386
+ base2 = vars["pluginPath"];
377
387
  } else if (typeof window !== "undefined" && window.ckplayerBasePath) {
378
- base = window.ckplayerBasePath;
388
+ base2 = window.ckplayerBasePath;
379
389
  }
380
- if (base) {
381
- if (base.slice(-1) !== "/") {
382
- base += "/";
390
+ if (base2 && isUnreliablePluginBase(base2)) {
391
+ base2 = "";
392
+ }
393
+ if (base2) {
394
+ if (base2.slice(-1) !== "/") {
395
+ base2 += "/";
383
396
  }
384
- return base + folder + "/" + file;
397
+ return base2 + folder + "/" + file;
385
398
  }
386
399
  var fromScript = getPath(folder) + file;
387
- if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1) {
400
+ if (fromScript && fromScript.indexOf(folder + "/") > -1 && fromScript.indexOf("undefined") === -1 && !isUnreliablePluginBase(getPath())) {
388
401
  return fromScript;
389
402
  }
390
403
  var allowCdn = !vars || vars["cdnFallback"] !== false;
391
404
  var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
392
- if (!allowCdn || !cdn || cdn.indexOf("1.0.3") > -1) {
405
+ if (!allowCdn || !cdn || cdn.indexOf("1.0.6") > -1) {
393
406
  return folder + "/" + file;
394
407
  }
395
408
  if (cdn.slice(-1) !== "/") {
@@ -703,11 +716,24 @@ var require_ckplayer = __commonJS({
703
716
  }, hlsPlayer = function(url) {
704
717
  var startHls = function() {
705
718
  if (typeof Hls !== "undefined" && !isUndefined(Hls) && Hls.isSupported()) {
706
- hls = new Hls();
719
+ var hlsConf = {};
720
+ if (seekTime && seekTime > 0 && (isUndefined(vars["live"]) || !vars["live"])) {
721
+ hlsConf.startPosition = seekTime;
722
+ maxSeeTime = Math.max(maxSeeTime, seekTime);
723
+ if (firstSeekTime < 0) {
724
+ firstSeekTime = seekTime;
725
+ }
726
+ seekTime = 0;
727
+ hlsStartPositionUsed = true;
728
+ clearSeekRetry();
729
+ }
730
+ hls = new Hls(hlsConf);
707
731
  hls.loadSource(url);
708
732
  hls.attachMedia(video);
709
733
  hls.on(Hls.Events.MANIFEST_PARSED, function() {
710
- applyPendingSeek();
734
+ if (!hlsStartPositionUsed) {
735
+ applyPendingSeek();
736
+ }
711
737
  });
712
738
  hls.on(Hls.Events.ERROR, function(event2, data) {
713
739
  var code = 9;
@@ -725,6 +751,13 @@ var require_ckplayer = __commonJS({
725
751
  }
726
752
  }
727
753
  }
754
+ if (fatal && data.type === Hls.ErrorTypes.MEDIA_ERROR && hls && typeof hls.recoverMediaError === "function") {
755
+ try {
756
+ hls.recoverMediaError();
757
+ fatal = false;
758
+ } catch (errRecover) {
759
+ }
760
+ }
728
761
  CT.error = { code, message: message2 };
729
762
  eventTarget("error", CT.error);
730
763
  if (fatal) {
@@ -1406,8 +1439,28 @@ var require_ckplayer = __commonJS({
1406
1439
  checkTrack();
1407
1440
  }
1408
1441
  }
1409
- }, applyPendingSeek = function() {
1410
- if (!seekTime || !video) {
1442
+ }, timeInBuffered = function(t) {
1443
+ if (!video || isUndefined(video.buffered)) {
1444
+ return false;
1445
+ }
1446
+ try {
1447
+ var buf = video.buffered;
1448
+ for (var i2 = 0; i2 < buf.length; i2++) {
1449
+ if (t >= buf.start(i2) - 0.35 && t <= buf.end(i2) + 0.15) {
1450
+ return true;
1451
+ }
1452
+ }
1453
+ } catch (event2) {
1454
+ }
1455
+ return false;
1456
+ }, clearSeekRetry = function() {
1457
+ if (seekRetryTimer) {
1458
+ clearTimeout(seekRetryTimer);
1459
+ seekRetryTimer = null;
1460
+ }
1461
+ seekRetryCount = 0;
1462
+ }, applyPendingSeek = function(force) {
1463
+ if (!seekTime || !video || seekApplyLock) {
1411
1464
  return;
1412
1465
  }
1413
1466
  if (!isUndefined(vars["live"]) && (valType(vars["live"]) == "boolean" && vars["live"] || valType(vars["live"]) == "number")) {
@@ -1418,18 +1471,92 @@ var require_ckplayer = __commonJS({
1418
1471
  if (dur && isFinite(dur) && dur > 0 && t >= dur) {
1419
1472
  t = Math.max(0, dur - 0.3);
1420
1473
  }
1474
+ if (t <= 0) {
1475
+ seekTime = 0;
1476
+ clearSeekRetry();
1477
+ return;
1478
+ }
1479
+ var readyEnough = !isUndefined(video.readyState) && video.readyState >= 2;
1480
+ var bufferedOk = timeInBuffered(t);
1481
+ if (!force && !bufferedOk && (!readyEnough || video.readyState < 3)) {
1482
+ seekRetryCount++;
1483
+ if (seekRetryCount <= 50) {
1484
+ try {
1485
+ if (hls && typeof hls.startLoad === "function") {
1486
+ hls.startLoad(t);
1487
+ }
1488
+ } catch (event2) {
1489
+ }
1490
+ if (seekRetryTimer) {
1491
+ clearTimeout(seekRetryTimer);
1492
+ }
1493
+ seekRetryTimer = setTimeout(function() {
1494
+ applyPendingSeek(false);
1495
+ }, 200);
1496
+ return;
1497
+ }
1498
+ }
1499
+ clearSeekRetry();
1421
1500
  if (t > 0) {
1422
1501
  maxSeeTime = Math.max(maxSeeTime, t);
1423
1502
  if (firstSeekTime < 0) {
1424
1503
  firstSeekTime = t;
1425
1504
  }
1426
1505
  }
1506
+ seekApplyLock = true;
1427
1507
  seekTime = 0;
1428
1508
  try {
1429
1509
  video.currentTime = t;
1430
1510
  } catch (event2) {
1431
1511
  seekTime = t;
1512
+ seekApplyLock = false;
1432
1513
  }
1514
+ setTimeout(function() {
1515
+ seekApplyLock = false;
1516
+ }, 800);
1517
+ }, recoverDecodeError = function() {
1518
+ if (decodeRecoverCount >= 2) {
1519
+ return false;
1520
+ }
1521
+ decodeRecoverCount++;
1522
+ var resumeAt = playTime > 0 ? playTime : vars["seek"] ? parseFloat(vars["seek"]) : 0;
1523
+ if (isNaN(resumeAt) || resumeAt < 0) {
1524
+ resumeAt = 0;
1525
+ }
1526
+ try {
1527
+ if (hls && typeof hls.recoverMediaError === "function") {
1528
+ hls.recoverMediaError();
1529
+ if (resumeAt > 0) {
1530
+ seekTime = resumeAt;
1531
+ seekApplyLock = false;
1532
+ setTimeout(function() {
1533
+ applyPendingSeek(true);
1534
+ }, 300);
1535
+ }
1536
+ return true;
1537
+ }
1538
+ } catch (event2) {
1539
+ }
1540
+ try {
1541
+ var soft = Math.max(0, resumeAt - 1.5);
1542
+ seekTime = resumeAt;
1543
+ seekApplyLock = false;
1544
+ if (video) {
1545
+ video.currentTime = soft;
1546
+ }
1547
+ setTimeout(function() {
1548
+ applyPendingSeek(true);
1549
+ if (video && video.paused && vars["autoplay"]) {
1550
+ try {
1551
+ video.play();
1552
+ } catch (e2) {
1553
+ }
1554
+ }
1555
+ }, 400);
1556
+ return true;
1557
+ } catch (event2) {
1558
+ }
1559
+ return false;
1433
1560
  }, loadedMetaData = function() {
1434
1561
  eventTarget("loadedMetaData", {
1435
1562
  width: CK.getWidth(),
@@ -1606,6 +1733,11 @@ var require_ckplayer = __commonJS({
1606
1733
  if (!isUndefined(errorInfo.message)) {
1607
1734
  msg = errorInfo.message;
1608
1735
  }
1736
+ if (code === 3 && recoverDecodeError()) {
1737
+ CT.error = { code, message: msg };
1738
+ eventTarget("error", CT.error);
1739
+ return;
1740
+ }
1609
1741
  CT.error = { code, message: msg };
1610
1742
  showError();
1611
1743
  } else {
@@ -1655,6 +1787,8 @@ var require_ckplayer = __commonJS({
1655
1787
  eventTarget("error", CT.error);
1656
1788
  },
1657
1789
  seeked: function() {
1790
+ seekApplyLock = false;
1791
+ decodeRecoverCount = 0;
1658
1792
  if (paused) {
1659
1793
  player.play();
1660
1794
  }
@@ -2086,8 +2220,8 @@ var require_ckplayer = __commonJS({
2086
2220
  img = createlImg(adv["file"]);
2087
2221
  C["ad"]["picture"].append(img);
2088
2222
  img.addListener("load", function() {
2089
- var w = this.getWidth(), h = this.getHeight();
2090
- if (w > 0 || h > 0) {
2223
+ var w = this.getWidth(), h2 = this.getHeight();
2224
+ if (w > 0 || h2 > 0) {
2091
2225
  if (adv["link"]) {
2092
2226
  var a2 = createlA("", adv["link"]);
2093
2227
  a2.append(this);
@@ -2165,8 +2299,8 @@ var require_ckplayer = __commonJS({
2165
2299
  C["adPause"].htm("");
2166
2300
  C["adPause"].append(img);
2167
2301
  img.addListener("load", function() {
2168
- var w = this.getWidth(), h = this.getHeight();
2169
- if (w > 0 || h > 0) {
2302
+ var w = this.getWidth(), h2 = this.getHeight();
2303
+ if (w > 0 || h2 > 0) {
2170
2304
  C["adPause"].htm("");
2171
2305
  if (adv["link"]) {
2172
2306
  var a2 = createlA("", adv["link"]);
@@ -2177,7 +2311,7 @@ var require_ckplayer = __commonJS({
2177
2311
  }
2178
2312
  C["adPause"].css({
2179
2313
  "width": w + "px",
2180
- "height": h + "px"
2314
+ "height": h2 + "px"
2181
2315
  });
2182
2316
  if (ad["pauseClose"]) {
2183
2317
  C["adPause"].append(ad["pauseClose"]);
@@ -2606,10 +2740,6 @@ var require_ckplayer = __commonJS({
2606
2740
  firstSeekTime = target;
2607
2741
  }
2608
2742
  }
2609
- try {
2610
- video.currentTime = target;
2611
- } catch (event2) {
2612
- }
2613
2743
  return player;
2614
2744
  }
2615
2745
  if (duration && isFinite(duration) && duration > 0 && target > duration) {
@@ -2621,6 +2751,11 @@ var require_ckplayer = __commonJS({
2621
2751
  if (vars["timeScheduleAdjust"] == 5 && target > maxSeeTime && seekTime && Math.abs(seekTime - target) < 0.5) {
2622
2752
  maxSeeTime = Math.max(maxSeeTime, target);
2623
2753
  }
2754
+ if (target > 0.5 && !timeInBuffered(target) && video.readyState < 3) {
2755
+ seekTime = target;
2756
+ applyPendingSeek(false);
2757
+ return player;
2758
+ }
2624
2759
  try {
2625
2760
  video.currentTime = target;
2626
2761
  seekTime = 0;
@@ -3589,11 +3724,11 @@ var require_ckplayer = __commonJS({
3589
3724
  C["about"]["textareaEle"].hide();
3590
3725
  message(language["copySucceeded"], true);
3591
3726
  }, getBarHeight = function() {
3592
- var h = C["bar"].getHeight();
3727
+ var h2 = C["bar"].getHeight();
3593
3728
  if (parseFloat(C["bar"]["pbox"].css("top")) < 0) {
3594
- h -= parseInt(C["bar"]["pbox"].css("top"));
3729
+ h2 -= parseInt(C["bar"]["pbox"].css("top"));
3595
3730
  }
3596
- return h;
3731
+ return h2;
3597
3732
  }, hideBar = function() {
3598
3733
  if (mouseSetTime) {
3599
3734
  clearTimeout(mouseSetTime);
@@ -3656,17 +3791,17 @@ var require_ckplayer = __commonJS({
3656
3791
  if (!isUndefined(vars["playbackrateOpen"]) && vars["playbackrateOpen"]) {
3657
3792
  C["bar"]["playbackrate"].show();
3658
3793
  C["bar"]["playbackrate"]["bgbox"].show();
3659
- var w = C["bar"]["playbackrate"]["bg"].getWidth(), h = C["bar"]["playbackrate"]["bg"].getHeight();
3794
+ var w = C["bar"]["playbackrate"]["bg"].getWidth(), h2 = C["bar"]["playbackrate"]["bg"].getHeight();
3660
3795
  var bw = C["bar"]["playbackrate"]["button"].getWidth();
3661
3796
  C["bar"]["playbackrate"]["bg"].css({ "width": w + 10 + "px" });
3662
3797
  w = C["bar"]["playbackrate"]["bg"].getWidth();
3663
3798
  if (getBarHeight() > C["bar"].getHeight()) {
3664
- h += getBarHeight() - C["bar"].getHeight();
3799
+ h2 += getBarHeight() - C["bar"].getHeight();
3665
3800
  }
3666
3801
  C["bar"]["playbackrate"]["bgbox"].attr("style", "");
3667
3802
  C["bar"]["playbackrate"]["bgbox"].css({
3668
3803
  "width": w + "px",
3669
- "height": h + 2 + "px",
3804
+ "height": h2 + 2 + "px",
3670
3805
  "left": -(w - bw) * 0.5 + "px"
3671
3806
  });
3672
3807
  C["bar"]["playbackrate"]["button"].mouseover(function() {
@@ -3726,17 +3861,17 @@ var require_ckplayer = __commonJS({
3726
3861
  C["bar"]["track"].hide();
3727
3862
  C["bar"]["track"].show();
3728
3863
  C["bar"]["track"]["bgbox"].show();
3729
- var w = C["bar"]["track"]["bg"].getWidth(), h = C["bar"]["track"]["bg"].getHeight();
3864
+ var w = C["bar"]["track"]["bg"].getWidth(), h2 = C["bar"]["track"]["bg"].getHeight();
3730
3865
  var bw = C["bar"]["track"]["button"].getWidth();
3731
3866
  C["bar"]["track"]["bg"].css({ "width": w + 10 + "px" });
3732
3867
  w = C["bar"]["track"]["bg"].getWidth();
3733
3868
  if (getBarHeight() > C["bar"].getHeight()) {
3734
- h += getBarHeight() - C["bar"].getHeight();
3869
+ h2 += getBarHeight() - C["bar"].getHeight();
3735
3870
  }
3736
3871
  C["bar"]["track"]["bgbox"].attr("style", "");
3737
3872
  C["bar"]["track"]["bgbox"].css({
3738
3873
  "width": w + "px",
3739
- "height": h + 2 + "px",
3874
+ "height": h2 + 2 + "px",
3740
3875
  "left": -(w - bw) * 0.5 + "px"
3741
3876
  });
3742
3877
  C["bar"]["track"]["button"].mouseover(function() {
@@ -3796,17 +3931,17 @@ var require_ckplayer = __commonJS({
3796
3931
  }
3797
3932
  C["bar"]["definition"].show();
3798
3933
  C["bar"]["definition"]["bgbox"].show();
3799
- var w = C["bar"]["definition"]["bg"].getWidth(), h = C["bar"]["definition"]["bg"].getHeight();
3934
+ var w = C["bar"]["definition"]["bg"].getWidth(), h2 = C["bar"]["definition"]["bg"].getHeight();
3800
3935
  var bw = C["bar"]["definition"]["button"].getWidth();
3801
3936
  C["bar"]["definition"]["bg"].css({ "width": w + 10 + "px" });
3802
3937
  w = C["bar"]["definition"]["bg"].getWidth();
3803
3938
  if (getBarHeight() > C["bar"].getHeight()) {
3804
- h += getBarHeight() - C["bar"].getHeight();
3939
+ h2 += getBarHeight() - C["bar"].getHeight();
3805
3940
  }
3806
3941
  C["bar"]["definition"]["bgbox"].attr("style", "");
3807
3942
  C["bar"]["definition"]["bgbox"].css({
3808
3943
  "width": w + "px",
3809
- "height": h + 2 + "px",
3944
+ "height": h2 + 2 + "px",
3810
3945
  "left": -(w - bw) * 0.5 + "px"
3811
3946
  });
3812
3947
  C["bar"]["definition"]["button"].mouseover(function() {
@@ -4390,9 +4525,9 @@ var require_ckplayer = __commonJS({
4390
4525
  }, tipResize = function(ele, cl, align) {
4391
4526
  var offset = ele.offset();
4392
4527
  var ckOffset = CK.offset();
4393
- var w = C["tip"].getWidth(), h = C["tip"].getHeight();
4528
+ var w = C["tip"].getWidth(), h2 = C["tip"].getHeight();
4394
4529
  var ew = ele.getWidth();
4395
- var left = 0, top = offset["top"] - ckOffset["top"] - h;
4530
+ var left = 0, top = offset["top"] - ckOffset["top"] - h2;
4396
4531
  if (getBarHeight() > C["bar"].getHeight()) {
4397
4532
  top -= getBarHeight() - C["bar"].getHeight();
4398
4533
  }
@@ -4417,8 +4552,8 @@ var require_ckplayer = __commonJS({
4417
4552
  if (left > CM.getWidth() - w) {
4418
4553
  left = CM.getWidth() - w;
4419
4554
  }
4420
- if (top > CM.getHeight() - h) {
4421
- top = CM.getHeight() - h;
4555
+ if (top > CM.getHeight() - h2) {
4556
+ top = CM.getHeight() - h2;
4422
4557
  }
4423
4558
  C["tip"].css({
4424
4559
  "left": left + "px",
@@ -4716,9 +4851,9 @@ var require_ckplayer = __commonJS({
4716
4851
  e = e || window.event;
4717
4852
  var client = getClient(e);
4718
4853
  var bgOffset = bg.offset();
4719
- var h = client["y"] - bgOffset["top"];
4854
+ var h2 = client["y"] - bgOffset["top"];
4720
4855
  var max = bg.getHeight();
4721
- var vol = 1 - h / max;
4856
+ var vol = 1 - h2 / max;
4722
4857
  player.volume(vol);
4723
4858
  };
4724
4859
  bg.mousedown(bgMouseDown);
@@ -5274,7 +5409,7 @@ var require_ckplayer = __commonJS({
5274
5409
  }
5275
5410
  var thisTemp = this;
5276
5411
  var parNode = this.CK;
5277
- var w = parNode.getWidth(), h = parNode.getHeight();
5412
+ var w = parNode.getWidth(), h2 = parNode.getHeight();
5278
5413
  var speed = 10;
5279
5414
  this.timerTween = null;
5280
5415
  this.tweenPlay = true;
@@ -5475,7 +5610,7 @@ var require_ckplayer = __commonJS({
5475
5610
  case "width":
5476
5611
  current = thisTemp.getWidth();
5477
5612
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5478
- result = parseInt(vars2) * h * 0.01;
5613
+ result = parseInt(vars2) * h2 * 0.01;
5479
5614
  } else {
5480
5615
  result = parseInt(vars2);
5481
5616
  }
@@ -5483,7 +5618,7 @@ var require_ckplayer = __commonJS({
5483
5618
  case "height":
5484
5619
  current = thisTemp.getHeight();
5485
5620
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5486
- result = parseInt(vars2) * h * 0.01;
5621
+ result = parseInt(vars2) * h2 * 0.01;
5487
5622
  } else {
5488
5623
  result = parseInt(vars2);
5489
5624
  }
@@ -5521,7 +5656,7 @@ var require_ckplayer = __commonJS({
5521
5656
  current = thisTemp.offset()["top"] - parNode.offset()["top"];
5522
5657
  }
5523
5658
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5524
- result = parseInt(vars2) * h * 0.01;
5659
+ result = parseInt(vars2) * h2 * 0.01;
5525
5660
  } else {
5526
5661
  result = parseInt(vars2);
5527
5662
  }
@@ -5534,7 +5669,7 @@ var require_ckplayer = __commonJS({
5534
5669
  current = parNode.getHeight() - (thisTemp.offset()["top"] - parNode.offset()["top"] + thisTemp.getHeight());
5535
5670
  }
5536
5671
  if (vars2.substring(vars2.length - 1, vars2.length) == "%") {
5537
- result = parseInt(vars2) * h * 0.01;
5672
+ result = parseInt(vars2) * h2 * 0.01;
5538
5673
  } else {
5539
5674
  result = parseInt(vars2);
5540
5675
  }
@@ -5780,7 +5915,7 @@ var require_ckplayer = __commonJS({
5780
5915
  }
5781
5916
  varsTime += time;
5782
5917
  return language["lookBack"] + date("H:i:s", varsTime);
5783
- }, loadJs = function(file, callback2) {
5918
+ }, loadJs = function(file, callback2, isRetry) {
5784
5919
  var fn2 = function() {
5785
5920
  };
5786
5921
  if (!isUndefined(callback2)) {
@@ -5815,19 +5950,37 @@ var require_ckplayer = __commonJS({
5815
5950
  ;
5816
5951
  }, 10);
5817
5952
  };
5818
- var w3c = function() {
5819
- if (valType(fn2) == "function") {
5820
- fn2();
5953
+ var removeScript = function() {
5954
+ try {
5955
+ if (script.parentNode) {
5956
+ script.parentNode.removeChild(script);
5957
+ }
5958
+ } catch (event2) {
5821
5959
  }
5960
+ };
5961
+ var w3c = function() {
5822
5962
  removeListener(script, "load", w3c);
5823
5963
  removeListener(script, "error", w3cError);
5964
+ doReady();
5824
5965
  };
5825
5966
  var w3cError = function() {
5826
- if (valType(fn2) == "function") {
5827
- fn2();
5828
- }
5829
5967
  removeListener(script, "load", w3c);
5830
5968
  removeListener(script, "error", w3cError);
5969
+ removeScript();
5970
+ if (!isRetry && (!vars || vars["cdnFallback"] !== false)) {
5971
+ var cdn = typeof window !== "undefined" && window.ckplayerPlusCdn ? window.ckplayerPlusCdn : ckplayerPlusDefaultCdn;
5972
+ var m2 = String(file).match(/\/(hls\.js|flv\.js|mpegts\.js|language)\/([^/?#]+)(?:[?#].*)?$/i);
5973
+ if (cdn && cdn.indexOf("1.0.6") === -1 && m2) {
5974
+ if (cdn.slice(-1) !== "/") {
5975
+ cdn += "/";
5976
+ }
5977
+ var retryUrl = cdn + m2[1] + "/" + m2[2];
5978
+ if (retryUrl !== file) {
5979
+ loadJs(retryUrl, callback2, true);
5980
+ return;
5981
+ }
5982
+ }
5983
+ }
5831
5984
  };
5832
5985
  try {
5833
5986
  addListener(script, "load", w3c);
@@ -6053,14 +6206,19 @@ var require_ckplayer = __commonJS({
6053
6206
  }
6054
6207
  function getPath(siz) {
6055
6208
  if (typeof window !== "undefined" && window.ckplayerBasePath) {
6056
- var base = window.ckplayerBasePath;
6057
- if (base.slice(-1) !== "/") {
6058
- base += "/";
6209
+ var base2 = window.ckplayerBasePath;
6210
+ if (/\/(?:assets|\.vite\/deps|_next\/static|chunks?)\/?$/i.test(base2)) {
6211
+ base2 = "";
6059
6212
  }
6060
- if (!isUndefined(siz)) {
6061
- return base + siz + "/";
6213
+ if (base2) {
6214
+ if (base2.slice(-1) !== "/") {
6215
+ base2 += "/";
6216
+ }
6217
+ if (!isUndefined(siz)) {
6218
+ return base2 + siz + "/";
6219
+ }
6220
+ return base2;
6062
6221
  }
6063
- return base;
6064
6222
  }
6065
6223
  var scriptList = document.scripts || [], thisPath = scriptList.length ? scriptList[scriptList.length - 1].src : "";
6066
6224
  for (var i2 = 0; i2 < scriptList.length; i2++) {
@@ -6116,41 +6274,41 @@ var require_ckplayer = __commonJS({
6116
6274
  };
6117
6275
  }
6118
6276
  function standardization(o, n) {
6119
- var h = {};
6277
+ var h2 = {};
6120
6278
  var k;
6121
6279
  for (k in o) {
6122
- h[k] = o[k];
6280
+ h2[k] = o[k];
6123
6281
  }
6124
6282
  for (k in n) {
6125
- if (k in h) {
6126
- h[k] = n[k];
6283
+ if (k in h2) {
6284
+ h2[k] = n[k];
6127
6285
  }
6128
6286
  }
6129
- return h;
6287
+ return h2;
6130
6288
  }
6131
6289
  function mergeObj(o, n) {
6132
- var h = {};
6290
+ var h2 = {};
6133
6291
  var k;
6134
6292
  for (k in o) {
6135
- h[k] = o[k];
6293
+ h2[k] = o[k];
6136
6294
  }
6137
6295
  for (k in n) {
6138
- if (k in h) {
6139
- switch (valType(h[k])) {
6296
+ if (k in h2) {
6297
+ switch (valType(h2[k])) {
6140
6298
  case "object":
6141
6299
  if (valType(n[k]) == "object") {
6142
- h[k] = mergeObj(h[k], n[k]);
6300
+ h2[k] = mergeObj(h2[k], n[k]);
6143
6301
  }
6144
6302
  break;
6145
6303
  default:
6146
- if (valType(h[k]) == valType(n[k])) {
6147
- h[k] = n[k];
6304
+ if (valType(h2[k]) == valType(n[k])) {
6305
+ h2[k] = n[k];
6148
6306
  }
6149
6307
  break;
6150
6308
  }
6151
6309
  }
6152
6310
  }
6153
- return h;
6311
+ return h2;
6154
6312
  }
6155
6313
  function valType(val) {
6156
6314
  if (typeof val === "undefined") return "undefined";
@@ -6264,8 +6422,8 @@ var require_ckplayer = __commonJS({
6264
6422
  var result = parseInt(val);
6265
6423
  if (isUndefined(result)) result = 0;
6266
6424
  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 + ":";
6425
+ 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 = "";
6426
+ if (h2 !== "00") res += h2 + ":";
6269
6427
  res += m2 + ":" + s;
6270
6428
  return res;
6271
6429
  }
@@ -6566,24 +6724,61 @@ var require_ckplayer = __commonJS({
6566
6724
  }
6567
6725
  });
6568
6726
 
6727
+ // src/vue/CkPlayer.js
6728
+ import { h, version as vueVersion } from "vue";
6729
+
6569
6730
  // src/index.js
6570
6731
  var import_ckplayer = __toESM(require_ckplayer());
6571
6732
  var import_meta = {};
6572
6733
  try {
6573
6734
  if (typeof window !== "undefined" && !window.ckplayerBasePath) {
6574
- window.ckplayerBasePath = new URL("./", import_meta.url).href;
6735
+ base = new URL("./", import_meta.url).href;
6736
+ if (/\/dist\/$/i.test(base) || /\/ckplayer-plus(?:@[^/]+)?\/(?:dist\/)?$/i.test(base) || /\/node_modules\/ckplayer-plus\/(?:dist\/)?$/i.test(base)) {
6737
+ window.ckplayerBasePath = base;
6738
+ }
6575
6739
  }
6576
6740
  } catch (e) {
6577
6741
  }
6742
+ var base;
6578
6743
  var index_default = import_ckplayer.default;
6579
6744
 
6580
- // src/vue/CkPlayer.js
6745
+ // src/shared.js
6581
6746
  var EVENT_NAMES = ["play", "pause", "ended", "volume", "muted", "full", "error", "time", "seek", "screenshot"];
6582
6747
  function createUid() {
6583
6748
  return "ckp-" + Math.random().toString(36).slice(2, 10);
6584
6749
  }
6750
+ function buildPlayerConfig(input) {
6751
+ var opts = input.options || {};
6752
+ var config = {
6753
+ container: input.container,
6754
+ video: input.video,
6755
+ poster: input.poster || "",
6756
+ autoplay: !!input.autoplay,
6757
+ live: input.live != null ? input.live : false,
6758
+ plug: input.plug || "",
6759
+ autoPlug: input.autoPlug !== false,
6760
+ volume: input.volume != null ? input.volume : 0.8,
6761
+ cookie: opts.cookie || input.cookie || createUid()
6762
+ };
6763
+ if (input.pluginPath) {
6764
+ config.pluginPath = input.pluginPath;
6765
+ }
6766
+ for (var key in opts) {
6767
+ if (Object.prototype.hasOwnProperty.call(opts, key) && key !== "container") {
6768
+ config[key] = opts[key];
6769
+ }
6770
+ }
6771
+ if (typeof config.loaded === "string") {
6772
+ delete config.loaded;
6773
+ }
6774
+ return config;
6775
+ }
6776
+
6777
+ // src/vue/CkPlayer.js
6778
+ var unmountHook = typeof vueVersion === "string" && vueVersion.charAt(0) === "3" ? "beforeUnmount" : "beforeDestroy";
6585
6779
  var CkPlayer = {
6586
6780
  name: "CkPlayer",
6781
+ emits: EVENT_NAMES.concat(["ready"]),
6587
6782
  props: {
6588
6783
  video: { required: true },
6589
6784
  poster: { type: String, default: "" },
@@ -6602,35 +6797,47 @@ var CkPlayer = {
6602
6797
  },
6603
6798
  data: function() {
6604
6799
  return {
6605
- player: null,
6606
- instanceId: createUid(),
6607
- destroyed: false
6800
+ instanceId: createUid()
6608
6801
  };
6609
6802
  },
6803
+ created: function() {
6804
+ this.player = null;
6805
+ this._destroyed = false;
6806
+ },
6610
6807
  mounted: function() {
6611
6808
  this.initPlayer();
6612
6809
  },
6613
- beforeDestroy: function() {
6614
- this.teardown();
6615
- },
6616
- beforeUnmount: function() {
6617
- this.teardown();
6618
- },
6619
6810
  watch: {
6620
- video: function() {
6621
- this.reinit();
6811
+ video: {
6812
+ deep: true,
6813
+ handler: function() {
6814
+ this.reinit();
6815
+ }
6622
6816
  },
6623
6817
  poster: function() {
6624
6818
  this.reinit();
6625
6819
  },
6626
6820
  plug: function() {
6627
6821
  this.reinit();
6822
+ },
6823
+ autoplay: function() {
6824
+ this.reinit();
6825
+ },
6826
+ live: function() {
6827
+ this.reinit();
6828
+ },
6829
+ pluginPath: function() {
6830
+ this.reinit();
6831
+ },
6832
+ volume: function(vol) {
6833
+ if (this.player && typeof this.player.volume === "function" && typeof vol === "number") {
6834
+ this.player.volume(vol);
6835
+ }
6628
6836
  }
6629
6837
  },
6630
6838
  methods: {
6631
6839
  buildConfig: function() {
6632
- var opts = this.options || {};
6633
- var config = {
6840
+ return buildPlayerConfig({
6634
6841
  container: this.$refs.container,
6635
6842
  video: this.video,
6636
6843
  poster: this.poster,
@@ -6639,20 +6846,10 @@ var CkPlayer = {
6639
6846
  plug: this.plug,
6640
6847
  autoPlug: this.autoPlug,
6641
6848
  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;
6849
+ pluginPath: this.pluginPath,
6850
+ options: this.options,
6851
+ cookie: this.instanceId
6852
+ });
6656
6853
  },
6657
6854
  bindEvents: function() {
6658
6855
  var self2 = this;
@@ -6667,14 +6864,13 @@ var CkPlayer = {
6667
6864
  });
6668
6865
  },
6669
6866
  initPlayer: function() {
6670
- if (typeof window === "undefined" || !this.$refs.container) return;
6671
- this.destroyed = false;
6867
+ if (typeof window === "undefined" || this._destroyed || !this.$refs.container) return;
6672
6868
  this.player = new index_default(this.buildConfig());
6673
6869
  this.bindEvents();
6674
6870
  this.$emit("ready", this.player);
6675
6871
  },
6676
6872
  teardown: function() {
6677
- this.destroyed = true;
6873
+ this._destroyed = true;
6678
6874
  if (this.player && typeof this.player.remove === "function") {
6679
6875
  try {
6680
6876
  this.player.remove();
@@ -6686,8 +6882,9 @@ var CkPlayer = {
6686
6882
  reinit: function() {
6687
6883
  var self2 = this;
6688
6884
  this.teardown();
6689
- this.destroyed = false;
6885
+ this._destroyed = false;
6690
6886
  this.$nextTick(function() {
6887
+ if (self2._destroyed) return;
6691
6888
  self2.initPlayer();
6692
6889
  });
6693
6890
  },
@@ -6722,7 +6919,7 @@ var CkPlayer = {
6722
6919
  }
6723
6920
  },
6724
6921
  render: function() {
6725
- return this.$createElement("div", {
6922
+ return h("div", {
6726
6923
  ref: "container",
6727
6924
  class: ["ckplayer-plus", this.className].filter(Boolean).join(" "),
6728
6925
  style: {
@@ -6732,6 +6929,9 @@ var CkPlayer = {
6732
6929
  });
6733
6930
  }
6734
6931
  };
6932
+ CkPlayer[unmountHook] = function() {
6933
+ this.teardown();
6934
+ };
6735
6935
  var CkPlayer_default = CkPlayer;
6736
6936
 
6737
6937
  // src/vue/index.js