ranui 0.1.8 → 0.1.10-alpha.1

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.
Files changed (176) hide show
  1. package/dist/_commonjs-dynamic-modules-DLbDWi6a.js +12 -0
  2. package/dist/arrow-down-C9jBUUt3.js +30 -0
  3. package/dist/assets/image/failImage.d.ts +2 -0
  4. package/dist/button.js +7 -0
  5. package/dist/checkbox.js +7 -0
  6. package/dist/colorpicker.js +13 -0
  7. package/dist/{colz-746223ab.js → colz-CRDozfZA.js} +1 -5
  8. package/dist/components/button/index.d.ts +38 -1
  9. package/dist/components/checkbox/index.d.ts +27 -0
  10. package/dist/components/colorpicker/index.d.ts +122 -0
  11. package/dist/components/content/index.d.ts +15 -0
  12. package/dist/components/input/index.d.ts +208 -1
  13. package/dist/components/message/index.d.ts +2 -0
  14. package/dist/components/option/index.d.ts +2 -1
  15. package/dist/components/player/index.d.ts +207 -493
  16. package/dist/components/popover/index.d.ts +39 -0
  17. package/dist/components/preview/docx.d.ts +1 -1
  18. package/dist/components/preview/index.d.ts +2 -0
  19. package/dist/components/preview/pptx/process_pptx.d.ts +1 -1
  20. package/dist/components/progress/index.d.ts +11 -5
  21. package/dist/components/radar/index.d.ts +1 -1
  22. package/dist/components/scratch/index.d.ts +23 -0
  23. package/dist/components/select/index.d.ts +18 -6
  24. package/dist/components/tab/index.d.ts +5 -0
  25. package/dist/components/tabpane/index.d.ts +5 -0
  26. package/dist/content.js +6 -0
  27. package/dist/docx-ajDUtnbM.js +3665 -0
  28. package/dist/global-DOfcrQ2N.js +4 -0
  29. package/dist/icon.js +6 -0
  30. package/dist/iconShadowless.js +6 -0
  31. package/dist/image.js +4 -0
  32. package/dist/index-0fvHQjmN.js +298 -0
  33. package/dist/{index-f6d6982d.js → index-BLepXisd.js} +101 -84
  34. package/dist/{index-b2be6bef.js → index-BOoNI-Al.js} +904 -1078
  35. package/dist/index-BPBRPxND.js +195 -0
  36. package/dist/{index-b90299ca.js → index-BpOERe9M.js} +1 -1
  37. package/dist/index-Bv6Z6rIe.js +498 -0
  38. package/dist/index-ByJ7zZdQ.js +65641 -0
  39. package/dist/{index-5975bbc0.js → index-C1x9Popy.js} +1 -1
  40. package/dist/index-CCNK5H8T.js +103 -0
  41. package/dist/{index-a1a53af6.js → index-CD09p_mF.js} +7 -31
  42. package/dist/index-CFnsLnrb.js +496 -0
  43. package/dist/{index-a43b144f.js → index-CJZp9lE4.js} +29 -50
  44. package/dist/{index-57492b9b.js → index-CSnBqUsQ.js} +48 -1
  45. package/dist/index-CWWI8SHO.js +206 -0
  46. package/dist/{index-7b8840f9.js → index-CZlEoE62.js} +220 -1010
  47. package/dist/index-CbyMC6Yz.js +59 -0
  48. package/dist/index-CiBVH-oH.js +258 -0
  49. package/dist/{index-0e7229ea.js → index-DUMmFdJ7.js} +9 -21
  50. package/dist/{index-aea75a9f.js → index-Du-Biu-I.js} +1 -1
  51. package/dist/index-EnzWG8R0.js +521 -0
  52. package/dist/index-F2RO3OU4.js +501 -0
  53. package/dist/{index-7f513a14.js → index-GavQwMDL.js} +11 -29
  54. package/dist/{index-48653b79.js → index-suip9eAw.js} +2 -2
  55. package/dist/index.d.ts +18 -14
  56. package/dist/index.js +23 -19
  57. package/dist/info-circle-fill-CFeVMdci.js +4 -0
  58. package/dist/input.js +6 -0
  59. package/dist/inputShadowless.js +6 -0
  60. package/dist/jszip.min-Ca6PjkYs.js +2674 -0
  61. package/dist/message.js +5 -0
  62. package/dist/modal.js +4 -0
  63. package/dist/{components/option/index.js → option.js} +3 -6
  64. package/dist/{pdf-bdb7818a.js → pdf-B2a6ll8f.js} +1 -1
  65. package/dist/player.js +8 -0
  66. package/dist/popover.js +6 -0
  67. package/dist/preview.js +7 -0
  68. package/dist/progress.js +7 -0
  69. package/dist/radar.js +6 -0
  70. package/dist/select.js +10 -0
  71. package/dist/selectShadowless.js +10 -0
  72. package/dist/{umd/components/image → shadowless/icon}/index.d.ts +1 -0
  73. package/dist/shadowless/input/index.d.ts +210 -0
  74. package/dist/{umd/components → shadowless}/select/index.d.ts +19 -11
  75. package/dist/shadowless/shadowless/index.js +14 -0
  76. package/dist/shadowless.d.ts +3 -0
  77. package/dist/skeleton.js +4 -0
  78. package/dist/sprite-CH2zLtZy.js +141 -0
  79. package/dist/style.css +1 -1
  80. package/dist/tab.js +6 -0
  81. package/dist/tabpane.js +4 -0
  82. package/dist/tsconfig.json +29 -0
  83. package/dist/umd/index.umd.cjs +21 -32
  84. package/dist/umd/shadowless/shadowless.umd.cjs +1 -0
  85. package/dist/umd/shadowless/style.css +1 -0
  86. package/dist/umd/style.css +1 -1
  87. package/dist/utils/color.d.ts +52 -0
  88. package/dist/utils/index.d.ts +9 -1
  89. package/dist/utils-BMBEcoPj.js +356 -0
  90. package/dist/vite.config.d.ts +1 -0
  91. package/package.json +61 -39
  92. package/readme.md +14 -14
  93. package/typings.d.ts +101 -0
  94. package/dist/components/button/index.js +0 -7
  95. package/dist/components/icon/index.js +0 -6
  96. package/dist/components/image/index.js +0 -4
  97. package/dist/components/input/index.js +0 -5
  98. package/dist/components/message/index.js +0 -4
  99. package/dist/components/modal/index.js +0 -4
  100. package/dist/components/player/index.js +0 -11
  101. package/dist/components/preview/index.js +0 -8
  102. package/dist/components/progress/index.js +0 -8
  103. package/dist/components/radar/index.js +0 -7
  104. package/dist/components/select/index.js +0 -11
  105. package/dist/components/skeleton/index.js +0 -4
  106. package/dist/components/tab/index.js +0 -7
  107. package/dist/components/tabpane/index.js +0 -4
  108. package/dist/docx-c5d02d8c.js +0 -21
  109. package/dist/index-183517e7.js +0 -265
  110. package/dist/index-4d873a42.js +0 -195
  111. package/dist/index-a216f328.js +0 -662
  112. package/dist/index-d2d69b06.js +0 -225
  113. package/dist/index-ecaed5cc.js +0 -439
  114. package/dist/info-circle-fill-90ec9aa9.js +0 -14
  115. package/dist/umd/build/config.d.ts +0 -3
  116. package/dist/umd/build/config.umd.d.ts +0 -2
  117. package/dist/umd/components/button/index.d.ts +0 -2
  118. package/dist/umd/components/form/index.d.ts +0 -2
  119. package/dist/umd/components/icon/index.d.ts +0 -2
  120. package/dist/umd/components/input/index.d.ts +0 -2
  121. package/dist/umd/components/message/index.d.ts +0 -14
  122. package/dist/umd/components/modal/index.d.ts +0 -2
  123. package/dist/umd/components/option/index.d.ts +0 -2
  124. package/dist/umd/components/player/index.d.ts +0 -524
  125. package/dist/umd/components/preview/colz.d.ts +0 -72
  126. package/dist/umd/components/preview/docx.d.ts +0 -8
  127. package/dist/umd/components/preview/excel/excel.d.ts +0 -2
  128. package/dist/umd/components/preview/excel/index.d.ts +0 -1
  129. package/dist/umd/components/preview/excel/media.d.ts +0 -37
  130. package/dist/umd/components/preview/index.d.ts +0 -6
  131. package/dist/umd/components/preview/pdf.d.ts +0 -1
  132. package/dist/umd/components/preview/pptx/index.d.ts +0 -16
  133. package/dist/umd/components/preview/pptx/process_pptx.d.ts +0 -23
  134. package/dist/umd/components/preview/pptx/t_xml.d.ts +0 -1
  135. package/dist/umd/components/preview/pptx/worker.d.ts +0 -1
  136. package/dist/umd/components/progress/index.d.ts +0 -36
  137. package/dist/umd/components/radar/index.d.ts +0 -2
  138. package/dist/umd/components/skeleton/index.d.ts +0 -2
  139. package/dist/umd/components/tab/index.d.ts +0 -403
  140. package/dist/umd/components/tabpane/index.d.ts +0 -347
  141. package/dist/umd/index.d.ts +0 -14
  142. package/dist/umd/playwright.config.d.ts +0 -9
  143. package/dist/umd/plugins/auto-import-file.d.ts +0 -0
  144. package/dist/umd/plugins/load-style.d.ts +0 -6
  145. package/dist/umd/plugins/load-svg.d.ts +0 -9
  146. package/dist/umd/tests/button.spec.d.ts +0 -1
  147. package/dist/umd/utils/image.d.ts +0 -32
  148. package/dist/umd/utils/index.d.ts +0 -64
  149. package/dist/umd/utils/math.d.ts +0 -26
  150. package/dist/umd/utils/tween.d.ts +0 -21
  151. package/dist/umd/vite.config.d.ts +0 -6
  152. package/dist/vendor-f71e6f68.js +0 -92126
  153. /package/dist/{add-user-b2bed3e7.js → add-user-BN1JlY7e.js} +0 -0
  154. /package/dist/{book-b11a68eb.js → book-nTEFXU2x.js} +0 -0
  155. /package/dist/{umd/build/config.es.d.ts → build/config.sha.d.ts} +0 -0
  156. /package/dist/{check-circle-fill-dc284144.js → check-circle-fill-B_pd8ZSs.js} +0 -0
  157. /package/dist/{check-circle-74bd09c3.js → check-circle-szyAJiap.js} +0 -0
  158. /package/dist/{close-20925345.js → close-CFnkhudp.js} +0 -0
  159. /package/dist/{close-circle-720c18be.js → close-circle-CwmuN2C6.js} +0 -0
  160. /package/dist/{close-circle-fill-238a66b1.js → close-circle-fill-jSqPPw9i.js} +0 -0
  161. /package/dist/{eye-5e742329.js → eye-D_mEt17f.js} +0 -0
  162. /package/dist/{eye-close-3874f1ae.js → eye-close-BVr3NJtg.js} +0 -0
  163. /package/dist/{home-c4a05e8b.js → home-BUQ4USMk.js} +0 -0
  164. /package/dist/{index-8e1e2573.js → index-CQTJoWhb.js} +0 -0
  165. /package/dist/{info-circle-5826decc.js → info-circle-COnL5bTJ.js} +0 -0
  166. /package/dist/{loading-09ca52df.js → loading-Dcc5RApI.js} +0 -0
  167. /package/dist/{lock-1d2487c9.js → lock-Cr7BnmWN.js} +0 -0
  168. /package/dist/{message-b2bfdea7.js → message-D36_Zo2l.js} +0 -0
  169. /package/dist/{power-off-6ade5a91.js → power-off-lQRbiBak.js} +0 -0
  170. /package/dist/{preview-b291aea8.js → preview-CJbz9GjO.js} +0 -0
  171. /package/dist/{setting-1e5ccb6d.js → setting-DemlgzVC.js} +0 -0
  172. /package/dist/{team-ca6a12e1.js → team-tl4NJXPC.js} +0 -0
  173. /package/dist/{unlock-f56086fd.js → unlock-CeU74z9n.js} +0 -0
  174. /package/dist/{user-5c01e665.js → user-B-eVXwuk.js} +0 -0
  175. /package/dist/{warning-circle-035e025c.js → warning-circle-DDUgEDIv.js} +0 -0
  176. /package/dist/{warning-circle-fill-d17c37c9.js → warning-circle-fill-lODUKz0i.js} +0 -0
@@ -4,8 +4,9 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { c as createDocumentFragment, S as SyncHook, r as removeClassToElement, a as addClassToElement, b as timeFormat, d as range, e as throttle$1 } from "./index-d2d69b06.js";
8
- import "./index-f6d6982d.js";
7
+ import { b as createDocumentFragment, S as SyncHook, r as removeClassToElement, a as addClassToElement, t as timeFormat, e as range, d as generateThrottle } from "./utils-BMBEcoPj.js";
8
+ import "./index-BLepXisd.js";
9
+ import { H as HTMLElementSSR } from "./index-CSnBqUsQ.js";
9
10
  !function t(e) {
10
11
  var r, i;
11
12
  r = this, i = function() {
@@ -9312,1102 +9313,925 @@ import "./index-f6d6982d.js";
9312
9313
  return Xa.defaultConfig = void 0, Xa;
9313
9314
  }, "object" == typeof exports && "undefined" != typeof module ? module.exports = i() : "function" == typeof define && define.amd ? define(i) : (r = "undefined" != typeof globalThis ? globalThis : r || self).Hls = i();
9314
9315
  }(false);
9315
- const index$2 = "";
9316
9316
  const PLAY_STATE_LIST = ["play", "playing", "timeupdate"];
9317
+ const throttle = generateThrottle();
9317
9318
  const SPEED = [
9318
9319
  { label: "2.0X", value: 2 },
9319
9320
  { label: "1.5X", value: 1.5 },
9320
9321
  { label: "1.0X", value: 1 },
9322
+ { label: "0.8X", value: 0.8 },
9321
9323
  { label: "0.5X", value: 0.5 }
9322
9324
  ];
9323
- function Custom() {
9324
- if (typeof document !== "undefined" && !customElements.get("r-player")) {
9325
- class RanPlayer extends HTMLElement {
9326
- /**
9327
- * @description: 初始化view和video的全局上下文
9328
- * @return {*}
9329
- */
9330
- constructor() {
9331
- super();
9332
- __publicField(this, "ctx");
9333
- __publicField(this, "_player");
9334
- __publicField(this, "_container");
9335
- __publicField(this, "_slot");
9336
- __publicField(this, "_playerController");
9337
- __publicField(this, "_playerBtn");
9338
- __publicField(this, "_progress");
9339
- __publicField(this, "_progressDot");
9340
- __publicField(this, "_progressWrap");
9341
- __publicField(this, "_progressWrapValue");
9342
- __publicField(this, "requestAnimationFrameId");
9343
- __publicField(this, "moveProgress");
9344
- __publicField(this, "_playerControllerBottom");
9345
- __publicField(this, "_playerControllerBottomRight");
9346
- __publicField(this, "_playerControllerBottomLeft");
9347
- __publicField(this, "_playerControllerBottomPlayBtn");
9348
- __publicField(this, "_playerControllerBottomTimeCurrent");
9349
- __publicField(this, "_playerControllerBottomTimeDuration");
9350
- __publicField(this, "_playerControllerBottomTimeDivide");
9351
- __publicField(this, "_playControllerBottomClarity");
9352
- __publicField(this, "_playControllerBottomSpeed");
9353
- __publicField(this, "_playControllerBottomSpeedIcon");
9354
- __publicField(this, "_playControllerBottomVolumeProgress");
9355
- __publicField(this, "_playControllerBottomRightFullScreen");
9356
- __publicField(this, "_playControllerBottomVolume");
9357
- __publicField(this, "_playControllerBottomSpeedPopover");
9358
- __publicField(this, "controllerBarTimeId");
9359
- __publicField(this, "_playerTip");
9360
- __publicField(this, "_playerTipTime");
9361
- __publicField(this, "_playerTipText");
9362
- __publicField(this, "_volume");
9363
- __publicField(this, "_video");
9364
- __publicField(this, "_hls");
9365
- __publicField(this, "changeClarityToSetVideo", () => {
9366
- const { currentTime, playbackRate, volume, currentState } = this.ctx;
9367
- this.setCurrentTime(currentTime);
9368
- this.setPlaybackRate(playbackRate);
9369
- this.setVolume(volume);
9370
- if (PLAY_STATE_LIST.includes(currentState)) {
9371
- this.play();
9372
- } else {
9373
- this.pause();
9374
- }
9375
- });
9376
- __publicField(this, "changeClarity", (e) => {
9377
- this.ctx.clarity = e.detail.value;
9378
- const url = this.ctx.levelMap.get(e.detail.value);
9379
- if (url && this._hls) {
9380
- this._hls.loadSource(url);
9381
- this._hls.startLoad();
9382
- this.changeClarityToSetVideo();
9383
- }
9384
- });
9385
- __publicField(this, "createClaritySelect", () => {
9386
- const { levels, url } = this.ctx;
9387
- this._playControllerBottomClarity.innerHTML = "";
9388
- if (levels.length <= 0)
9325
+ class RanPlayer extends HTMLElementSSR() {
9326
+ /**
9327
+ * @description: 初始化 view 和 video 的全局上下文
9328
+ * @return {*}
9329
+ */
9330
+ constructor() {
9331
+ super();
9332
+ __publicField(this, "ctx");
9333
+ __publicField(this, "_player");
9334
+ __publicField(this, "_container");
9335
+ __publicField(this, "_slot");
9336
+ __publicField(this, "_playerController");
9337
+ __publicField(this, "_playerBtn");
9338
+ __publicField(this, "_progress");
9339
+ __publicField(this, "_progressDot");
9340
+ __publicField(this, "_progressWrap");
9341
+ __publicField(this, "_progressWrapValue");
9342
+ __publicField(this, "requestAnimationFrameId");
9343
+ __publicField(this, "moveProgress");
9344
+ __publicField(this, "_playerControllerBottom");
9345
+ __publicField(this, "_playerControllerBottomRight");
9346
+ __publicField(this, "_playerControllerBottomLeft");
9347
+ __publicField(this, "_playerControllerBottomPlayBtn");
9348
+ __publicField(this, "_playerControllerBottomTimeCurrent");
9349
+ __publicField(this, "_playerControllerBottomTimeDuration");
9350
+ __publicField(this, "_playerControllerBottomTimeDivide");
9351
+ __publicField(this, "_playControllerBottomClarity");
9352
+ __publicField(this, "_playControllerBottomSpeed");
9353
+ __publicField(this, "_playControllerBottomSpeedIcon");
9354
+ __publicField(this, "_playControllerBottomVolumeProgress");
9355
+ __publicField(this, "_playControllerBottomRightFullScreen");
9356
+ __publicField(this, "_playControllerBottomVolume");
9357
+ __publicField(this, "_playControllerBottomSpeedPopover");
9358
+ __publicField(this, "controllerBarTimeId");
9359
+ __publicField(this, "_playerTip");
9360
+ __publicField(this, "_playerTipTime");
9361
+ __publicField(this, "_playerTipText");
9362
+ __publicField(this, "_volume");
9363
+ __publicField(this, "_video");
9364
+ __publicField(this, "_hls");
9365
+ __publicField(this, "changeClarityToSetVideo", () => {
9366
+ const { currentTime, playbackRate, volume, currentState } = this.ctx;
9367
+ this.setCurrentTime(currentTime);
9368
+ this.setPlaybackRate(playbackRate);
9369
+ this.setVolume(volume);
9370
+ if (PLAY_STATE_LIST.includes(currentState)) {
9371
+ this.play();
9372
+ } else {
9373
+ this.pause();
9374
+ }
9375
+ });
9376
+ __publicField(this, "changeClarity", (e) => {
9377
+ this.ctx.clarity = e.detail.value;
9378
+ const url = this.ctx.levelMap.get(e.detail.value);
9379
+ if (url && this._hls) {
9380
+ this._hls.loadSource(url);
9381
+ this._hls.startLoad();
9382
+ this.changeClarityToSetVideo();
9383
+ }
9384
+ });
9385
+ __publicField(this, "createClaritySelect", () => {
9386
+ const { levels, url } = this.ctx;
9387
+ this._playControllerBottomClarity.innerHTML = "";
9388
+ if (levels.length <= 0)
9389
+ return;
9390
+ const Fragment = document.createDocumentFragment();
9391
+ levels.forEach((item) => {
9392
+ const { name, url: url2 } = item;
9393
+ if (!name || !url2)
9394
+ return;
9395
+ this.ctx.levelMap.set(name, url2);
9396
+ const option = document.createElement("r-option");
9397
+ option.setAttribute("value", name);
9398
+ option.innerHTML = name;
9399
+ Fragment.appendChild(option);
9400
+ });
9401
+ const select = document.createElement("r-select");
9402
+ select.setAttribute("value", this.ctx.clarity || "Auto");
9403
+ select.appendChild(Fragment);
9404
+ select.setAttribute("type", "text");
9405
+ select.setAttribute("action", "hover,click");
9406
+ select.setAttribute("placement", "top");
9407
+ const id = this._player.getAttribute("id");
9408
+ id && select.setAttribute("getPopupContainerId", id);
9409
+ select.setAttribute("dropdownclass", "video-clarity-dropdown");
9410
+ select.addEventListener("change", this.changeClarity);
9411
+ this._playControllerBottomClarity.appendChild(select);
9412
+ });
9413
+ __publicField(this, "manifestLoaded", (type, data) => {
9414
+ if (type === "hlsManifestLoaded") {
9415
+ const { url, levels = [] } = data;
9416
+ if (levels.length <= 0)
9417
+ return;
9418
+ levels.forEach((item) => {
9419
+ if (this.ctx.levelMap.get(item.name) === item.url)
9389
9420
  return;
9390
- const Fragment = document.createDocumentFragment();
9391
- levels.forEach((item) => {
9392
- const { name, url: url2 } = item;
9393
- if (!name || !url2)
9394
- return;
9395
- this.ctx.levelMap.set(name, url2);
9396
- const option = document.createElement("r-option");
9397
- option.setAttribute("value", name);
9398
- option.innerHTML = name;
9399
- Fragment.appendChild(option);
9400
- });
9401
- const select = document.createElement("r-select");
9402
- select.setAttribute("value", this.ctx.clarity || "Auto");
9403
- select.appendChild(Fragment);
9404
- select.setAttribute("type", "text");
9405
- select.setAttribute("action", "hover,click");
9406
- select.setAttribute("placement", "top");
9407
- const id = this._player.getAttribute("id");
9408
- id && select.setAttribute("getPopupContainerId", id);
9409
- select.setAttribute("dropdownclass", "video-clarity-dropdown");
9410
- select.addEventListener("change", this.changeClarity);
9411
- this._playControllerBottomClarity.appendChild(select);
9421
+ this.ctx.levels.push(item);
9412
9422
  });
9413
- __publicField(this, "manifestLoaded", (type, data) => {
9414
- if (type === "hlsManifestLoaded") {
9415
- const { url, levels = [] } = data;
9416
- if (levels.length <= 0)
9417
- return;
9418
- levels.forEach((item) => {
9419
- if (this.ctx.levelMap.get(item.name) === item.url)
9420
- return;
9421
- this.ctx.levels.push(item);
9422
- });
9423
- if (!this.ctx.levelMap.get("Auto")) {
9424
- this.ctx.levels.push({ name: "Auto", url });
9425
- this.ctx.levelMap.set("Auto", url);
9426
- }
9427
- this.ctx.url = url;
9428
- this.createClaritySelect();
9429
- }
9430
- });
9431
- /**
9432
- * @description: 初始化 video 和更新 video 方法
9433
- * @return {*}
9434
- */
9435
- __publicField(this, "updatePlayer", () => {
9436
- var _a;
9437
- const { Hls } = window;
9438
- if (!this.contains(this._player))
9439
- this.appendChild(this._player);
9423
+ if (!this.ctx.levelMap.get("Auto")) {
9424
+ this.ctx.levels.push({ name: "Auto", url });
9425
+ this.ctx.levelMap.set("Auto", url);
9426
+ }
9427
+ this.ctx.url = url;
9428
+ this.createClaritySelect();
9429
+ this.change("hlsManifestLoaded", { data });
9430
+ }
9431
+ });
9432
+ /**
9433
+ * @description: 初始化 video 和更新 video 方法
9434
+ * @return {*}
9435
+ */
9436
+ __publicField(this, "updatePlayer", () => {
9437
+ var _a;
9438
+ const { Hls } = window;
9439
+ if (!this.contains(this._player))
9440
+ this.appendChild(this._player);
9441
+ if (this._hls) {
9442
+ this._hls.destroy();
9443
+ this._hls = void 0;
9444
+ }
9445
+ this._video = document.createElement("video");
9446
+ this._video.setAttribute("class", "ran-player-video");
9447
+ this._video.setAttribute("preload", "auto");
9448
+ this._video.setAttribute("x5-video-player-type", "h5");
9449
+ this._video.setAttribute("x5-video-orientation", "portrait");
9450
+ this._video.setAttribute("webkit-playsinline", "true");
9451
+ this._video.setAttribute("playsinline", "true");
9452
+ this._video.setAttribute("controls", "false");
9453
+ this._video.controls = false;
9454
+ this._video.setAttribute("initial-time", "0.01");
9455
+ try {
9456
+ if (this._video.canPlayType("application/vnd.apple.mpegurl") && this.src) {
9457
+ this._video.src = this.src;
9458
+ } else if ((Hls == null ? void 0 : Hls.isSupported()) && this.src) {
9459
+ this._hls = new Hls();
9440
9460
  if (this._hls) {
9441
- this._hls.destroy();
9442
- this._hls = void 0;
9443
- }
9444
- this._video = document.createElement("video");
9445
- this._video.setAttribute("class", "ran-player-video");
9446
- this._video.setAttribute("preload", "auto");
9447
- this._video.setAttribute("x5-video-player-type", "h5");
9448
- this._video.setAttribute("x5-video-orientation", "portrait");
9449
- this._video.setAttribute("webkit-playsinline", "true");
9450
- this._video.setAttribute("playsinline", "true");
9451
- this._video.setAttribute("controls", "false");
9452
- this._video.controls = false;
9453
- this._video.setAttribute("initial-time", "0.01");
9454
- if ((Hls == null ? void 0 : Hls.isSupported()) && this.src) {
9455
- this._hls = new Hls();
9456
- if (this._hls) {
9457
- this._hls.off(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9458
- this._hls.on(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9459
- this._hls.loadSource(this.src);
9460
- this._hls.attachMedia(this._video);
9461
- }
9462
- this._container.appendChild(this._video);
9463
- (_a = this._video.parentElement) == null ? void 0 : _a.setAttribute(
9464
- "class",
9465
- "ran-player-contain"
9466
- );
9467
- }
9468
- this.listenEvent();
9469
- });
9470
- __publicField(this, "change", (name, value) => {
9471
- const currentTime = this.getCurrentTime();
9472
- const duration = this.getTotalTime();
9473
- this.dispatchEvent(
9474
- new CustomEvent("change", {
9475
- detail: {
9476
- type: name,
9477
- data: value,
9478
- currentTime,
9479
- duration,
9480
- tag: this
9481
- }
9482
- })
9483
- );
9484
- });
9485
- __publicField(this, "onCanplay", (e) => {
9486
- this.ctx.currentState = e.type;
9487
- removeClassToElement(
9488
- this._playerControllerBottomPlayBtn,
9489
- "ran-player-controller-bottom-left-btn-pause"
9490
- );
9491
- addClassToElement(
9492
- this._playerControllerBottomPlayBtn,
9493
- "ran-player-controller-bottom-left-btn-play"
9494
- );
9495
- this.change("canplay", e);
9496
- this.resize();
9497
- });
9498
- __publicField(this, "onCanplaythrough", (e) => {
9499
- this.ctx.currentState = e.type;
9500
- this.change("canplaythrough", e);
9501
- });
9502
- __publicField(this, "onComplete", (e) => {
9503
- this.ctx.currentState = e.type;
9504
- this.change("complete", e);
9505
- });
9506
- __publicField(this, "onDurationchange", (e) => {
9507
- this.ctx.currentState = e.type;
9508
- this.change("durationchange", e);
9509
- });
9510
- __publicField(this, "onEmptied", (e) => {
9511
- this.ctx.currentState = e.type;
9512
- this.change("emptied", e);
9513
- });
9514
- __publicField(this, "onEnded", (e) => {
9515
- this.ctx.currentState = e.type;
9516
- this.change("ended", e);
9517
- });
9518
- __publicField(this, "onError", (e) => {
9519
- this.ctx.currentState = e.type;
9520
- this.change("error", e);
9521
- });
9522
- __publicField(this, "onLoadedmetadata", (e) => {
9523
- this.ctx.currentState = e.type;
9524
- this.change("loadedmetadata", e);
9525
- });
9526
- __publicField(this, "onLoadstart", (e) => {
9527
- this.ctx.currentState = e.type;
9528
- this.change("loadstart", e);
9529
- });
9530
- __publicField(this, "onProgress", (e) => {
9531
- this.ctx.currentState = e.type;
9532
- this.change("progress", e);
9533
- });
9534
- __publicField(this, "onRatechange", (e) => {
9535
- this.ctx.currentState = e.type;
9536
- this.change("ratechange", e);
9537
- });
9538
- __publicField(this, "onSeeked", (e) => {
9539
- this.ctx.currentState = e.type;
9540
- this.change("seeked", e);
9541
- });
9542
- __publicField(this, "onSeeking", (e) => {
9543
- this.ctx.currentState = e.type;
9544
- this.change("seeking", e);
9545
- });
9546
- __publicField(this, "onStalled", (e) => {
9547
- this.ctx.currentState = e.type;
9548
- this.change("stalled", e);
9549
- });
9550
- __publicField(this, "onSuspend", (e) => {
9551
- this.ctx.currentState = e.type;
9552
- this.change("suspend", e);
9553
- });
9554
- __publicField(this, "onLoadeddata", (e) => {
9555
- this.ctx.currentState = e.type;
9556
- const duration = this.getTotalTime();
9557
- this.ctx.duration = duration;
9558
- this._playerControllerBottomTimeCurrent.innerText = "00:00";
9559
- this._playerControllerBottomTimeDivide.innerText = "/";
9560
- this._playerControllerBottomTimeDuration.innerText = timeFormat(
9561
- this.ctx.duration
9562
- );
9563
- this.change("loadeddata", e);
9564
- });
9565
- __publicField(this, "onTimeupdate", (e) => {
9566
- this.ctx.currentState = e.type;
9567
- this.change("timeupdate", e);
9568
- });
9569
- __publicField(this, "onVolumechange", (e) => {
9570
- this.ctx.currentState = e.type;
9571
- this.change("volumechange", e);
9572
- });
9573
- __publicField(this, "onWaiting", (e) => {
9574
- this.ctx.currentState = e.type;
9575
- this.change("waiting", e);
9576
- });
9577
- __publicField(this, "onPlay", (e) => {
9578
- this.ctx.currentState = e.type;
9579
- this.requestAnimationFrame(this.updateCurrentProgress);
9580
- removeClassToElement(
9581
- this._playerControllerBottomPlayBtn,
9582
- "ran-player-controller-bottom-left-btn-play"
9583
- );
9584
- addClassToElement(
9585
- this._playerControllerBottomPlayBtn,
9586
- "ran-player-controller-bottom-left-btn-pause"
9587
- );
9588
- this.showControllerBar();
9589
- this.change("play", e);
9590
- });
9591
- __publicField(this, "onPlaying", (e) => {
9592
- this.ctx.currentState = e.type;
9593
- this._playerBtn.style.setProperty("display", "none");
9594
- removeClassToElement(
9595
- this._playerControllerBottomPlayBtn,
9596
- "ran-player-controller-bottom-left-btn-play"
9597
- );
9598
- addClassToElement(
9599
- this._playerControllerBottomPlayBtn,
9600
- "ran-player-controller-bottom-left-btn-pause"
9601
- );
9602
- this.requestAnimationFrame(this.updateCurrentProgress);
9603
- this.showControllerBar();
9604
- this.change("playing", e);
9605
- });
9606
- __publicField(this, "onPause", (e) => {
9607
- this.ctx.currentState = e.type;
9608
- this._playerBtn.style.setProperty("display", "block");
9609
- this.change("pause", e);
9610
- removeClassToElement(
9611
- this._playerControllerBottomPlayBtn,
9612
- "ran-player-controller-bottom-left-btn-pause"
9613
- );
9614
- addClassToElement(
9615
- this._playerControllerBottomPlayBtn,
9616
- "ran-player-controller-bottom-left-btn-play"
9617
- );
9618
- this.cancelAnimationFrame();
9461
+ this._hls.off(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9462
+ this._hls.on(Hls.Events.MANIFEST_LOADED, this.manifestLoaded);
9463
+ this._hls.off(Hls.Events.ERROR, this.hlsError);
9464
+ this._hls.on(Hls.Events.ERROR, this.hlsError);
9465
+ this._hls.loadSource(this.src);
9466
+ this._hls.attachMedia(this._video);
9467
+ }
9468
+ this._container.appendChild(this._video);
9469
+ (_a = this._video.parentElement) == null ? void 0 : _a.setAttribute("class", "ran-player-contain");
9470
+ }
9471
+ this.listenEvent();
9472
+ } catch (error) {
9473
+ }
9474
+ });
9475
+ __publicField(this, "hlsError", (event, data) => {
9476
+ this.change("hlsError", { event, data });
9477
+ if (this._video) {
9478
+ this._video.src = this.src;
9479
+ }
9480
+ });
9481
+ __publicField(this, "change", (name, value) => {
9482
+ const currentTime = this.getCurrentTime();
9483
+ const duration = this.getTotalTime();
9484
+ this.debug && console.log(name, value);
9485
+ this.dispatchEvent(
9486
+ new CustomEvent("change", {
9487
+ detail: {
9488
+ type: name,
9489
+ data: value,
9490
+ currentTime,
9491
+ duration,
9492
+ tag: this
9493
+ }
9494
+ })
9495
+ );
9496
+ });
9497
+ __publicField(this, "onCanplay", (e) => {
9498
+ this.ctx.currentState = e.type;
9499
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9500
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9501
+ this.change("canplay", e);
9502
+ this.resize();
9503
+ });
9504
+ __publicField(this, "onCanplaythrough", (e) => {
9505
+ this.ctx.currentState = e.type;
9506
+ this.change("canplaythrough", e);
9507
+ });
9508
+ __publicField(this, "onComplete", (e) => {
9509
+ this.ctx.currentState = e.type;
9510
+ this.change("complete", e);
9511
+ });
9512
+ __publicField(this, "onDurationchange", (e) => {
9513
+ this.ctx.currentState = e.type;
9514
+ this.change("durationchange", e);
9515
+ });
9516
+ __publicField(this, "onEmptied", (e) => {
9517
+ this.ctx.currentState = e.type;
9518
+ this.change("emptied", e);
9519
+ });
9520
+ __publicField(this, "onEnded", (e) => {
9521
+ this.ctx.currentState = e.type;
9522
+ this.change("ended", e);
9523
+ });
9524
+ __publicField(this, "onError", (e) => {
9525
+ this.ctx.currentState = e.type;
9526
+ this.change("error", e);
9527
+ });
9528
+ __publicField(this, "onLoadedmetadata", (e) => {
9529
+ this.ctx.currentState = e.type;
9530
+ this.change("loadedmetadata", e);
9531
+ });
9532
+ __publicField(this, "onLoadstart", (e) => {
9533
+ this.ctx.currentState = e.type;
9534
+ this.change("loadstart", e);
9535
+ });
9536
+ __publicField(this, "onProgress", (e) => {
9537
+ this.ctx.currentState = e.type;
9538
+ this.change("progress", e);
9539
+ });
9540
+ __publicField(this, "onRatechange", (e) => {
9541
+ this.ctx.currentState = e.type;
9542
+ this.change("ratechange", e);
9543
+ });
9544
+ __publicField(this, "onSeeked", (e) => {
9545
+ this.ctx.currentState = e.type;
9546
+ this.change("seeked", e);
9547
+ });
9548
+ __publicField(this, "onSeeking", (e) => {
9549
+ this.ctx.currentState = e.type;
9550
+ this.change("seeking", e);
9551
+ });
9552
+ __publicField(this, "onStalled", (e) => {
9553
+ this.ctx.currentState = e.type;
9554
+ this.change("stalled", e);
9555
+ });
9556
+ __publicField(this, "onSuspend", (e) => {
9557
+ this.ctx.currentState = e.type;
9558
+ this.change("suspend", e);
9559
+ });
9560
+ __publicField(this, "onLoadeddata", (e) => {
9561
+ this.ctx.currentState = e.type;
9562
+ const duration = this.getTotalTime();
9563
+ this.ctx.duration = duration;
9564
+ this._playerControllerBottomTimeCurrent.innerText = "00:00";
9565
+ this._playerControllerBottomTimeDivide.innerText = "/";
9566
+ this._playerControllerBottomTimeDuration.innerText = timeFormat(this.ctx.duration);
9567
+ this.change("loadeddata", e);
9568
+ });
9569
+ __publicField(this, "onTimeupdate", (e) => {
9570
+ this.ctx.currentState = e.type;
9571
+ this.change("timeupdate", e);
9572
+ });
9573
+ __publicField(this, "onVolumechange", (e) => {
9574
+ this.ctx.currentState = e.type;
9575
+ this.change("volumechange", e);
9576
+ });
9577
+ __publicField(this, "onWaiting", (e) => {
9578
+ this.ctx.currentState = e.type;
9579
+ this.change("waiting", e);
9580
+ });
9581
+ __publicField(this, "onPlay", (e) => {
9582
+ this.ctx.currentState = e.type;
9583
+ this.requestAnimationFrame(this.updateCurrentProgress);
9584
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9585
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9586
+ this.showControllerBar();
9587
+ this.change("play", e);
9588
+ });
9589
+ __publicField(this, "onPlaying", (e) => {
9590
+ this.ctx.currentState = e.type;
9591
+ this._playerBtn.style.setProperty("display", "none");
9592
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9593
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9594
+ this.requestAnimationFrame(this.updateCurrentProgress);
9595
+ this.showControllerBar();
9596
+ this.change("playing", e);
9597
+ });
9598
+ __publicField(this, "onPause", (e) => {
9599
+ this.ctx.currentState = e.type;
9600
+ this._playerBtn.style.setProperty("display", "block");
9601
+ this.change("pause", e);
9602
+ removeClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-pause");
9603
+ addClassToElement(this._playerControllerBottomPlayBtn, "ran-player-controller-bottom-left-btn-play");
9604
+ this.cancelAnimationFrame();
9605
+ this._playerController.style.setProperty("opacity", "1");
9606
+ if (this.controllerBarTimeId) {
9607
+ clearTimeout(this.controllerBarTimeId);
9608
+ this.controllerBarTimeId = void 0;
9609
+ }
9610
+ });
9611
+ __publicField(this, "clearListenerEvent", () => {
9612
+ if (!this._video)
9613
+ return;
9614
+ this._video.removeEventListener("canplay", this.onCanplay);
9615
+ this._video.removeEventListener("canplaythrough", this.onCanplaythrough);
9616
+ this._video.removeEventListener("complete", this.onComplete);
9617
+ this._video.removeEventListener("durationchange", this.onDurationchange);
9618
+ this._video.removeEventListener("emptied", this.onEmptied);
9619
+ this._video.removeEventListener("ended", this.onEnded);
9620
+ this._video.removeEventListener("error", this.onError);
9621
+ this._video.removeEventListener("loadeddata", this.onLoadeddata);
9622
+ this._video.removeEventListener("loadedmetadata", this.onLoadedmetadata);
9623
+ this._video.removeEventListener("loadstart", this.onLoadstart);
9624
+ this._video.removeEventListener("pause", this.onPause);
9625
+ this._video.removeEventListener("play", this.onPlay);
9626
+ this._video.removeEventListener("playing", this.onPlaying);
9627
+ this._video.removeEventListener("progress", this.onProgress);
9628
+ this._video.removeEventListener("ratechange", this.onRatechange);
9629
+ this._video.removeEventListener("seeked", this.onSeeked);
9630
+ this._video.removeEventListener("seeking", this.onSeeking);
9631
+ this._video.removeEventListener("stalled", this.onStalled);
9632
+ this._video.removeEventListener("suspend", this.onSuspend);
9633
+ this._video.removeEventListener("timeupdate", this.onTimeupdate);
9634
+ this._video.removeEventListener("volumechange", this.onVolumechange);
9635
+ this._video.removeEventListener("waiting", this.onWaiting);
9636
+ });
9637
+ /**
9638
+ * @description: 用户行为和 video 之间的交互
9639
+ * @return {*}
9640
+ */
9641
+ __publicField(this, "listenEvent", () => {
9642
+ if (!this._video)
9643
+ return;
9644
+ this.clearListenerEvent();
9645
+ this._video.addEventListener("canplay", this.onCanplay);
9646
+ this._video.addEventListener("canplaythrough", this.onCanplaythrough);
9647
+ this._video.addEventListener("complete", this.onComplete);
9648
+ this._video.addEventListener("durationchange", this.onDurationchange);
9649
+ this._video.addEventListener("emptied", this.onEmptied);
9650
+ this._video.addEventListener("ended", this.onEnded);
9651
+ this._video.addEventListener("error", this.onError);
9652
+ this._video.addEventListener("loadeddata", this.onLoadeddata);
9653
+ this._video.addEventListener("loadedmetadata", this.onLoadedmetadata);
9654
+ this._video.addEventListener("loadstart", this.onLoadstart);
9655
+ this._video.addEventListener("pause", this.onPause);
9656
+ this._video.addEventListener("play", this.onPlay);
9657
+ this._video.addEventListener("playing", this.onPlaying);
9658
+ this._video.addEventListener("progress", this.onProgress);
9659
+ this._video.addEventListener("ratechange", this.onRatechange);
9660
+ this._video.addEventListener("seeked", this.onSeeked);
9661
+ this._video.addEventListener("seeking", this.onSeeking);
9662
+ this._video.addEventListener("stalled", this.onStalled);
9663
+ this._video.addEventListener("suspend", this.onSuspend);
9664
+ this._video.addEventListener("timeupdate", this.onTimeupdate);
9665
+ this._video.addEventListener("volumechange", this.onVolumechange);
9666
+ this._video.addEventListener("waiting", this.onWaiting);
9667
+ });
9668
+ __publicField(this, "showControllerBar", (e) => {
9669
+ if (e) {
9670
+ const dom = e.target;
9671
+ if (dom.classList.value.includes("ran-player-controller")) {
9619
9672
  this._playerController.style.setProperty("opacity", "1");
9620
9673
  if (this.controllerBarTimeId) {
9621
9674
  clearTimeout(this.controllerBarTimeId);
9622
9675
  this.controllerBarTimeId = void 0;
9623
9676
  }
9677
+ return;
9678
+ }
9679
+ }
9680
+ if (PLAY_STATE_LIST.includes(this.ctx.currentState)) {
9681
+ this._playerController.style.setProperty("opacity", "1");
9682
+ if (this.controllerBarTimeId) {
9683
+ clearTimeout(this.controllerBarTimeId);
9684
+ this.controllerBarTimeId = void 0;
9685
+ }
9686
+ this.controllerBarTimeId = setTimeout(() => {
9687
+ this._playerController.style.setProperty("opacity", "0");
9688
+ clearTimeout(this.controllerBarTimeId);
9689
+ this.controllerBarTimeId = void 0;
9690
+ }, 2e3);
9691
+ } else {
9692
+ this._playerController.style.setProperty("opacity", "1");
9693
+ if (this.controllerBarTimeId) {
9694
+ clearTimeout(this.controllerBarTimeId);
9695
+ this.controllerBarTimeId = void 0;
9696
+ }
9697
+ }
9698
+ });
9699
+ /**
9700
+ * @description: 进度条点击事件
9701
+ * @param {MouseEvent} e
9702
+ * @return {*}
9703
+ */
9704
+ __publicField(this, "progressClick", (e) => {
9705
+ const rect = this._progressWrap.getBoundingClientRect();
9706
+ const offsetX = e.clientX - rect.left;
9707
+ const percentage = range(offsetX / this._progress.offsetWidth);
9708
+ this.setCurrentTime(this.ctx.duration * percentage);
9709
+ this.updateCurrentProgress();
9710
+ });
9711
+ /**
9712
+ * @description: 进度条鼠标按下事件
9713
+ * @param {MouseEvent} e
9714
+ * @return {*}
9715
+ */
9716
+ __publicField(this, "progressDotMouseDown", (e) => {
9717
+ this._playerBtn.style.setProperty("display", "none");
9718
+ this.moveProgress.mouseDown = true;
9719
+ this.cancelAnimationFrame();
9720
+ });
9721
+ /**
9722
+ * @description: 进度条鼠标移动事件
9723
+ * @param {MouseEvent} e
9724
+ * @return {*}
9725
+ */
9726
+ __publicField(this, "progressDotMouseMove", (e) => {
9727
+ this.showControllerBar(e);
9728
+ if (!this.moveProgress.mouseDown)
9729
+ return;
9730
+ const rect = this._progress.getBoundingClientRect();
9731
+ const offsetX = e.clientX - rect.left - 9;
9732
+ const percentage = range(offsetX / this._progress.offsetWidth);
9733
+ this._progressWrapValue.style.setProperty("transform", `scaleX(${percentage})`);
9734
+ this._progressDot.style.setProperty("transform", `translateX(${percentage * this._progress.offsetWidth}px)`);
9735
+ this.moveProgress.percentage = Math.floor(percentage * 100) / 100;
9736
+ });
9737
+ /**
9738
+ * @description: 进度条鼠标松开事件
9739
+ * @param {MouseEvent} e
9740
+ * @return {*}
9741
+ */
9742
+ __publicField(this, "progressDotMouseUp", () => {
9743
+ if (!this.moveProgress.mouseDown)
9744
+ return;
9745
+ const percentage = this.moveProgress.percentage;
9746
+ this.setCurrentTime(this.ctx.duration * percentage);
9747
+ this.play();
9748
+ this.moveProgress.mouseDown = false;
9749
+ this.requestAnimationFrame(this.updateCurrentProgress);
9750
+ });
9751
+ /**
9752
+ * @description: 更新页面样式
9753
+ * @param {Function} fn
9754
+ * @return {*}
9755
+ */
9756
+ __publicField(this, "requestAnimationFrame", (fn) => {
9757
+ if (this.requestAnimationFrameId)
9758
+ return;
9759
+ this.requestAnimationFrameId = window.requestAnimationFrame(() => {
9760
+ fn();
9761
+ this.requestAnimationFrameId && cancelAnimationFrame(this.requestAnimationFrameId);
9762
+ this.requestAnimationFrameId = void 0;
9763
+ this.requestAnimationFrame(fn);
9764
+ });
9765
+ });
9766
+ /**
9767
+ * @description: 取消页面动画
9768
+ * @param {Function} fn
9769
+ * @return {*}
9770
+ */
9771
+ __publicField(this, "cancelAnimationFrame", () => {
9772
+ if (!this.requestAnimationFrameId)
9773
+ return;
9774
+ cancelAnimationFrame(this.requestAnimationFrameId);
9775
+ this.requestAnimationFrameId = void 0;
9776
+ });
9777
+ /**
9778
+ * @description: 更新进度条
9779
+ * @param {*} void
9780
+ * @return {*}
9781
+ */
9782
+ __publicField(this, "updateCurrentProgress", () => {
9783
+ const currentTime = this.getCurrentTime();
9784
+ this.ctx.currentTime = currentTime;
9785
+ const { duration } = this.ctx;
9786
+ this._progressWrapValue.style.setProperty("transform", `scaleX(${currentTime / duration})`);
9787
+ this._progressDot.style.setProperty(
9788
+ "transform",
9789
+ `translateX(${currentTime / duration * this._progress.offsetWidth}px)`
9790
+ );
9791
+ if (currentTime >= 0) {
9792
+ this._playerControllerBottomTimeCurrent.innerText = timeFormat(currentTime);
9793
+ }
9794
+ });
9795
+ __publicField(this, "changeAttribute", (k, o, n, attribute, callback) => {
9796
+ if (k === attribute && o !== n)
9797
+ throttle(callback)();
9798
+ });
9799
+ /**
9800
+ * @description: 点击整个视频时,触发的事件
9801
+ * @param {*} void
9802
+ * @return {*}
9803
+ */
9804
+ __publicField(this, "dispatchClickPlayerContainerAction", (e) => {
9805
+ e.stopPropagation();
9806
+ e.preventDefault();
9807
+ if (PLAY_STATE_LIST.includes(this.ctx.currentState)) {
9808
+ this.pause();
9809
+ this._playerBtn.style.setProperty("display", "block");
9810
+ } else {
9811
+ this.play();
9812
+ this._playerBtn.style.setProperty("display", "none");
9813
+ }
9814
+ });
9815
+ /**
9816
+ * @description: 空格事件
9817
+ * @param {KeyboardEvent} e
9818
+ * @return {*}
9819
+ */
9820
+ __publicField(this, "SpaceKeyDown", (e) => {
9821
+ const { currentTime, duration } = this.ctx;
9822
+ if (e.code === "Space") {
9823
+ this.dispatchClickPlayerBtnAction(e);
9824
+ }
9825
+ if (e.code === "Escape") {
9826
+ this.customExitFullscreen().then(() => {
9827
+ this.ctx.fullScreen = false;
9828
+ }).catch((error) => {
9624
9829
  });
9625
- __publicField(this, "clearListenerEvent", () => {
9626
- if (!this._video)
9627
- return;
9628
- this._video.removeEventListener("canplay", this.onCanplay);
9629
- this._video.removeEventListener(
9630
- "canplaythrough",
9631
- this.onCanplaythrough
9632
- );
9633
- this._video.removeEventListener("complete", this.onComplete);
9634
- this._video.removeEventListener(
9635
- "durationchange",
9636
- this.onDurationchange
9637
- );
9638
- this._video.removeEventListener("emptied", this.onEmptied);
9639
- this._video.removeEventListener("ended", this.onEnded);
9640
- this._video.removeEventListener("error", this.onError);
9641
- this._video.removeEventListener("loadeddata", this.onLoadeddata);
9642
- this._video.removeEventListener(
9643
- "loadedmetadata",
9644
- this.onLoadedmetadata
9645
- );
9646
- this._video.removeEventListener("loadstart", this.onLoadstart);
9647
- this._video.removeEventListener("pause", this.onPause);
9648
- this._video.removeEventListener("play", this.onPlay);
9649
- this._video.removeEventListener("playing", this.onPlaying);
9650
- this._video.removeEventListener("progress", this.onProgress);
9651
- this._video.removeEventListener("ratechange", this.onRatechange);
9652
- this._video.removeEventListener("seeked", this.onSeeked);
9653
- this._video.removeEventListener("seeking", this.onSeeking);
9654
- this._video.removeEventListener("stalled", this.onStalled);
9655
- this._video.removeEventListener("suspend", this.onSuspend);
9656
- this._video.removeEventListener("timeupdate", this.onTimeupdate);
9657
- this._video.removeEventListener("volumechange", this.onVolumechange);
9658
- this._video.removeEventListener("waiting", this.onWaiting);
9659
- });
9660
- /**
9661
- * @description: 用户行为和 video 之间的交互
9662
- * @return {*}
9663
- */
9664
- __publicField(this, "listenEvent", () => {
9665
- if (!this._video)
9666
- return;
9667
- this.clearListenerEvent();
9668
- this._video.addEventListener("canplay", this.onCanplay);
9669
- this._video.addEventListener("canplaythrough", this.onCanplaythrough);
9670
- this._video.addEventListener("complete", this.onComplete);
9671
- this._video.addEventListener("durationchange", this.onDurationchange);
9672
- this._video.addEventListener("emptied", this.onEmptied);
9673
- this._video.addEventListener("ended", this.onEnded);
9674
- this._video.addEventListener("error", this.onError);
9675
- this._video.addEventListener("loadeddata", this.onLoadeddata);
9676
- this._video.addEventListener("loadedmetadata", this.onLoadedmetadata);
9677
- this._video.addEventListener("loadstart", this.onLoadstart);
9678
- this._video.addEventListener("pause", this.onPause);
9679
- this._video.addEventListener("play", this.onPlay);
9680
- this._video.addEventListener("playing", this.onPlaying);
9681
- this._video.addEventListener("progress", this.onProgress);
9682
- this._video.addEventListener("ratechange", this.onRatechange);
9683
- this._video.addEventListener("seeked", this.onSeeked);
9684
- this._video.addEventListener("seeking", this.onSeeking);
9685
- this._video.addEventListener("stalled", this.onStalled);
9686
- this._video.addEventListener("suspend", this.onSuspend);
9687
- this._video.addEventListener("timeupdate", this.onTimeupdate);
9688
- this._video.addEventListener("volumechange", this.onVolumechange);
9689
- this._video.addEventListener("waiting", this.onWaiting);
9690
- });
9691
- __publicField(this, "showControllerBar", (e) => {
9692
- if (e) {
9693
- const dom = e.target;
9694
- if (dom.classList.value.includes("ran-player-controller")) {
9695
- this._playerController.style.setProperty("opacity", "1");
9696
- if (this.controllerBarTimeId) {
9697
- clearTimeout(this.controllerBarTimeId);
9698
- this.controllerBarTimeId = void 0;
9699
- }
9700
- return;
9701
- }
9702
- }
9703
- if (PLAY_STATE_LIST.includes(this.ctx.currentState)) {
9704
- this._playerController.style.setProperty("opacity", "1");
9705
- if (this.controllerBarTimeId) {
9706
- clearTimeout(this.controllerBarTimeId);
9707
- this.controllerBarTimeId = void 0;
9708
- }
9709
- this.controllerBarTimeId = setTimeout(() => {
9710
- this._playerController.style.setProperty("opacity", "0");
9711
- clearTimeout(this.controllerBarTimeId);
9712
- this.controllerBarTimeId = void 0;
9713
- }, 2e3);
9714
- } else {
9715
- this._playerController.style.setProperty("opacity", "1");
9716
- if (this.controllerBarTimeId) {
9717
- clearTimeout(this.controllerBarTimeId);
9718
- this.controllerBarTimeId = void 0;
9719
- }
9720
- }
9721
- });
9722
- /**
9723
- * @description: 进度条点击事件
9724
- * @param {MouseEvent} e
9725
- * @return {*}
9726
- */
9727
- __publicField(this, "progressClick", (e) => {
9728
- const rect = this._progressWrap.getBoundingClientRect();
9729
- const offsetX = e.clientX - rect.left;
9730
- const percentage = range(offsetX / this._progress.offsetWidth);
9731
- this.setCurrentTime(this.ctx.duration * percentage);
9732
- this.updateCurrentProgress();
9733
- });
9734
- /**
9735
- * @description: 进度条鼠标按下事件
9736
- * @param {MouseEvent} e
9737
- * @return {*}
9738
- */
9739
- __publicField(this, "progressDotMouseDown", (e) => {
9740
- this._playerBtn.style.setProperty("display", "none");
9741
- this.moveProgress.mouseDown = true;
9742
- this.cancelAnimationFrame();
9743
- });
9744
- /**
9745
- * @description: 进度条鼠标移动事件
9746
- * @param {MouseEvent} e
9747
- * @return {*}
9748
- */
9749
- __publicField(this, "progressDotMouseMove", (e) => {
9750
- this.showControllerBar(e);
9751
- if (!this.moveProgress.mouseDown)
9752
- return;
9753
- const rect = this._progress.getBoundingClientRect();
9754
- const offsetX = e.clientX - rect.left - 9;
9755
- const percentage = range(offsetX / this._progress.offsetWidth);
9756
- this._progressWrapValue.style.setProperty(
9757
- "transform",
9758
- `scaleX(${percentage})`
9759
- );
9760
- this._progressDot.style.setProperty(
9761
- "transform",
9762
- `translateX(${percentage * this._progress.offsetWidth}px)`
9763
- );
9764
- this.moveProgress.percentage = Math.floor(percentage * 100) / 100;
9765
- });
9766
- /**
9767
- * @description: 进度条鼠标松开事件
9768
- * @param {MouseEvent} e
9769
- * @return {*}
9770
- */
9771
- __publicField(this, "progressDotMouseUp", () => {
9772
- if (!this.moveProgress.mouseDown)
9773
- return;
9774
- const percentage = this.moveProgress.percentage;
9775
- this.setCurrentTime(this.ctx.duration * percentage);
9776
- this.play();
9777
- this.moveProgress.mouseDown = false;
9778
- this.requestAnimationFrame(this.updateCurrentProgress);
9779
- });
9780
- /**
9781
- * @description: 更新页面样式
9782
- * @param {Function} fn
9783
- * @return {*}
9784
- */
9785
- __publicField(this, "requestAnimationFrame", (fn) => {
9786
- if (this.requestAnimationFrameId)
9787
- return;
9788
- this.requestAnimationFrameId = window.requestAnimationFrame(() => {
9789
- fn();
9790
- this.requestAnimationFrameId && cancelAnimationFrame(this.requestAnimationFrameId);
9791
- this.requestAnimationFrameId = void 0;
9792
- this.requestAnimationFrame(fn);
9793
- });
9794
- });
9795
- /**
9796
- * @description: 取消页面动画
9797
- * @param {Function} fn
9798
- * @return {*}
9799
- */
9800
- __publicField(this, "cancelAnimationFrame", () => {
9801
- if (!this.requestAnimationFrameId)
9802
- return;
9803
- cancelAnimationFrame(this.requestAnimationFrameId);
9804
- this.requestAnimationFrameId = void 0;
9805
- });
9806
- /**
9807
- * @description: 更新进度条
9808
- * @param {*} void
9809
- * @return {*}
9810
- */
9811
- __publicField(this, "updateCurrentProgress", () => {
9812
- const currentTime = this.getCurrentTime();
9813
- this.ctx.currentTime = currentTime;
9814
- const { duration } = this.ctx;
9815
- this._progressWrapValue.style.setProperty(
9816
- "transform",
9817
- `scaleX(${currentTime / duration})`
9818
- );
9819
- this._progressDot.style.setProperty(
9820
- "transform",
9821
- `translateX(${currentTime / duration * this._progress.offsetWidth}px)`
9822
- );
9823
- if (currentTime >= 0) {
9824
- this._playerControllerBottomTimeCurrent.innerText = timeFormat(currentTime);
9825
- }
9826
- });
9827
- __publicField(this, "changeAttribute", (k, o, n, attribute, callback) => {
9828
- if (k === attribute && o !== n)
9829
- throttle$1(callback)();
9830
- });
9831
- /**
9832
- * @description: 点击整个视频时,触发的事件
9833
- * @param {*} void
9834
- * @return {*}
9835
- */
9836
- __publicField(this, "dispatchClickPlayerContainerAction", (e) => {
9837
- e.stopPropagation();
9838
- e.preventDefault();
9839
- if (PLAY_STATE_LIST.includes(this.ctx.currentState)) {
9840
- this.pause();
9841
- this._playerBtn.style.setProperty("display", "block");
9842
- } else {
9843
- this.play();
9844
- this._playerBtn.style.setProperty("display", "none");
9845
- }
9846
- });
9847
- /**
9848
- * @description: 空格事件
9849
- * @param {KeyboardEvent} e
9850
- * @return {*}
9851
- */
9852
- __publicField(this, "SpaceKeyDown", (e) => {
9853
- e.stopPropagation();
9854
- e.preventDefault();
9855
- const { currentTime, duration } = this.ctx;
9856
- if (e.code === "Space") {
9857
- this.dispatchClickPlayerBtnAction(e);
9858
- }
9859
- if (e.code === "Escape") {
9860
- document.exitFullscreen().then(() => {
9861
- this.ctx.fullScreen = false;
9862
- }).catch((error) => {
9863
- });
9864
- }
9865
- if (e.code === "ArrowLeft") {
9866
- const time = range(currentTime - 5, 0, duration);
9867
- this.setCurrentTime(time);
9868
- this.play();
9869
- }
9870
- if (e.code === "ArrowRight") {
9871
- const time = range(currentTime + 5, 0, duration);
9872
- this.setCurrentTime(time);
9873
- this.play();
9874
- }
9875
- });
9876
- /**
9877
- * @description: 点击player-btn,触发的事件
9878
- * @param {*} void
9879
- * @return {*}
9880
- */
9881
- __publicField(this, "dispatchClickPlayerBtnAction", (e) => {
9882
- e.stopPropagation();
9883
- e.preventDefault();
9884
- if (PLAY_STATE_LIST.includes(this.ctx.currentState)) {
9885
- this.pause();
9886
- this._playerBtn.style.setProperty("display", "block");
9887
- } else {
9888
- this.play();
9889
- this._playerBtn.style.setProperty("display", "none");
9890
- }
9891
- });
9892
- __publicField(this, "changeVolumeProgress", (e) => {
9893
- if (this._video) {
9894
- this.setVolume(e.detail.value);
9895
- this.change("volume", e.detail.value);
9896
- if (e.detail.value > 0) {
9897
- this._volume = e.detail.value;
9898
- }
9899
- }
9900
- });
9901
- __publicField(this, "openFullScreen", () => {
9902
- if (!this.ctx.fullScreen) {
9903
- this._player.requestFullscreen().then(() => {
9904
- this.resize();
9905
- this.ctx.fullScreen = true;
9906
- }).catch((error) => {
9907
- });
9908
- } else {
9909
- document.exitFullscreen().then(() => {
9910
- this.resize();
9911
- this.ctx.fullScreen = false;
9912
- }).catch((error) => {
9913
- });
9914
- }
9915
- });
9916
- __publicField(this, "changeSpeed", (e) => {
9917
- this.change("speed", e.detail.value);
9918
- this.setPlaybackRate(e.detail.value);
9919
- });
9920
- __publicField(this, "progressMouseEnter", (e) => {
9921
- this._playerTip.style.setProperty("opacity", "1");
9922
- const rect = this._progress.getBoundingClientRect();
9923
- const offsetX = e.clientX - rect.left;
9924
- if (this._playerTipText.innerText) {
9925
- this._playerTip.style.setProperty(
9926
- "transform",
9927
- `translate(calc(${offsetX}px - 50%),-20px)`
9928
- );
9929
- } else {
9930
- this._playerTip.style.setProperty(
9931
- "transform",
9932
- `translateX(calc(${offsetX}px - 50%))`
9933
- );
9934
- }
9935
- this._playerTipTime.innerText = timeFormat(
9936
- offsetX / this._progress.clientWidth * this.ctx.duration
9937
- );
9938
- });
9939
- __publicField(this, "progressMouseLeave", (e) => {
9940
- if (e.target.classList.contains(
9941
- "ran-player-controller-progress-wrap-dot"
9942
- )) {
9943
- return;
9944
- }
9945
- this._playerTip.style.setProperty("opacity", "0");
9946
- });
9947
- __publicField(this, "progressMouseMove", (e) => {
9948
- const rect = this._progress.getBoundingClientRect();
9949
- this._playerTip.style.setProperty("opacity", "1");
9950
- const offsetX = e.clientX - rect.left;
9951
- if (this._playerTipText.innerText) {
9952
- this._playerTip.style.setProperty(
9953
- "transform",
9954
- `translate(calc(${offsetX}px - 50%),-20px)`
9955
- );
9956
- } else {
9957
- this._playerTip.style.setProperty(
9958
- "transform",
9959
- `translateX(calc(${offsetX}px - 50%))`
9960
- );
9961
- }
9962
- this._playerTipTime.innerText = timeFormat(
9963
- offsetX / this._progress.clientWidth * this.ctx.duration
9964
- );
9965
- });
9966
- __publicField(this, "changePlayerVolume", () => {
9967
- if (!this._video)
9968
- return;
9969
- const { volume } = this.ctx;
9970
- if (volume > 0) {
9971
- addClassToElement(
9972
- this._playControllerBottomSpeedIcon,
9973
- "ran-player-controller-bottom-right-volume-icon-mute"
9974
- );
9975
- removeClassToElement(
9976
- this._playControllerBottomSpeedIcon,
9977
- "ran-player-controller-bottom-right-volume-icon-volume"
9978
- );
9979
- this._playControllerBottomVolumeProgress.setAttribute("percent", "0");
9980
- this.setVolume(0);
9981
- this.change("volume", 0);
9982
- } else {
9983
- addClassToElement(
9984
- this._playControllerBottomSpeedIcon,
9985
- "ran-player-controller-bottom-right-volume-icon-volume"
9986
- );
9987
- removeClassToElement(
9988
- this._playControllerBottomSpeedIcon,
9989
- "ran-player-controller-bottom-right-volume-icon-mute"
9990
- );
9991
- this._playControllerBottomVolumeProgress.setAttribute(
9992
- "percent",
9993
- `${this._volume || 0.5}`
9994
- );
9995
- this.setVolume(0.5);
9996
- this.change("volume", this._volume || 0.5);
9997
- }
9998
- });
9999
- __publicField(this, "resize", () => {
10000
- if (this._video) {
10001
- const { width, height } = this._player.getBoundingClientRect();
10002
- this._video.style.setProperty("width", `${width}px`);
10003
- this._video.style.setProperty("height", `${height}px`);
10004
- }
10005
- this.updateCurrentProgress();
10006
- });
10007
- __publicField(this, "fullScreenChange", () => {
10008
- var _a;
10009
- if ((_a = document.fullscreenElement) == null ? void 0 : _a.classList.contains("ran-player")) {
10010
- this.change("fullscreen", true);
10011
- this.ctx.fullScreen = true;
10012
- } else {
10013
- this.change("fullscreen", false);
10014
- this.ctx.fullScreen = false;
10015
- }
10016
- });
10017
- __publicField(this, "getPlaybackRate", () => {
10018
- if (this._video) {
10019
- this.ctx.playbackRate = this._video.playbackRate || 0;
10020
- }
10021
- return this.ctx.playbackRate;
10022
- });
10023
- __publicField(this, "setPlaybackRate", (n) => {
10024
- if (this._video) {
10025
- this.ctx.playbackRate = n;
10026
- this._video.playbackRate = n;
10027
- }
10028
- return this.ctx.playbackRate;
10029
- });
10030
- __publicField(this, "setVolume", (n) => {
10031
- if (this._video) {
10032
- this.ctx.volume = n;
10033
- this._video.volume = n;
10034
- }
10035
- return this.ctx.volume;
10036
- });
10037
- __publicField(this, "getVolume", () => {
10038
- if (this._video) {
10039
- this.ctx.volume = this._video.volume || 0;
10040
- }
10041
- return this.ctx.volume;
10042
- });
10043
- __publicField(this, "setCurrentTime", (n) => {
10044
- if (this._video) {
10045
- this.ctx.currentTime = n;
10046
- this._video.currentTime = n;
10047
- }
10048
- return this.ctx.currentTime;
10049
- });
10050
- __publicField(this, "getCurrentTime", () => {
10051
- if (this._video) {
10052
- this.ctx.currentTime = this._video.currentTime || 0;
10053
- }
10054
- return this.ctx.currentTime;
10055
- });
10056
- __publicField(this, "getTotalTime", () => {
10057
- if (this._video) {
10058
- this.ctx.duration = this._video.duration || 0;
10059
- }
10060
- return this.ctx.duration;
10061
- });
10062
- __publicField(this, "play", (n) => {
10063
- if (this._video) {
10064
- if (n !== void 0 && n >= 0) {
10065
- this.ctx.currentTime = n;
10066
- this._video.currentTime = n;
10067
- }
10068
- this._video.play();
10069
- }
10070
- });
10071
- __publicField(this, "pause", () => {
10072
- if (this._video) {
10073
- this._video.pause();
10074
- }
9830
+ }
9831
+ if (e.code === "ArrowLeft") {
9832
+ const time = range(currentTime - 5, 0, duration);
9833
+ this.setCurrentTime(time);
9834
+ this.play();
9835
+ }
9836
+ if (e.code === "ArrowRight") {
9837
+ const time = range(currentTime + 5, 0, duration);
9838
+ this.setCurrentTime(time);
9839
+ this.play();
9840
+ }
9841
+ });
9842
+ /**
9843
+ * @description: 点击 player-btn,触发的事件
9844
+ * @param {*} void
9845
+ * @return {*}
9846
+ */
9847
+ __publicField(this, "dispatchClickPlayerBtnAction", (e) => {
9848
+ e.stopPropagation();
9849
+ e.preventDefault();
9850
+ if (PLAY_STATE_LIST.includes(this.ctx.currentState)) {
9851
+ this.pause();
9852
+ this._playerBtn.style.setProperty("display", "block");
9853
+ } else {
9854
+ this.play();
9855
+ this._playerBtn.style.setProperty("display", "none");
9856
+ }
9857
+ });
9858
+ __publicField(this, "changeVolumeProgress", (e) => {
9859
+ if (this._video) {
9860
+ this.setVolume(e.detail.value);
9861
+ this.change("volume", e.detail.value);
9862
+ if (e.detail.value > 0) {
9863
+ this._volume = e.detail.value;
9864
+ }
9865
+ }
9866
+ });
9867
+ __publicField(this, "customRequestFullscreen", (options) => {
9868
+ return this._player.requestFullscreen() || this._player.mozRequestFullScreen() || this._player.msRequestFullscreen() || this._player.oRequestFullscreen() || this._player.webkitRequestFullscreen() || this._player.webkitEnterFullscreen();
9869
+ });
9870
+ __publicField(this, "customExitFullscreen", () => {
9871
+ return document.exitFullscreen() || document.msExitFullscreen() || document.mozCancelFullScreen() || document.oCancelFullScreen() || document.webkitExitFullscreen();
9872
+ });
9873
+ __publicField(this, "openFullScreen", () => {
9874
+ if (!this.ctx.fullScreen) {
9875
+ this.customRequestFullscreen().then(() => {
9876
+ this.resize();
9877
+ this.ctx.fullScreen = true;
9878
+ }).catch((error) => {
10075
9879
  });
10076
- this._player = document.createElement("div");
10077
- this._container = document.createElement("div");
10078
- this._slot = document.createElement("slot");
10079
- this._playerBtn = document.createElement("div");
10080
- this._progress = document.createElement("div");
10081
- this._progressWrap = document.createElement("div");
10082
- this._progressWrapValue = document.createElement("div");
10083
- this._progressDot = document.createElement("div");
10084
- this._playerControllerBottom = document.createElement("div");
10085
- this._playerControllerBottomRight = document.createElement("div");
10086
- this._playerControllerBottomLeft = document.createElement("div");
10087
- this._player.setAttribute("class", "ran-player");
10088
- this._player.setAttribute(
10089
- "id",
10090
- "ran-player" + `${performance.now()}`.replace(".", "")
10091
- );
10092
- this._playerBtn.setAttribute("class", "ran-player-play-btn");
10093
- this._progress.setAttribute("class", "ran-player-controller-progress");
10094
- this._progressWrap.setAttribute(
10095
- "class",
10096
- "ran-player-controller-progress-wrap"
10097
- );
10098
- this._progressWrapValue.setAttribute(
10099
- "class",
10100
- "ran-player-controller-progress-wrap-value"
10101
- );
10102
- this._progressDot.setAttribute(
10103
- "class",
10104
- "ran-player-controller-progress-dot"
10105
- );
10106
- this._playerControllerBottom.setAttribute(
10107
- "class",
10108
- "ran-player-controller-bottom"
10109
- );
10110
- this._playerControllerBottomRight.setAttribute(
10111
- "class",
10112
- "ran-player-controller-bottom-right"
10113
- );
10114
- this._playerControllerBottomLeft.setAttribute(
10115
- "class",
10116
- "ran-player-controller-bottom-left"
10117
- );
10118
- this._playerControllerBottomPlayBtn = document.createElement("div");
10119
- this._playerControllerBottomPlayBtn.setAttribute(
10120
- "class",
10121
- "ran-player-controller-bottom-left-btn"
10122
- );
10123
- this._playerControllerBottomTimeCurrent = document.createElement("div");
10124
- this._playerControllerBottomTimeCurrent.setAttribute(
10125
- "class",
10126
- "ran-player-controller-bottom-left-time-current"
10127
- );
10128
- this._playerControllerBottomTimeDivide = document.createElement("div");
10129
- this._playerControllerBottomTimeDivide.setAttribute(
10130
- "class",
10131
- "ran-player-controller-bottom-left-time-divide"
10132
- );
10133
- this._playerControllerBottomTimeDuration = document.createElement("div");
10134
- this._playerControllerBottomTimeDuration.setAttribute(
10135
- "class",
10136
- "ran-player-controller-bottom-left-time-duration"
10137
- );
10138
- this._playControllerBottomSpeed = document.createElement("div");
10139
- this._playControllerBottomSpeed.setAttribute(
10140
- "class",
10141
- "ran-player-controller-bottom-right-speed"
10142
- );
10143
- this._playControllerBottomSpeedPopover = document.createElement("r-select");
10144
- this._playControllerBottomSpeedPopover.setAttribute("value", "1");
10145
- this._playControllerBottomSpeedPopover.setAttribute(
10146
- "action",
10147
- "hover,click"
10148
- );
10149
- this._playControllerBottomSpeedPopover.setAttribute("type", "text");
10150
- this._playControllerBottomSpeedPopover.setAttribute("placement", "top");
10151
- const id = this._player.getAttribute("id");
10152
- id && this._playControllerBottomSpeedPopover.setAttribute(
10153
- "getPopupContainerId",
10154
- id
10155
- );
10156
- this._playControllerBottomSpeedPopover.setAttribute(
10157
- "dropdownclass",
10158
- "video-speed-dropdown"
10159
- );
10160
- this._playControllerBottomSpeedPopover.addEventListener(
10161
- "change",
10162
- this.changeSpeed
10163
- );
10164
- const Fragment = document.createDocumentFragment();
10165
- SPEED.forEach((item) => {
10166
- const { label, value } = item;
10167
- const option = document.createElement("r-option");
10168
- option.innerHTML = label;
10169
- option.setAttribute("value", `${value}`);
10170
- Fragment.appendChild(option);
9880
+ } else {
9881
+ this.customExitFullscreen().then(() => {
9882
+ this.resize();
9883
+ this.ctx.fullScreen = false;
9884
+ }).catch((error) => {
10171
9885
  });
10172
- this._playControllerBottomSpeedPopover.appendChild(Fragment);
10173
- this._playControllerBottomSpeed.appendChild(
10174
- this._playControllerBottomSpeedPopover
10175
- );
10176
- this._playControllerBottomVolume = document.createElement("div");
10177
- this._playControllerBottomVolume.setAttribute(
10178
- "class",
10179
- "ran-player-controller-bottom-right-volume"
10180
- );
10181
- this._playControllerBottomVolumeProgress = document.createElement("r-progress");
10182
- this._playControllerBottomVolumeProgress.setAttribute(
10183
- "class",
10184
- "ran-player-controller-bottom-right-volume-progress"
10185
- );
10186
- this._playControllerBottomVolumeProgress.setAttribute("percent", "0.5");
10187
- this._playControllerBottomVolumeProgress.setAttribute("type", "drag");
10188
- this._playControllerBottomSpeedIcon = document.createElement("div");
10189
- this._playControllerBottomSpeedIcon.setAttribute(
10190
- "class",
10191
- "ran-player-controller-bottom-right-volume-icon ran-player-controller-bottom-right-volume-icon-volume"
10192
- );
10193
- this._playControllerBottomClarity = document.createElement("div");
10194
- this._playControllerBottomClarity.setAttribute(
10195
- "class",
10196
- "ran-player-controller-bottom-right-clarity"
10197
- );
10198
- this._playControllerBottomRightFullScreen = document.createElement("div");
10199
- this._playControllerBottomRightFullScreen.setAttribute(
10200
- "class",
10201
- "ran-player-controller-bottom-right-full"
10202
- );
10203
- this._playerController = document.createElement("div");
10204
- this._playerController.setAttribute("class", "ran-player-controller");
10205
- this._playerTip = document.createElement("div");
10206
- this._playerTip.setAttribute("class", "ran-player-controller-tip");
10207
- this._playerTipTime = document.createElement("div");
10208
- this._playerTipTime.setAttribute(
10209
- "class",
10210
- "ran-player-controller-tip-time"
10211
- );
10212
- this._playerTipText = document.createElement("div");
10213
- this._playerTipText.setAttribute(
10214
- "class",
10215
- "ran-player-controller-tip-text"
10216
- );
10217
- this._playerTip.appendChild(
10218
- createDocumentFragment([this._playerTipTime, this._playerTipText])
10219
- );
10220
- this._playerController.appendChild(
10221
- createDocumentFragment([
10222
- this._playerTip,
10223
- this._progress,
10224
- this._playerControllerBottom
10225
- ])
10226
- );
10227
- this._player.appendChild(
10228
- createDocumentFragment([
10229
- this._container,
10230
- this._slot,
10231
- this._playerBtn,
10232
- this._playerController
10233
- ])
10234
- );
10235
- this._progressWrap.appendChild(this._progressWrapValue);
10236
- this._progress.appendChild(
10237
- createDocumentFragment([this._progressWrap, this._progressDot])
10238
- );
10239
- this._playerControllerBottom.appendChild(
10240
- createDocumentFragment([
10241
- this._playerControllerBottomLeft,
10242
- this._playerControllerBottomRight
10243
- ])
10244
- );
10245
- this._playerControllerBottomLeft.appendChild(
10246
- createDocumentFragment([
10247
- this._playerControllerBottomPlayBtn,
10248
- this._playerControllerBottomTimeCurrent,
10249
- this._playerControllerBottomTimeDivide,
10250
- this._playerControllerBottomTimeDuration
10251
- ])
10252
- );
10253
- this._playControllerBottomVolume.appendChild(
10254
- createDocumentFragment([
10255
- this._playControllerBottomSpeedIcon,
10256
- this._playControllerBottomVolumeProgress
10257
- ])
10258
- );
10259
- this._playerControllerBottomRight.appendChild(
10260
- createDocumentFragment([
10261
- this._playControllerBottomClarity,
10262
- this._playControllerBottomSpeed,
10263
- this._playControllerBottomVolume,
10264
- this._playControllerBottomRightFullScreen
10265
- ])
10266
- );
10267
- this.ctx = {
10268
- currentTime: 0,
10269
- // 当前时间
10270
- duration: 0,
10271
- // 总时长
10272
- currentState: "",
10273
- // 当前视频状态
10274
- action: new SyncHook(),
10275
- // 不同时期触发的状态
10276
- volume: 0.5,
10277
- // 当前音量
10278
- playbackRate: 1,
10279
- // 当前倍速
10280
- clarity: "",
10281
- // 当前清晰度
10282
- fullScreen: false,
10283
- // 是否全屏
10284
- levels: [],
10285
- // 清晰度列表
10286
- url: "",
10287
- // 当前播放的地址
10288
- levelMap: /* @__PURE__ */ new Map()
10289
- // 清晰度和名字的映射关系
10290
- };
10291
- this.moveProgress = {
10292
- percentage: 0,
10293
- mouseDown: false
10294
- };
10295
- }
10296
- static get observedAttributes() {
10297
- return ["src", "volume", "currentTime", "playbackRate"];
10298
- }
10299
- get src() {
10300
- return this.getAttribute("src") || "";
10301
- }
10302
- set src(value) {
10303
- this.setAttribute("src", value || "");
10304
- }
10305
- get volume() {
10306
- return this.getAttribute("volume") || "";
10307
- }
10308
- set volume(value) {
10309
- this.setAttribute("volume", value || "");
10310
- }
10311
- get currentTime() {
10312
- return this.getAttribute("currentTime") || "";
10313
- }
10314
- set currentTime(value) {
10315
- this.setAttribute("currentTime", value || "");
10316
- }
10317
- get playbackRate() {
10318
- return this.getAttribute("playbackRate") || "";
10319
9886
  }
10320
- set playbackRate(value) {
10321
- this.setAttribute("playbackRate", value || "");
10322
- }
10323
- connectedCallback() {
10324
- this._container.addEventListener(
10325
- "click",
10326
- this.dispatchClickPlayerContainerAction
10327
- );
10328
- this._playerBtn.addEventListener(
10329
- "click",
10330
- this.dispatchClickPlayerBtnAction
10331
- );
10332
- document.body.addEventListener("keydown", this.SpaceKeyDown);
10333
- this._progressDot.addEventListener(
10334
- "mousedown",
10335
- this.progressDotMouseDown
10336
- );
10337
- this._playerControllerBottomPlayBtn.addEventListener(
10338
- "click",
10339
- this.dispatchClickPlayerBtnAction
10340
- );
10341
- this._progress.addEventListener("click", this.progressClick);
10342
- this._progress.addEventListener("mouseenter", this.progressMouseEnter);
10343
- this._progress.addEventListener("mousemove", this.progressMouseMove);
10344
- this._progress.addEventListener("mouseleave", this.progressMouseLeave);
10345
- this._player.addEventListener("mousemove", this.progressDotMouseMove);
10346
- this._player.addEventListener("mouseup", this.progressDotMouseUp);
10347
- this._playControllerBottomVolumeProgress.addEventListener(
10348
- "change",
10349
- this.changeVolumeProgress
10350
- );
10351
- this._playControllerBottomRightFullScreen.addEventListener(
10352
- "click",
10353
- this.openFullScreen
10354
- );
10355
- this._playControllerBottomSpeedIcon.addEventListener(
10356
- "click",
10357
- this.changePlayerVolume
10358
- );
10359
- document.addEventListener("fullscreenchange", this.fullScreenChange);
10360
- window.addEventListener("resize", this.resize);
10361
- this.updatePlayer();
10362
- }
10363
- disconnectCallback() {
10364
- this._container.removeEventListener(
10365
- "click",
10366
- this.dispatchClickPlayerContainerAction
10367
- );
10368
- this._playerBtn.removeEventListener(
10369
- "click",
10370
- this.dispatchClickPlayerBtnAction
10371
- );
10372
- this._playerControllerBottomPlayBtn.removeEventListener(
10373
- "click",
10374
- this.dispatchClickPlayerBtnAction
10375
- );
10376
- this.cancelAnimationFrame();
10377
- document.removeEventListener("keydown", this.SpaceKeyDown);
10378
- this._progress.removeEventListener("click", this.progressClick);
10379
- this._progress.removeEventListener(
10380
- "mouseenter",
10381
- this.progressMouseEnter
10382
- );
10383
- this._progress.removeEventListener("mousemove", this.progressMouseMove);
10384
- this._progress.removeEventListener(
10385
- "mouseleave",
10386
- this.progressMouseLeave
10387
- );
10388
- this._progressDot.removeEventListener(
10389
- "mousedown",
10390
- this.progressDotMouseDown
9887
+ });
9888
+ __publicField(this, "changeSpeed", (e) => {
9889
+ this.change("speed", e.detail.value);
9890
+ this.setPlaybackRate(e.detail.value);
9891
+ });
9892
+ __publicField(this, "progressMouseEnter", (e) => {
9893
+ this._playerTip.style.setProperty("opacity", "1");
9894
+ const rect = this._progress.getBoundingClientRect();
9895
+ const offsetX = e.clientX - rect.left;
9896
+ if (this._playerTipText.innerText) {
9897
+ this._playerTip.style.setProperty("transform", `translate(calc(${offsetX}px - 50%),-20px)`);
9898
+ } else {
9899
+ this._playerTip.style.setProperty("transform", `translateX(calc(${offsetX}px - 50%))`);
9900
+ }
9901
+ this._playerTipTime.innerText = timeFormat(offsetX / this._progress.clientWidth * this.ctx.duration);
9902
+ });
9903
+ __publicField(this, "progressMouseLeave", (e) => {
9904
+ if (e.target.classList.contains("ran-player-controller-progress-wrap-dot")) {
9905
+ return;
9906
+ }
9907
+ this._playerTip.style.setProperty("opacity", "0");
9908
+ });
9909
+ __publicField(this, "progressMouseMove", (e) => {
9910
+ const rect = this._progress.getBoundingClientRect();
9911
+ this._playerTip.style.setProperty("opacity", "1");
9912
+ const offsetX = e.clientX - rect.left;
9913
+ if (this._playerTipText.innerText) {
9914
+ this._playerTip.style.setProperty("transform", `translate(calc(${offsetX}px - 50%),-20px)`);
9915
+ } else {
9916
+ this._playerTip.style.setProperty("transform", `translateX(calc(${offsetX}px - 50%))`);
9917
+ }
9918
+ this._playerTipTime.innerText = timeFormat(offsetX / this._progress.clientWidth * this.ctx.duration);
9919
+ });
9920
+ __publicField(this, "changePlayerVolume", () => {
9921
+ if (!this._video)
9922
+ return;
9923
+ const { volume } = this.ctx;
9924
+ if (volume > 0) {
9925
+ addClassToElement(this._playControllerBottomSpeedIcon, "ran-player-controller-bottom-right-volume-icon-mute");
9926
+ removeClassToElement(
9927
+ this._playControllerBottomSpeedIcon,
9928
+ "ran-player-controller-bottom-right-volume-icon-volume"
10391
9929
  );
10392
- this._player.removeEventListener(
10393
- "mousemove",
10394
- this.progressDotMouseMove
10395
- );
10396
- this._player.removeEventListener("mouseup", this.progressDotMouseUp);
10397
- this._playControllerBottomVolumeProgress.removeEventListener(
10398
- "change",
10399
- this.changeVolumeProgress
10400
- );
10401
- this._playControllerBottomRightFullScreen.removeEventListener(
10402
- "click",
10403
- this.openFullScreen
10404
- );
10405
- window.removeEventListener("resize", this.resize);
10406
- document.removeEventListener("fullscreenchange", this.fullScreenChange);
10407
- }
10408
- attributeChangedCallback(k, o, n) {
10409
- }
10410
- }
9930
+ this._playControllerBottomVolumeProgress.setAttribute("percent", "0");
9931
+ this.setVolume(0);
9932
+ this.change("volume", 0);
9933
+ } else {
9934
+ addClassToElement(this._playControllerBottomSpeedIcon, "ran-player-controller-bottom-right-volume-icon-volume");
9935
+ removeClassToElement(this._playControllerBottomSpeedIcon, "ran-player-controller-bottom-right-volume-icon-mute");
9936
+ this._playControllerBottomVolumeProgress.setAttribute("percent", `${this._volume || 0.5}`);
9937
+ this.setVolume(0.5);
9938
+ this.change("volume", this._volume || 0.5);
9939
+ }
9940
+ });
9941
+ __publicField(this, "resize", () => {
9942
+ if (this._video) {
9943
+ const { width, height } = this._player.getBoundingClientRect();
9944
+ this._video.style.setProperty("width", `${width}px`);
9945
+ this._video.style.setProperty("height", `${height}px`);
9946
+ if (document.body.clientWidth < 500) {
9947
+ this._playControllerBottomVolume.style.setProperty("display", "none");
9948
+ } else {
9949
+ this._playControllerBottomVolume.style.setProperty("display", "flex");
9950
+ }
9951
+ }
9952
+ this.updateCurrentProgress();
9953
+ });
9954
+ __publicField(this, "fullScreenChange", () => {
9955
+ var _a;
9956
+ if ((_a = document.fullscreenElement) == null ? void 0 : _a.classList.contains("ran-player")) {
9957
+ this.change("fullscreen", true);
9958
+ this.ctx.fullScreen = true;
9959
+ } else {
9960
+ this.change("fullscreen", false);
9961
+ this.ctx.fullScreen = false;
9962
+ }
9963
+ });
9964
+ __publicField(this, "getPlaybackRate", () => {
9965
+ if (this._video) {
9966
+ this.ctx.playbackRate = this._video.playbackRate || 0;
9967
+ }
9968
+ return this.ctx.playbackRate;
9969
+ });
9970
+ __publicField(this, "setPlaybackRate", (n) => {
9971
+ if (this._video) {
9972
+ this.ctx.playbackRate = n;
9973
+ this._video.playbackRate = n;
9974
+ }
9975
+ return this.ctx.playbackRate;
9976
+ });
9977
+ __publicField(this, "setVolume", (n) => {
9978
+ if (this._video) {
9979
+ this.ctx.volume = n;
9980
+ this._video.volume = n;
9981
+ }
9982
+ return this.ctx.volume;
9983
+ });
9984
+ __publicField(this, "getVolume", () => {
9985
+ if (this._video) {
9986
+ this.ctx.volume = this._video.volume || 0;
9987
+ }
9988
+ return this.ctx.volume;
9989
+ });
9990
+ __publicField(this, "setCurrentTime", (n) => {
9991
+ if (this._video) {
9992
+ this.ctx.currentTime = n;
9993
+ this._video.currentTime = n;
9994
+ }
9995
+ return this.ctx.currentTime;
9996
+ });
9997
+ __publicField(this, "getCurrentTime", () => {
9998
+ if (this._video) {
9999
+ this.ctx.currentTime = this._video.currentTime || 0;
10000
+ }
10001
+ return this.ctx.currentTime;
10002
+ });
10003
+ __publicField(this, "getTotalTime", () => {
10004
+ if (this._video) {
10005
+ this.ctx.duration = this._video.duration || 0;
10006
+ }
10007
+ return this.ctx.duration;
10008
+ });
10009
+ __publicField(this, "play", (n) => {
10010
+ if (this._video) {
10011
+ if (n !== void 0 && n >= 0) {
10012
+ this.ctx.currentTime = n;
10013
+ this._video.currentTime = n;
10014
+ }
10015
+ this._video.play();
10016
+ }
10017
+ });
10018
+ __publicField(this, "pause", () => {
10019
+ if (this._video) {
10020
+ this._video.pause();
10021
+ }
10022
+ });
10023
+ this.innerHTML = "";
10024
+ this._player = document.createElement("div");
10025
+ this._container = document.createElement("div");
10026
+ this._slot = document.createElement("slot");
10027
+ this._playerBtn = document.createElement("div");
10028
+ this._progress = document.createElement("div");
10029
+ this._progressWrap = document.createElement("div");
10030
+ this._progressWrapValue = document.createElement("div");
10031
+ this._progressDot = document.createElement("div");
10032
+ this._playerControllerBottom = document.createElement("div");
10033
+ this._playerControllerBottomRight = document.createElement("div");
10034
+ this._playerControllerBottomLeft = document.createElement("div");
10035
+ this._player.setAttribute("class", "ran-player");
10036
+ this._player.setAttribute("id", "ran-player" + `${performance.now()}`.replace(".", ""));
10037
+ this._playerBtn.setAttribute("class", "ran-player-play-btn");
10038
+ this._progress.setAttribute("class", "ran-player-controller-progress");
10039
+ this._progressWrap.setAttribute("class", "ran-player-controller-progress-wrap");
10040
+ this._progressWrapValue.setAttribute("class", "ran-player-controller-progress-wrap-value");
10041
+ this._progressDot.setAttribute("class", "ran-player-controller-progress-dot");
10042
+ this._playerControllerBottom.setAttribute("class", "ran-player-controller-bottom");
10043
+ this._playerControllerBottomRight.setAttribute("class", "ran-player-controller-bottom-right");
10044
+ this._playerControllerBottomLeft.setAttribute("class", "ran-player-controller-bottom-left");
10045
+ this._playerControllerBottomPlayBtn = document.createElement("div");
10046
+ this._playerControllerBottomPlayBtn.setAttribute("class", "ran-player-controller-bottom-left-btn");
10047
+ this._playerControllerBottomTimeCurrent = document.createElement("div");
10048
+ this._playerControllerBottomTimeCurrent.setAttribute("class", "ran-player-controller-bottom-left-time-current");
10049
+ this._playerControllerBottomTimeDivide = document.createElement("div");
10050
+ this._playerControllerBottomTimeDivide.setAttribute("class", "ran-player-controller-bottom-left-time-divide");
10051
+ this._playerControllerBottomTimeDuration = document.createElement("div");
10052
+ this._playerControllerBottomTimeDuration.setAttribute("class", "ran-player-controller-bottom-left-time-duration");
10053
+ this._playControllerBottomSpeed = document.createElement("div");
10054
+ this._playControllerBottomSpeed.setAttribute("class", "ran-player-controller-bottom-right-speed");
10055
+ this._playControllerBottomSpeedPopover = document.createElement("r-select");
10056
+ this._playControllerBottomSpeedPopover.setAttribute("value", "1");
10057
+ this._playControllerBottomSpeedPopover.setAttribute("action", "hover,click");
10058
+ this._playControllerBottomSpeedPopover.setAttribute("type", "text");
10059
+ this._playControllerBottomSpeedPopover.setAttribute("placement", "top");
10060
+ const id = this._player.getAttribute("id");
10061
+ id && this._playControllerBottomSpeedPopover.setAttribute("getPopupContainerId", id);
10062
+ this._playControllerBottomSpeedPopover.setAttribute("dropdownclass", "video-speed-dropdown");
10063
+ this._playControllerBottomSpeedPopover.addEventListener("change", this.changeSpeed);
10064
+ const Fragment = document.createDocumentFragment();
10065
+ SPEED.forEach((item) => {
10066
+ const { label, value } = item;
10067
+ const option = document.createElement("r-option");
10068
+ option.innerHTML = label;
10069
+ option.setAttribute("value", `${value}`);
10070
+ Fragment.appendChild(option);
10071
+ });
10072
+ this._playControllerBottomSpeedPopover.appendChild(Fragment);
10073
+ this._playControllerBottomSpeed.appendChild(this._playControllerBottomSpeedPopover);
10074
+ this._playControllerBottomVolume = document.createElement("div");
10075
+ this._playControllerBottomVolume.setAttribute("class", "ran-player-controller-bottom-right-volume");
10076
+ this._playControllerBottomVolumeProgress = document.createElement("r-progress");
10077
+ this._playControllerBottomVolumeProgress.setAttribute(
10078
+ "class",
10079
+ "ran-player-controller-bottom-right-volume-progress"
10080
+ );
10081
+ this._playControllerBottomVolumeProgress.setAttribute("percent", "0.5");
10082
+ this._playControllerBottomVolumeProgress.setAttribute("type", "drag");
10083
+ this._playControllerBottomSpeedIcon = document.createElement("div");
10084
+ this._playControllerBottomSpeedIcon.setAttribute(
10085
+ "class",
10086
+ "ran-player-controller-bottom-right-volume-icon ran-player-controller-bottom-right-volume-icon-volume"
10087
+ );
10088
+ this._playControllerBottomClarity = document.createElement("div");
10089
+ this._playControllerBottomClarity.setAttribute("class", "ran-player-controller-bottom-right-clarity");
10090
+ this._playControllerBottomRightFullScreen = document.createElement("div");
10091
+ this._playControllerBottomRightFullScreen.setAttribute("class", "ran-player-controller-bottom-right-full");
10092
+ this._playerController = document.createElement("div");
10093
+ this._playerController.setAttribute("class", "ran-player-controller");
10094
+ this._playerTip = document.createElement("div");
10095
+ this._playerTip.setAttribute("class", "ran-player-controller-tip");
10096
+ this._playerTipTime = document.createElement("div");
10097
+ this._playerTipTime.setAttribute("class", "ran-player-controller-tip-time");
10098
+ this._playerTipText = document.createElement("div");
10099
+ this._playerTipText.setAttribute("class", "ran-player-controller-tip-text");
10100
+ this._playerTip.appendChild(createDocumentFragment([this._playerTipTime, this._playerTipText]));
10101
+ this._playerController.appendChild(
10102
+ createDocumentFragment([this._playerTip, this._progress, this._playerControllerBottom])
10103
+ );
10104
+ this._player.appendChild(
10105
+ createDocumentFragment([this._container, this._slot, this._playerBtn, this._playerController])
10106
+ );
10107
+ this._progressWrap.appendChild(this._progressWrapValue);
10108
+ this._progress.appendChild(createDocumentFragment([this._progressWrap, this._progressDot]));
10109
+ this._playerControllerBottom.appendChild(
10110
+ createDocumentFragment([this._playerControllerBottomLeft, this._playerControllerBottomRight])
10111
+ );
10112
+ this._playerControllerBottomLeft.appendChild(
10113
+ createDocumentFragment([
10114
+ this._playerControllerBottomPlayBtn,
10115
+ this._playerControllerBottomTimeCurrent,
10116
+ this._playerControllerBottomTimeDivide,
10117
+ this._playerControllerBottomTimeDuration
10118
+ ])
10119
+ );
10120
+ this._playControllerBottomVolume.appendChild(
10121
+ createDocumentFragment([this._playControllerBottomSpeedIcon, this._playControllerBottomVolumeProgress])
10122
+ );
10123
+ this._playerControllerBottomRight.appendChild(
10124
+ createDocumentFragment([
10125
+ this._playControllerBottomClarity,
10126
+ this._playControllerBottomSpeed,
10127
+ this._playControllerBottomVolume,
10128
+ this._playControllerBottomRightFullScreen
10129
+ ])
10130
+ );
10131
+ this.ctx = {
10132
+ currentTime: 0,
10133
+ // 当前时间
10134
+ duration: 0,
10135
+ // 总时长
10136
+ currentState: "",
10137
+ // 当前视频状态
10138
+ action: new SyncHook(),
10139
+ // 不同时期触发的状态
10140
+ volume: 0.5,
10141
+ // 当前音量
10142
+ playbackRate: 1,
10143
+ // 当前倍速
10144
+ clarity: "",
10145
+ // 当前清晰度
10146
+ fullScreen: false,
10147
+ // 是否全屏
10148
+ levels: [],
10149
+ // 清晰度列表
10150
+ url: "",
10151
+ // 当前播放的地址
10152
+ levelMap: /* @__PURE__ */ new Map()
10153
+ // 清晰度和名字的映射关系
10154
+ };
10155
+ this.moveProgress = {
10156
+ percentage: 0,
10157
+ mouseDown: false
10158
+ };
10159
+ }
10160
+ static get observedAttributes() {
10161
+ return ["src", "volume", "currentTime", "playbackRate", "debug"];
10162
+ }
10163
+ get src() {
10164
+ return this.getAttribute("src") || "";
10165
+ }
10166
+ set src(value) {
10167
+ this.setAttribute("src", value || "");
10168
+ }
10169
+ get debug() {
10170
+ return this.getAttribute("debug") || "";
10171
+ }
10172
+ set debug(value) {
10173
+ this.setAttribute("debug", value || "");
10174
+ }
10175
+ get volume() {
10176
+ return this.getAttribute("volume") || "";
10177
+ }
10178
+ set volume(value) {
10179
+ this.setAttribute("volume", value || "");
10180
+ }
10181
+ get currentTime() {
10182
+ return this.getAttribute("currentTime") || "";
10183
+ }
10184
+ set currentTime(value) {
10185
+ this.setAttribute("currentTime", value || "");
10186
+ }
10187
+ get playbackRate() {
10188
+ return this.getAttribute("playbackRate") || "";
10189
+ }
10190
+ set playbackRate(value) {
10191
+ this.setAttribute("playbackRate", value || "");
10192
+ }
10193
+ connectedCallback() {
10194
+ this._container.addEventListener("click", this.dispatchClickPlayerContainerAction);
10195
+ this._playerBtn.addEventListener("click", this.dispatchClickPlayerBtnAction);
10196
+ this.addEventListener("keydown", this.SpaceKeyDown);
10197
+ this._progressDot.addEventListener("mousedown", this.progressDotMouseDown);
10198
+ this._playerControllerBottomPlayBtn.addEventListener("click", this.dispatchClickPlayerBtnAction);
10199
+ this._progress.addEventListener("click", this.progressClick);
10200
+ this._progress.addEventListener("mouseenter", this.progressMouseEnter);
10201
+ this._progress.addEventListener("mousemove", this.progressMouseMove);
10202
+ this._progress.addEventListener("mouseleave", this.progressMouseLeave);
10203
+ this._player.addEventListener("mousemove", this.progressDotMouseMove);
10204
+ this._player.addEventListener("mouseup", this.progressDotMouseUp);
10205
+ this._playControllerBottomVolumeProgress.addEventListener("change", this.changeVolumeProgress);
10206
+ this._playControllerBottomRightFullScreen.addEventListener("click", this.openFullScreen);
10207
+ this._playControllerBottomSpeedIcon.addEventListener("click", this.changePlayerVolume);
10208
+ document.addEventListener("fullscreenchange", this.fullScreenChange);
10209
+ window.addEventListener("resize", this.resize);
10210
+ this.updatePlayer();
10211
+ }
10212
+ disconnectCallback() {
10213
+ this._container.removeEventListener("click", this.dispatchClickPlayerContainerAction);
10214
+ this._playerBtn.removeEventListener("click", this.dispatchClickPlayerBtnAction);
10215
+ this._playerControllerBottomPlayBtn.removeEventListener("click", this.dispatchClickPlayerBtnAction);
10216
+ this.cancelAnimationFrame();
10217
+ this.removeEventListener("keydown", this.SpaceKeyDown);
10218
+ this._progress.removeEventListener("click", this.progressClick);
10219
+ this._progress.removeEventListener("mouseenter", this.progressMouseEnter);
10220
+ this._progress.removeEventListener("mousemove", this.progressMouseMove);
10221
+ this._progress.removeEventListener("mouseleave", this.progressMouseLeave);
10222
+ this._progressDot.removeEventListener("mousedown", this.progressDotMouseDown);
10223
+ this._player.removeEventListener("mousemove", this.progressDotMouseMove);
10224
+ this._player.removeEventListener("mouseup", this.progressDotMouseUp);
10225
+ this._playControllerBottomVolumeProgress.removeEventListener("change", this.changeVolumeProgress);
10226
+ this._playControllerBottomRightFullScreen.removeEventListener("click", this.openFullScreen);
10227
+ window.removeEventListener("resize", this.resize);
10228
+ document.removeEventListener("fullscreenchange", this.fullScreenChange);
10229
+ }
10230
+ attributeChangedCallback(k, o, n) {
10231
+ }
10232
+ }
10233
+ function Custom() {
10234
+ if (typeof document !== "undefined" && !customElements.get("r-player")) {
10411
10235
  customElements.define("r-player", RanPlayer);
10412
10236
  return RanPlayer;
10413
10237
  }
@@ -10415,9 +10239,11 @@ function Custom() {
10415
10239
  const index = Custom();
10416
10240
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10417
10241
  __proto__: null,
10242
+ RanPlayer,
10418
10243
  default: index
10419
10244
  }, Symbol.toStringTag, { value: "Module" }));
10420
10245
  export {
10246
+ RanPlayer as R,
10421
10247
  index as a,
10422
10248
  index$1 as i
10423
10249
  };