vidply 1.2.0 → 1.2.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 (164) hide show
  1. package/README.md +946 -946
  2. package/dist/dev/{vidply.AudioDescriptionManager-R47Q4YR4.js → vidply.AudioDescriptionManager-6RFVF27Z.js} +275 -19
  3. package/dist/dev/vidply.AudioDescriptionManager-6RFVF27Z.js.map +7 -0
  4. package/dist/dev/{vidply.CaptionStyleMenu-7XHRBWUM.js → vidply.CaptionStyleMenu-R2SCQ6VP.js} +4 -4
  5. package/dist/dev/{vidply.DASHRenderer-PWEMC3BT.js → vidply.DASHRenderer-EOVEW73H.js} +3 -3
  6. package/dist/dev/vidply.DASHRenderer-EOVEW73H.js.map +7 -0
  7. package/dist/dev/{vidply.FloatingPlayerManager-PKNNNAS2.js → vidply.FloatingPlayerManager-V5XQWS75.js} +5 -5
  8. package/dist/dev/vidply.FloatingPlayerManager-V5XQWS75.js.map +7 -0
  9. package/dist/dev/{vidply.HLSRenderer-E7RQ74HI.js → vidply.HLSRenderer-ZBEFVH5W.js} +4 -4
  10. package/dist/dev/vidply.HLSRenderer-ZBEFVH5W.js.map +7 -0
  11. package/dist/dev/vidply.HTML5Renderer-P7ICKYU4.js +12 -0
  12. package/dist/dev/{vidply.SignLanguageManager-FET5FQZ7.js → vidply.SignLanguageManager-7IAJOVF6.js} +8 -8
  13. package/dist/dev/vidply.SignLanguageManager-7IAJOVF6.js.map +7 -0
  14. package/dist/dev/{vidply.SoundCloudRenderer-RVSJZODO.js → vidply.SoundCloudRenderer-OA7QQYGN.js} +3 -3
  15. package/dist/dev/vidply.SoundCloudRenderer-OA7QQYGN.js.map +7 -0
  16. package/dist/dev/{vidply.TranscriptManager-5GXOQCLX.js → vidply.TranscriptManager-BPM3T23L.js} +10 -10
  17. package/dist/dev/vidply.TranscriptManager-BPM3T23L.js.map +7 -0
  18. package/dist/dev/{vidply.VimeoRenderer-ER2LSBBW.js → vidply.VimeoRenderer-BRHFYPNJ.js} +3 -3
  19. package/dist/dev/vidply.VimeoRenderer-BRHFYPNJ.js.map +7 -0
  20. package/dist/dev/{vidply.YouTubeRenderer-NFTOWJAB.js → vidply.YouTubeRenderer-HRTN4EJ5.js} +3 -3
  21. package/dist/dev/vidply.YouTubeRenderer-HRTN4EJ5.js.map +7 -0
  22. package/dist/dev/{vidply.chunk-6RQA4ROD.js → vidply.chunk-5IK3IC5V.js} +2 -2
  23. package/dist/dev/{vidply.chunk-JJ47NO24.js → vidply.chunk-C55OBT5H.js} +2 -2
  24. package/dist/dev/vidply.chunk-C55OBT5H.js.map +7 -0
  25. package/dist/dev/{vidply.chunk-DZSDO3B7.js → vidply.chunk-HOYEMJSD.js} +2 -2
  26. package/dist/dev/{vidply.chunk-VMSQAZM7.js → vidply.chunk-JAKZNGOR.js} +2 -2
  27. package/dist/dev/{vidply.chunk-64WXMTGL.js → vidply.chunk-LDVFAFGC.js} +5 -5
  28. package/dist/dev/vidply.chunk-LDVFAFGC.js.map +7 -0
  29. package/dist/dev/{vidply.chunk-RZWZGDV7.js → vidply.chunk-NSMAZCMB.js} +6 -6
  30. package/dist/dev/vidply.chunk-NSMAZCMB.js.map +7 -0
  31. package/dist/dev/{vidply.chunk-KI7C3QVL.js → vidply.chunk-RQG3MA7W.js} +2 -2
  32. package/dist/dev/vidply.chunk-RQG3MA7W.js.map +7 -0
  33. package/dist/dev/{vidply.chunk-BNFIUL2Z.js → vidply.chunk-UHMVDBDB.js} +3 -3
  34. package/dist/dev/vidply.chunk-UHMVDBDB.js.map +7 -0
  35. package/dist/dev/{vidply.chunk-NQPURMQY.js → vidply.chunk-W5BR65JY.js} +6 -6
  36. package/dist/dev/vidply.chunk-W5BR65JY.js.map +7 -0
  37. package/dist/dev/{vidply.chunk-W25HUCHS.js → vidply.chunk-XAK3DPTO.js} +2 -2
  38. package/dist/dev/vidply.chunk-XAK3DPTO.js.map +7 -0
  39. package/dist/dev/{vidply.chunk-SK4V2DAU.js → vidply.chunk-YVCYQZJI.js} +3 -3
  40. package/dist/dev/{vidply.de-4YAT7FFM.js → vidply.de-5W5LBFSJ.js} +2 -2
  41. package/dist/dev/vidply.de-5W5LBFSJ.js.map +7 -0
  42. package/dist/dev/{vidply.es-LEWIRUBH.js → vidply.es-SHDAT6L6.js} +2 -2
  43. package/dist/dev/vidply.es-SHDAT6L6.js.map +7 -0
  44. package/dist/dev/vidply.esm.js +73 -34
  45. package/dist/dev/vidply.esm.js.map +2 -2
  46. package/dist/dev/{vidply.fr-Q4GV2NOE.js → vidply.fr-2JANOMNB.js} +2 -2
  47. package/dist/dev/vidply.fr-2JANOMNB.js.map +7 -0
  48. package/dist/dev/{vidply.ja-S6ITA6WU.js → vidply.ja-WWMSTEJH.js} +2 -2
  49. package/dist/dev/vidply.ja-WWMSTEJH.js.map +7 -0
  50. package/dist/legacy/vidply.js +345 -32
  51. package/dist/legacy/vidply.js.map +3 -3
  52. package/dist/legacy/vidply.min.js +2 -2
  53. package/dist/legacy/vidply.min.meta.json +66 -47
  54. package/dist/prod/vidply.AudioDescriptionManager-YTDVDQBO.min.js +6 -0
  55. package/dist/prod/{vidply.CaptionStyleMenu-M3KVQWB5.min.js → vidply.CaptionStyleMenu-2AFF3HF2.min.js} +2 -2
  56. package/dist/prod/{vidply.DASHRenderer-DN3S27AV.min.js → vidply.DASHRenderer-URDOTOKS.min.js} +2 -2
  57. package/dist/prod/{vidply.FloatingPlayerManager-SKAZ4J43.min.js → vidply.FloatingPlayerManager-QUBFK7CQ.min.js} +2 -2
  58. package/dist/prod/{vidply.HLSRenderer-62HH4YTK.min.js → vidply.HLSRenderer-46KNUVAB.min.js} +2 -2
  59. package/dist/prod/vidply.HTML5Renderer-7TQDMIGY.min.js +6 -0
  60. package/dist/prod/{vidply.SignLanguageManager-V3OBTSSF.min.js → vidply.SignLanguageManager-H4C36EVL.min.js} +2 -2
  61. package/dist/prod/{vidply.SoundCloudRenderer-CXRVZIAJ.min.js → vidply.SoundCloudRenderer-OYSWMW7D.min.js} +2 -2
  62. package/dist/prod/{vidply.TranscriptManager-SYM3DFUY.min.js → vidply.TranscriptManager-BA3DAS63.min.js} +2 -2
  63. package/dist/prod/{vidply.VimeoRenderer-72TWRYFQ.min.js → vidply.VimeoRenderer-NF3COTHU.min.js} +2 -2
  64. package/dist/prod/{vidply.YouTubeRenderer-UMHEV3KD.min.js → vidply.YouTubeRenderer-UCQKYIJ4.min.js} +2 -2
  65. package/dist/prod/{vidply.chunk-Z3YDSA7O.min.js → vidply.chunk-2HNCP64N.min.js} +1 -1
  66. package/dist/prod/{vidply.chunk-EKEYJWMG.min.js → vidply.chunk-6ECBIYVI.min.js} +2 -2
  67. package/dist/prod/{vidply.chunk-YEENJS3Q.min.js → vidply.chunk-7S5AFTST.min.js} +2 -2
  68. package/dist/prod/{vidply.chunk-P4UXOHWA.min.js → vidply.chunk-EUOA2DJK.min.js} +1 -1
  69. package/dist/prod/{vidply.chunk-2TB6MUHO.min.js → vidply.chunk-G6KGXNEW.min.js} +1 -1
  70. package/dist/prod/{vidply.chunk-ABPXVDLZ.min.js → vidply.chunk-JPMAK3NS.min.js} +1 -1
  71. package/dist/prod/{vidply.chunk-P3PQBY7N.min.js → vidply.chunk-L4O44K63.min.js} +1 -1
  72. package/dist/prod/{vidply.chunk-WX3MVEAL.min.js → vidply.chunk-M76ABMKB.min.js} +1 -1
  73. package/dist/prod/{vidply.chunk-TM6AXJVD.min.js → vidply.chunk-WRVDVD33.min.js} +2 -2
  74. package/dist/prod/{vidply.chunk-RI3X7WHK.min.js → vidply.chunk-X2FQEQYR.min.js} +2 -2
  75. package/dist/prod/{vidply.chunk-UK7YGOB5.min.js → vidply.chunk-XXUH7ADU.min.js} +2 -2
  76. package/dist/prod/{vidply.de-BCHXRQ53.min.js → vidply.de-JMCATTKZ.min.js} +1 -1
  77. package/dist/prod/{vidply.es-PICAKMZD.min.js → vidply.es-YVG37V7Z.min.js} +1 -1
  78. package/dist/prod/vidply.esm.min.js +2 -2
  79. package/dist/prod/{vidply.fr-ZILI7CDR.min.js → vidply.fr-OGKGN2R4.min.js} +1 -1
  80. package/dist/prod/{vidply.ja-5WQ4OK4J.min.js → vidply.ja-Z6DS7QLS.min.js} +1 -1
  81. package/dist/vidply.css +5796 -5796
  82. package/dist/vidply.esm.min.meta.json +148 -135
  83. package/package.json +7 -7
  84. package/src/controls/CaptionManager.ts +598 -598
  85. package/src/controls/ControlBar.ts +4159 -4159
  86. package/src/controls/KeyboardManager.ts +383 -383
  87. package/src/controls/SettingsDialog.ts +488 -488
  88. package/src/controls/TranscriptManager.ts +2426 -2426
  89. package/src/core/AudioDescriptionManager.ts +863 -774
  90. package/src/core/DescriptionSpeechManager.ts +232 -0
  91. package/src/core/FloatingPlayerManager.ts +674 -674
  92. package/src/core/LazyInit.ts +80 -80
  93. package/src/core/MetadataAlertsManager.ts +514 -514
  94. package/src/core/Player.ts +2915 -2872
  95. package/src/core/PosterManager.ts +169 -169
  96. package/src/core/PseudoFullscreen.ts +179 -179
  97. package/src/core/ResponsiveManager.ts +231 -231
  98. package/src/core/ResumeManager.ts +236 -236
  99. package/src/core/SignLanguageManager.ts +1308 -1308
  100. package/src/core/ThemeManager.ts +157 -157
  101. package/src/features/PlaylistManager.ts +1838 -1827
  102. package/src/i18n/i18n.ts +223 -223
  103. package/src/i18n/languages/de.ts +217 -217
  104. package/src/i18n/languages/en.ts +218 -218
  105. package/src/i18n/languages/es.ts +214 -214
  106. package/src/i18n/languages/fr.ts +214 -214
  107. package/src/i18n/languages/ja.ts +214 -214
  108. package/src/icons/Icons.ts +167 -167
  109. package/src/index.ts +196 -193
  110. package/src/renderers/DASHRenderer.ts +1077 -1077
  111. package/src/renderers/HLSRenderer.ts +944 -944
  112. package/src/renderers/HTML5Renderer.ts +389 -389
  113. package/src/renderers/SoundCloudRenderer.ts +437 -437
  114. package/src/renderers/VimeoRenderer.ts +298 -298
  115. package/src/renderers/YouTubeRenderer.ts +290 -290
  116. package/src/styles/vidply.css +5796 -5796
  117. package/src/types/events.ts +124 -122
  118. package/src/types/globals.d.ts +313 -313
  119. package/src/types/options.ts +185 -182
  120. package/src/types/renderer.ts +58 -58
  121. package/src/utils/DOMUtils.ts +281 -281
  122. package/src/utils/DownloadInfo.ts +171 -171
  123. package/src/utils/DraggablePanel.ts +539 -539
  124. package/src/utils/DraggablePanelMenu.ts +195 -195
  125. package/src/utils/DraggableResizable.ts +997 -997
  126. package/src/utils/EventEmitter.ts +59 -59
  127. package/src/utils/FormUtils.ts +95 -95
  128. package/src/utils/MenuFactory.ts +483 -483
  129. package/src/utils/Sanitize.ts +70 -70
  130. package/src/utils/SettingsMenuFactory.ts +289 -289
  131. package/src/utils/StorageManager.ts +287 -287
  132. package/src/utils/TrackLabelUtils.ts +52 -52
  133. package/src/utils/UrlSafe.ts +69 -69
  134. package/src/utils/VideoFrameCapture.ts +114 -114
  135. package/src/utils/WindowComponents.ts +250 -250
  136. package/dist/dev/vidply.AudioDescriptionManager-R47Q4YR4.js.map +0 -7
  137. package/dist/dev/vidply.DASHRenderer-PWEMC3BT.js.map +0 -7
  138. package/dist/dev/vidply.FloatingPlayerManager-PKNNNAS2.js.map +0 -7
  139. package/dist/dev/vidply.HLSRenderer-E7RQ74HI.js.map +0 -7
  140. package/dist/dev/vidply.HTML5Renderer-BU4QJJJY.js +0 -12
  141. package/dist/dev/vidply.SignLanguageManager-FET5FQZ7.js.map +0 -7
  142. package/dist/dev/vidply.SoundCloudRenderer-RVSJZODO.js.map +0 -7
  143. package/dist/dev/vidply.TranscriptManager-5GXOQCLX.js.map +0 -7
  144. package/dist/dev/vidply.VimeoRenderer-ER2LSBBW.js.map +0 -7
  145. package/dist/dev/vidply.YouTubeRenderer-NFTOWJAB.js.map +0 -7
  146. package/dist/dev/vidply.chunk-64WXMTGL.js.map +0 -7
  147. package/dist/dev/vidply.chunk-BNFIUL2Z.js.map +0 -7
  148. package/dist/dev/vidply.chunk-JJ47NO24.js.map +0 -7
  149. package/dist/dev/vidply.chunk-KI7C3QVL.js.map +0 -7
  150. package/dist/dev/vidply.chunk-NQPURMQY.js.map +0 -7
  151. package/dist/dev/vidply.chunk-RZWZGDV7.js.map +0 -7
  152. package/dist/dev/vidply.chunk-W25HUCHS.js.map +0 -7
  153. package/dist/dev/vidply.de-4YAT7FFM.js.map +0 -7
  154. package/dist/dev/vidply.es-LEWIRUBH.js.map +0 -7
  155. package/dist/dev/vidply.fr-Q4GV2NOE.js.map +0 -7
  156. package/dist/dev/vidply.ja-S6ITA6WU.js.map +0 -7
  157. package/dist/prod/vidply.AudioDescriptionManager-RHLIJW5C.min.js +0 -6
  158. package/dist/prod/vidply.HTML5Renderer-IU5T3WEW.min.js +0 -6
  159. /package/dist/dev/{vidply.CaptionStyleMenu-7XHRBWUM.js.map → vidply.CaptionStyleMenu-R2SCQ6VP.js.map} +0 -0
  160. /package/dist/dev/{vidply.HTML5Renderer-BU4QJJJY.js.map → vidply.HTML5Renderer-P7ICKYU4.js.map} +0 -0
  161. /package/dist/dev/{vidply.chunk-6RQA4ROD.js.map → vidply.chunk-5IK3IC5V.js.map} +0 -0
  162. /package/dist/dev/{vidply.chunk-DZSDO3B7.js.map → vidply.chunk-HOYEMJSD.js.map} +0 -0
  163. /package/dist/dev/{vidply.chunk-VMSQAZM7.js.map → vidply.chunk-JAKZNGOR.js.map} +0 -0
  164. /package/dist/dev/{vidply.chunk-SK4V2DAU.js.map → vidply.chunk-YVCYQZJI.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "inputs": {
3
3
  "src/utils/EventEmitter.ts": {
4
- "bytes": 1975,
4
+ "bytes": 1916,
5
5
  "imports": [
6
6
  {
7
7
  "path": "<runtime>",
@@ -12,32 +12,32 @@
12
12
  "format": "esm"
13
13
  },
14
14
  "src/utils/DOMUtils.ts": {
15
- "bytes": 9276,
15
+ "bytes": 8995,
16
16
  "imports": [],
17
17
  "format": "esm"
18
18
  },
19
19
  "src/i18n/languages/en.ts": {
20
- "bytes": 9107,
20
+ "bytes": 8889,
21
21
  "imports": [],
22
22
  "format": "esm"
23
23
  },
24
24
  "src/i18n/languages/de.ts": {
25
- "bytes": 11202,
25
+ "bytes": 10985,
26
26
  "imports": [],
27
27
  "format": "esm"
28
28
  },
29
29
  "src/i18n/languages/es.ts": {
30
- "bytes": 10250,
30
+ "bytes": 10036,
31
31
  "imports": [],
32
32
  "format": "esm"
33
33
  },
34
34
  "src/i18n/languages/fr.ts": {
35
- "bytes": 10571,
35
+ "bytes": 10357,
36
36
  "imports": [],
37
37
  "format": "esm"
38
38
  },
39
39
  "src/i18n/languages/ja.ts": {
40
- "bytes": 11054,
40
+ "bytes": 10840,
41
41
  "imports": [],
42
42
  "format": "esm"
43
43
  },
@@ -73,12 +73,12 @@
73
73
  "format": "esm"
74
74
  },
75
75
  "src/utils/Sanitize.ts": {
76
- "bytes": 2816,
76
+ "bytes": 2746,
77
77
  "imports": [],
78
78
  "format": "esm"
79
79
  },
80
80
  "src/i18n/i18n.ts": {
81
- "bytes": 7833,
81
+ "bytes": 7610,
82
82
  "imports": [
83
83
  {
84
84
  "path": "src/i18n/translations.ts",
@@ -110,7 +110,7 @@
110
110
  "format": "esm"
111
111
  },
112
112
  "src/icons/Icons.ts": {
113
- "bytes": 13659,
113
+ "bytes": 13492,
114
114
  "imports": [],
115
115
  "format": "esm"
116
116
  },
@@ -125,12 +125,12 @@
125
125
  "format": "esm"
126
126
  },
127
127
  "src/utils/VideoFrameCapture.ts": {
128
- "bytes": 3564,
128
+ "bytes": 3450,
129
129
  "imports": [],
130
130
  "format": "esm"
131
131
  },
132
132
  "src/utils/DownloadInfo.ts": {
133
- "bytes": 5039,
133
+ "bytes": 4868,
134
134
  "imports": [],
135
135
  "format": "esm"
136
136
  },
@@ -156,7 +156,7 @@
156
156
  "format": "esm"
157
157
  },
158
158
  "src/controls/ControlBar.ts": {
159
- "bytes": 175580,
159
+ "bytes": 171421,
160
160
  "imports": [
161
161
  {
162
162
  "path": "src/utils/DOMUtils.ts",
@@ -212,7 +212,7 @@
212
212
  "format": "esm"
213
213
  },
214
214
  "src/utils/StorageManager.ts": {
215
- "bytes": 9701,
215
+ "bytes": 9414,
216
216
  "imports": [
217
217
  {
218
218
  "path": "src/utils/Sanitize.ts",
@@ -228,7 +228,7 @@
228
228
  "format": "esm"
229
229
  },
230
230
  "src/utils/TrackLabelUtils.ts": {
231
- "bytes": 2045,
231
+ "bytes": 1993,
232
232
  "imports": [
233
233
  {
234
234
  "path": "src/i18n/i18n.ts",
@@ -239,7 +239,7 @@
239
239
  "format": "esm"
240
240
  },
241
241
  "src/controls/CaptionManager.ts": {
242
- "bytes": 23893,
242
+ "bytes": 23295,
243
243
  "imports": [
244
244
  {
245
245
  "path": "src/utils/DOMUtils.ts",
@@ -275,7 +275,7 @@
275
275
  "format": "esm"
276
276
  },
277
277
  "src/controls/KeyboardManager.ts": {
278
- "bytes": 13750,
278
+ "bytes": 13367,
279
279
  "imports": [
280
280
  {
281
281
  "path": "src/i18n/i18n.ts",
@@ -296,7 +296,7 @@
296
296
  "format": "esm"
297
297
  },
298
298
  "src/renderers/HTML5Renderer.ts": {
299
- "bytes": 12499,
299
+ "bytes": 12110,
300
300
  "imports": [
301
301
  {
302
302
  "path": "<runtime>",
@@ -307,17 +307,17 @@
307
307
  "format": "esm"
308
308
  },
309
309
  "src/utils/UrlSafe.ts": {
310
- "bytes": 2722,
310
+ "bytes": 2653,
311
311
  "imports": [],
312
312
  "format": "esm"
313
313
  },
314
314
  "src/core/LazyInit.ts": {
315
- "bytes": 2574,
315
+ "bytes": 2494,
316
316
  "imports": [],
317
317
  "format": "esm"
318
318
  },
319
319
  "src/core/PseudoFullscreen.ts": {
320
- "bytes": 7117,
320
+ "bytes": 6938,
321
321
  "imports": [
322
322
  {
323
323
  "path": "<runtime>",
@@ -328,7 +328,7 @@
328
328
  "format": "esm"
329
329
  },
330
330
  "src/core/ThemeManager.ts": {
331
- "bytes": 5729,
331
+ "bytes": 5572,
332
332
  "imports": [
333
333
  {
334
334
  "path": "src/utils/Sanitize.ts",
@@ -344,7 +344,7 @@
344
344
  "format": "esm"
345
345
  },
346
346
  "src/core/PosterManager.ts": {
347
- "bytes": 6038,
347
+ "bytes": 5869,
348
348
  "imports": [
349
349
  {
350
350
  "path": "src/utils/VideoFrameCapture.ts",
@@ -360,7 +360,7 @@
360
360
  "format": "esm"
361
361
  },
362
362
  "src/core/ResumeManager.ts": {
363
- "bytes": 7926,
363
+ "bytes": 7690,
364
364
  "imports": [
365
365
  {
366
366
  "path": "src/utils/DOMUtils.ts",
@@ -386,7 +386,7 @@
386
386
  "format": "esm"
387
387
  },
388
388
  "src/core/ResponsiveManager.ts": {
389
- "bytes": 9145,
389
+ "bytes": 8914,
390
390
  "imports": [
391
391
  {
392
392
  "path": "src/core/PseudoFullscreen.ts",
@@ -402,7 +402,7 @@
402
402
  "format": "esm"
403
403
  },
404
404
  "src/core/MetadataAlertsManager.ts": {
405
- "bytes": 18623,
405
+ "bytes": 18109,
406
406
  "imports": [
407
407
  {
408
408
  "path": "src/utils/PerformanceUtils.ts",
@@ -417,14 +417,30 @@
417
417
  ],
418
418
  "format": "esm"
419
419
  },
420
+ "src/core/DescriptionSpeechManager.ts": {
421
+ "bytes": 6702,
422
+ "imports": [
423
+ {
424
+ "path": "<runtime>",
425
+ "kind": "import-statement",
426
+ "external": true
427
+ }
428
+ ],
429
+ "format": "esm"
430
+ },
420
431
  "src/core/AudioDescriptionManager.ts": {
421
- "bytes": 30638,
432
+ "bytes": 32816,
422
433
  "imports": [
423
434
  {
424
435
  "path": "src/controls/CaptionManager.ts",
425
436
  "kind": "import-statement",
426
437
  "original": "../controls/CaptionManager.js"
427
438
  },
439
+ {
440
+ "path": "src/core/DescriptionSpeechManager.ts",
441
+ "kind": "import-statement",
442
+ "original": "./DescriptionSpeechManager.js"
443
+ },
428
444
  {
429
445
  "path": "<runtime>",
430
446
  "kind": "import-statement",
@@ -434,7 +450,7 @@
434
450
  "format": "esm"
435
451
  },
436
452
  "src/utils/DraggableResizable.ts": {
437
- "bytes": 33702,
453
+ "bytes": 32705,
438
454
  "imports": [
439
455
  {
440
456
  "path": "<runtime>",
@@ -445,7 +461,7 @@
445
461
  "format": "esm"
446
462
  },
447
463
  "src/utils/FormUtils.ts": {
448
- "bytes": 2379,
464
+ "bytes": 2284,
449
465
  "imports": [
450
466
  {
451
467
  "path": "src/utils/DOMUtils.ts",
@@ -492,12 +508,12 @@
492
508
  "format": "esm"
493
509
  },
494
510
  "src/utils/DraggablePanelMenu.ts": {
495
- "bytes": 7637,
511
+ "bytes": 7442,
496
512
  "imports": [],
497
513
  "format": "esm"
498
514
  },
499
515
  "src/utils/DraggablePanel.ts": {
500
- "bytes": 18513,
516
+ "bytes": 17974,
501
517
  "imports": [
502
518
  {
503
519
  "path": "src/utils/DOMUtils.ts",
@@ -528,7 +544,7 @@
528
544
  "format": "esm"
529
545
  },
530
546
  "src/core/SignLanguageManager.ts": {
531
- "bytes": 50115,
547
+ "bytes": 48807,
532
548
  "imports": [
533
549
  {
534
550
  "path": "src/utils/DOMUtils.ts",
@@ -569,7 +585,7 @@
569
585
  "format": "esm"
570
586
  },
571
587
  "src/core/FloatingPlayerManager.ts": {
572
- "bytes": 26582,
588
+ "bytes": 25908,
573
589
  "imports": [
574
590
  {
575
591
  "path": "src/utils/DOMUtils.ts",
@@ -600,7 +616,7 @@
600
616
  "format": "esm"
601
617
  },
602
618
  "src/controls/TranscriptManager.ts": {
603
- "bytes": 91285,
619
+ "bytes": 88859,
604
620
  "imports": [
605
621
  {
606
622
  "path": "src/utils/DOMUtils.ts",
@@ -671,7 +687,7 @@
671
687
  "format": "esm"
672
688
  },
673
689
  "src/renderers/YouTubeRenderer.ts": {
674
- "bytes": 8595,
690
+ "bytes": 8305,
675
691
  "imports": [
676
692
  {
677
693
  "path": "src/utils/ScriptLoader.ts",
@@ -687,7 +703,7 @@
687
703
  "format": "esm"
688
704
  },
689
705
  "src/renderers/VimeoRenderer.ts": {
690
- "bytes": 8670,
706
+ "bytes": 8372,
691
707
  "imports": [
692
708
  {
693
709
  "path": "src/utils/ScriptLoader.ts",
@@ -703,7 +719,7 @@
703
719
  "format": "esm"
704
720
  },
705
721
  "src/renderers/HLSRenderer.ts": {
706
- "bytes": 34651,
722
+ "bytes": 33707,
707
723
  "imports": [
708
724
  {
709
725
  "path": "src/utils/ScriptLoader.ts",
@@ -724,7 +740,7 @@
724
740
  "format": "esm"
725
741
  },
726
742
  "src/renderers/DASHRenderer.ts": {
727
- "bytes": 38277,
743
+ "bytes": 37200,
728
744
  "imports": [
729
745
  {
730
746
  "path": "src/utils/ScriptLoader.ts",
@@ -740,7 +756,7 @@
740
756
  "format": "esm"
741
757
  },
742
758
  "src/renderers/SoundCloudRenderer.ts": {
743
- "bytes": 13734,
759
+ "bytes": 13297,
744
760
  "imports": [
745
761
  {
746
762
  "path": "src/utils/ScriptLoader.ts",
@@ -756,7 +772,7 @@
756
772
  "format": "esm"
757
773
  },
758
774
  "src/core/Player.ts": {
759
- "bytes": 104259,
775
+ "bytes": 102940,
760
776
  "imports": [
761
777
  {
762
778
  "path": "src/utils/EventEmitter.ts",
@@ -907,7 +923,7 @@
907
923
  "format": "esm"
908
924
  },
909
925
  "src/features/PlaylistManager.ts": {
910
- "bytes": 64639,
926
+ "bytes": 63309,
911
927
  "imports": [
912
928
  {
913
929
  "path": "src/utils/DOMUtils.ts",
@@ -948,7 +964,7 @@
948
964
  "format": "esm"
949
965
  },
950
966
  "src/index.ts": {
951
- "bytes": 6832,
967
+ "bytes": 6801,
952
968
  "imports": [
953
969
  {
954
970
  "path": "src/core/Player.ts",
@@ -1034,8 +1050,11 @@
1034
1050
  "src/renderers/HTML5Renderer.ts": {
1035
1051
  "bytesInOutput": 11899
1036
1052
  },
1053
+ "src/core/DescriptionSpeechManager.ts": {
1054
+ "bytesInOutput": 6832
1055
+ },
1037
1056
  "src/core/AudioDescriptionManager.ts": {
1038
- "bytesInOutput": 24883
1057
+ "bytesInOutput": 27826
1039
1058
  },
1040
1059
  "src/utils/DraggableResizable.ts": {
1041
1060
  "bytesInOutput": 30761
@@ -1083,7 +1102,7 @@
1083
1102
  "bytesInOutput": 1054
1084
1103
  },
1085
1104
  "src/core/Player.ts": {
1086
- "bytesInOutput": 85990
1105
+ "bytesInOutput": 86657
1087
1106
  },
1088
1107
  "src/controls/ControlBar.ts": {
1089
1108
  "bytesInOutput": 127310
@@ -1122,13 +1141,13 @@
1122
1141
  "bytesInOutput": 15264
1123
1142
  },
1124
1143
  "src/features/PlaylistManager.ts": {
1125
- "bytesInOutput": 48005
1144
+ "bytesInOutput": 48299
1126
1145
  },
1127
1146
  "src/index.ts": {
1128
- "bytesInOutput": 5217
1147
+ "bytesInOutput": 5385
1129
1148
  }
1130
1149
  },
1131
- "bytes": 808336
1150
+ "bytes": 819377
1132
1151
  }
1133
1152
  }
1134
1153
  }
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * VidPly v1.2.1 - Universal, Accessible Video Player
3
+ * (c) 2026 Matthias Peltzer
4
+ * Released under GPL-2.0-or-later License
5
+ */
6
+ import{CaptionManager as e}from"./vidply.chunk-XXUH7ADU.min.js";import"./vidply.chunk-X2FQEQYR.min.js";import"./vidply.chunk-M76ABMKB.min.js";import"./vidply.chunk-6ECBIYVI.min.js";var t=class{player;enabled=!1;descriptionTrack=null;cueChangeHandler=null;seekedHandler=null;wasPlayingBeforeCue=!1;speaking=!1;lastSpokenCueKey=null;_pendingUtterance=null;constructor(e){this.player=e}canUseSpeech(){return!1!==this.player.options.audioDescriptionSpeech&&"undefined"!=typeof window&&"speechSynthesis"in window}findDescriptionTrack(){const e=(this.player.element?Array.from(this.player.element.textTracks||[]):[]).filter(e=>"descriptions"===e.kind&&!e._vidplyStale);if(0===e.length)return null;const t=this.player.captionManager?.currentTrack?.track?.language;if(t){const i=e.find(e=>e.language===t);if(i)return i}return e[0]??null}enable(){const e=this.findDescriptionTrack();return!!e&&(this.canUseSpeech()?(this.descriptionTrack=e,e.mode="hidden",this.cueChangeHandler=()=>{this.handleCueChange()},e.addEventListener("cuechange",this.cueChangeHandler),this.seekedHandler=()=>{this.cancelSpeech(),this.lastSpokenCueKey=null,this.handleCueChange()},this.player.on("seeked",this.seekedHandler),this.enabled=!0,this.handleCueChange(),!0):(e.mode="showing",!0))}disable(){this.cancelSpeech(),this.lastSpokenCueKey=null,this.enabled=!1,this.descriptionTrack&&this.cueChangeHandler&&this.descriptionTrack.removeEventListener("cuechange",this.cueChangeHandler),this.seekedHandler&&this.player.off("seeked",this.seekedHandler),this.descriptionTrack&&(this.descriptionTrack.mode="hidden"),this.cueChangeHandler=null,this.seekedHandler=null,this.descriptionTrack=null,this.wasPlayingBeforeCue=!1}handleCueChange(){if(!this.enabled||!this.descriptionTrack||!this.canUseSpeech())return;const e=this.descriptionTrack.activeCues;if(!e||0===e.length)return;const t=e[0],i=t.text?.trim();if(!i)return;const a=`${t.startTime}:${t.endTime}:${i}`;this.speaking&&this.lastSpokenCueKey===a||(this.lastSpokenCueKey!==a||this.player.state.playing)&&this.speakCue(t,a)}speakCue(e,t){if(!this.canUseSpeech())return;if(this.player.state.paused&&!this.speaking&&!this.wasPlayingBeforeCue)return;this.cancelSpeech(),this.wasPlayingBeforeCue=this.player.state.playing,this.wasPlayingBeforeCue&&this.player.pause(),this.speaking=!0,this.lastSpokenCueKey=t;const i={time:e.startTime,endTime:e.endTime,text:e.text.trim(),cue:e};this.player.emit("audiodescriptioncuestart",i);const a=new SpeechSynthesisUtterance(i.text);a.lang=this.descriptionTrack?.language||this.player.options.language||"en";const s=()=>{this._pendingUtterance===a&&(this._pendingUtterance=null,this.speaking=!1,this.player.emit("audiodescriptioncueend",i),(!1!==this.player.options.audioDescriptionExtended?this.wasPlayingBeforeCue:this.wasPlayingBeforeCue&&this.player.state.currentTime<e.endTime)&&this.enabled&&this.player.play(),this.wasPlayingBeforeCue=!1)};a.onend=s,a.onerror=s,this._pendingUtterance=a,window.speechSynthesis.speak(a)}cancelSpeech(){"undefined"!=typeof window&&window.speechSynthesis&&window.speechSynthesis.cancel(),this._pendingUtterance=null,this.speaking=!1,this.wasPlayingBeforeCue=!1}destroy(){this.disable()}},i=class{player;captionTracks;desiredState;enabled;originalSource;sourceElement;src;speechManager;constructor(e){this.player=e,this.enabled=!1,this.desiredState=!1,this.src=e.options.audioDescriptionSrc,this.sourceElement=null,this.originalSource=null,this.captionTracks=[],this.speechManager=null}_hasSwapSource(){const e=this.player.sourceElements.some(e=>e.getAttribute("data-desc-src"));return Boolean(this.src||e)}_hasDescriptionsTrack(){return Boolean(this.player.findTextTrack("descriptions"))}resolveDeliveryMode(){const e=this.player.options.audioDescriptionMode??"auto",t=this._hasSwapSource(),i=this._hasDescriptionsTrack();return"swap"===e?t?"swap":"none":"vtt_speech"===e?i?"vtt_speech":"none":t?"swap":i?"vtt_speech":"none"}_ensureSpeechManager(){return this.speechManager||(this.speechManager=new t(this.player)),this.speechManager}initFromSourceElements(e,t){for(const t of e){const e=t.getAttribute("data-desc-src"),i=t.getAttribute("data-orig-src");if(e||i){if(this.sourceElement||(this.sourceElement=t),i)this.originalSource||(this.originalSource=i),this.player.originalSrc||(this.player.originalSrc=i);else{const e=t.getAttribute("src");!this.originalSource&&e&&(this.originalSource=e),!this.player.originalSrc&&e&&(this.player.originalSrc=e)}e&&!this.src&&(this.src=e)}}t.forEach(e=>{const t=e.getAttribute("kind"),i=e.getAttribute("data-desc-src");("captions"===t||"subtitles"===t||"chapters"===t||"descriptions"===t)&&i&&e instanceof HTMLTrackElement&&(this.captionTracks.push({trackElement:e,originalSrc:e.getAttribute("src"),describedSrc:i,originalTrackSrc:e.getAttribute("data-orig-src")||e.getAttribute("src"),explicit:!0}),this.player.log(`Found explicit described ${t} track: ${e.getAttribute("src")} -> ${i}`))})}isAvailable(){const e=this.resolveDeliveryMode();return"swap"===e||"vtt_speech"===e||this.captionTracks.length>0}async enable(){const e=this.resolveDeliveryMode(),t=this.captionTracks.length>0;if("none"===e&&!t)return void console.warn("VidPly: No audio description source, descriptions track, or tracks provided");if(this.desiredState=!0,"vtt_speech"===e)return this._ensureSpeechManager().enable()?(this.enabled=!0,this.player.state.audioDescriptionEnabled=!0,void this.player.emit("audiodescriptionenabled")):void console.warn("VidPly: No descriptions track available for VTT speech mode");const i=this.player.state.currentTime,a=this.player.state.playing,s=this.player.element.poster||this.player.element.getAttribute("poster")||this.player.options.poster,r=i<.1&&!a,n=this._getCurrentCaptionText();this.sourceElement?await this._enableWithSourceElement(i,a,s,r,n):this.src?await this._enableWithDirectSrc(i,a,s,r):t&&(await this._swapCaptionTracks(!0),this.enabled=!0,this.player.emit("audiodescriptionenabled"))}async disable(){if(this.desiredState=!1,this.speechManager?.enabled)return this.speechManager.disable(),this.enabled=!1,this.player.state.audioDescriptionEnabled=!1,void this.player.emit("audiodescriptiondisabled");if(!this.sourceElement&&!this.src&&this.captionTracks.length>0)return await this._swapCaptionTracks(!1),this.enabled=!1,void this.player.emit("audiodescriptiondisabled");if(!this.player.originalSrc)return;const e=this.player.state.currentTime,t=this.player.state.playing,i=this.player.element.poster||this.player.element.getAttribute("poster")||this.player.options.poster,a=e<.1&&!t,s=this._getCurrentCaptionText();this.sourceElement?await this._disableWithSourceElement(e,t,i,a,s):this.src&&await this._disableWithDirectSrc(e,t,i)}async toggle(){const e=this.resolveDeliveryMode(),t=this.player.findTextTrack("descriptions"),i=this._hasSwapSource()||this.captionTracks.length>0;"vtt_speech"!==e?t&&!i?"showing"===t.mode?(t.mode="hidden",this.enabled=!1,this.player.state.audioDescriptionEnabled=!1,this.player.emit("audiodescriptiondisabled")):(t.mode="showing",this.enabled=!0,this.player.state.audioDescriptionEnabled=!0,this.player.emit("audiodescriptionenabled")):t&&i?this.enabled?(this.desiredState=!1,await this.disable()):(t.mode="showing",this.desiredState=!0,await this.enable()):i&&(this.enabled?(this.desiredState=!1,await this.disable()):(this.desiredState=!0,await this.enable())):this.enabled?await this.disable():await this.enable()}_getCurrentCaptionText(){return this.player.captionManager&&this.player.captionManager.currentTrack&&this.player.captionManager.currentCue?this.player.captionManager.currentCue.text:null}async _validateTrackExists(e){if("string"!=typeof e||!e)return!1;const t=[],i=this.player.lifecycleSignal;let a;if(i&&t.push(i),"undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout&&t.push(AbortSignal.timeout(8e3)),1===t.length)a=t[0];else if(t.length>1){const e=AbortSignal.any;a=e?e(t):t[0]}try{return(await fetch(e,{method:"HEAD",signal:a})).ok}catch{return!1}}async _swapCaptionTracks(e=!0){if(0===this.captionTracks.length)return[];const t=[],i=this.captionTracks.map(async t=>{if(t.trackElement&&t.describedSrc&&!0===t.explicit){const i=e?t.describedSrc:t.originalSrc;if(!i)return{trackInfo:t,exists:!1};try{return{trackInfo:t,exists:await this._validateTrackExists(i)}}catch{return{trackInfo:t,exists:!1}}}return{trackInfo:t,exists:!1}}),a=(await Promise.all(i)).filter(e=>e.exists);if(a.length>0){const i=new Map;a.forEach(({trackInfo:e})=>{const t=e.trackElement.track;i.set(e,t?{wasShowing:"showing"===t.mode,wasHidden:"hidden"===t.mode}:{wasShowing:!1,wasHidden:!1})});const s=a.map(({trackInfo:e})=>{const t={};Array.from(e.trackElement.attributes).forEach(e=>{t[e.name]=e.value});const i={trackInfo:e,oldSrc:e.trackElement.getAttribute("src"),parent:e.trackElement.parentNode,nextSibling:e.trackElement.nextSibling,attributes:t};return e.trackElement.remove(),i});this.player.element.load(),await new Promise(a=>{this.player.setManagedTimeout(()=>{s.forEach(({trackInfo:i,parent:a,nextSibling:s,attributes:r})=>{const n=e?i.describedSrc:i.originalSrc;if(!n)return;t.push(i);const l=document.createElement("track");l.setAttribute("src",n),Object.keys(r).forEach(e=>{const t=r[e];"src"!==e&&"data-desc-src"!==e&&void 0!==t&&l.setAttribute(e,t)});const c=a||this.player.element;s&&s.parentNode?c.insertBefore(l,s):c.appendChild(l),i.trackElement=l}),this.player.invalidateTrackCache();const r=()=>{this.player.setManagedTimeout(()=>{t.forEach(e=>{const t=e.trackElement,a=t.track;if(a){const s=i.get(e)||{wasShowing:!1,wasHidden:!1};a.mode="hidden";const r=()=>{a.mode=s.wasShowing||s.wasHidden?"hidden":"disabled"};t.readyState>=2?r():(t.addEventListener("load",r,{once:!0}),t.addEventListener("error",r,{once:!0}))}})},300)};this.player.element.readyState>=1?this.player.setManagedTimeout(r,200):(this.player.element.addEventListener("loadedmetadata",r,{once:!0}),this.player.setManagedTimeout(r,2e3)),a()},100)})}return t}_updateSourceElements(e=!0){const t=this.player.sourceElements,i=[];t.forEach(t=>{const a=t.getAttribute("data-desc-src"),s=t.getAttribute("src");if(a){const r=t.getAttribute("type"),n=t.getAttribute("data-orig-src")||s;i.push({src:e?a:n,type:r,origSrc:n,descSrc:a})}else i.push({src:t.getAttribute("src"),type:t.getAttribute("type"),origSrc:null,descSrc:null})}),this.player.element.hasAttribute("src")&&this.player.element.removeAttribute("src"),t.forEach(e=>e.remove()),i.forEach(e=>{if(!e.src)return;const t=document.createElement("source");t.setAttribute("src",e.src),e.type&&t.setAttribute("type",e.type),e.origSrc&&t.setAttribute("data-orig-src",e.origSrc),e.descSrc&&t.setAttribute("data-desc-src",e.descSrc);const i=this.player.element.querySelector("track");i?this.player.element.insertBefore(t,i):this.player.element.appendChild(t)}),this.player._sourceElementsDirty=!0,this.player._sourceElementsCache=null}async _waitForMediaReady(e=!1){await new Promise(e=>{if(this.player.element.readyState>=1)e();else{const t=()=>{this.player.element.removeEventListener("loadedmetadata",t),e()};this.player.element.addEventListener("loadedmetadata",t)}}),await new Promise(e=>setTimeout(e,300)),e&&await new Promise(e=>{if(this.player.element.readyState>=3)e();else{const t=()=>{this.player.element.removeEventListener("canplay",t),this.player.element.removeEventListener("canplaythrough",t),e()};this.player.element.addEventListener("canplay",t,{once:!0}),this.player.element.addEventListener("canplaythrough",t,{once:!0}),setTimeout(()=>{this.player.element.removeEventListener("canplay",t),this.player.element.removeEventListener("canplaythrough",t),e()},3e3)}})}async _restorePlaybackState(e,t,i,a){let s=e;if(a&&this.player.captionManager&&this.player.captionManager.tracks.length>0){await new Promise(e=>setTimeout(e,500));const t=this.player.findMatchingCaptionTime(a,this.player.captionManager.tracks);null!==t&&(s=t,this.player.options.debug&&this.player.log(`[VidPly] Syncing via caption: ${e}s -> ${s}s`))}s>0&&(this.player.seek(s),await new Promise(e=>setTimeout(e,100))),t?(await this.player.play(),this.player.setManagedTimeout(()=>{this.player.hidePosterOverlay()},100)):(this.player.pause(),i||this.player.hidePosterOverlay())}async _enableWithSourceElement(e,t,i,a,s){await this._swapCaptionTracks(!0),this._updateSourceElements(!0),i&&"VIDEO"===this.player.element.tagName&&(this.player.element.poster=i),this.player.element.load(),await this._waitForMediaReady(e>0||t),await this._restorePlaybackState(e,t,a,s),this.desiredState&&(this.enabled=!0,this.player.state.audioDescriptionEnabled=!0,this.player.emit("audiodescriptionenabled"),this._reloadTranscript())}async _enableWithDirectSrc(e,t,i,a){await this._swapCaptionTracks(!0),i&&"VIDEO"===this.player.element.tagName&&(this.player.element.poster=i),this.src&&(this.player.element.src=this.src,await this._waitForMediaReady(e>0||t),e>0&&(this.player.seek(e),await new Promise(e=>setTimeout(e,100))),t?await this.player.play():(this.player.pause(),a||this.player.hidePosterOverlay()),this.desiredState&&(this.enabled=!0,this.player.state.audioDescriptionEnabled=!0,this.player.emit("audiodescriptionenabled"),this._reloadTranscript()))}async _disableWithSourceElement(t,i,a,s,r){await this._swapCaptionTracks(!1),this._updateSourceElements(!1),a&&"VIDEO"===this.player.element.tagName&&(this.player.element.poster=a),this.player.element.load(),this.player.invalidateTrackCache(),await this._waitForMediaReady(t>0||i),await this._restorePlaybackState(t,i,s,r),this.player.captionManager&&(this.player.captionManager.destroy(),this.player.captionManager=new e(this.player)),this.desiredState||(this.enabled=!1,this.player.state.audioDescriptionEnabled=!1,this.player.emit("audiodescriptiondisabled"),this._reloadTranscript())}async _disableWithDirectSrc(e,t,i){await this._swapCaptionTracks(!1),i&&"VIDEO"===this.player.element.tagName&&(this.player.element.poster=i);const a=this.originalSource||this.player.originalSrc;a&&(this.player.element.src=a,this.player.element.load(),await this._waitForMediaReady(e>0||t),e>0&&this.player.seek(e),t&&await this.player.play(),this.desiredState||(this.enabled=!1,this.player.state.audioDescriptionEnabled=!1,this.player.emit("audiodescriptiondisabled"),this._reloadTranscript()))}_reloadTranscript(){this.player.transcriptManager&&this.player.transcriptManager.isVisible&&this.player.setManagedTimeout(()=>{this.player.transcriptManager&&this.player.transcriptManager.loadTranscriptData&&this.player.transcriptManager.loadTranscriptData()},800)}updateSources(e){this.speechManager?.destroy(),this.speechManager=null,this.src=e||null,this.enabled=!1,this.desiredState=!1,this.sourceElement=null,this.originalSource=null,this.captionTracks=[]}reinitialize(){this.player.invalidateTrackCache(),this.initFromSourceElements(this.player.sourceElements,this.player.trackElements)}destroy(){this.speechManager?.destroy(),this.speechManager=null,this.enabled=!1,this.desiredState=!1,this.captionTracks=[],this.sourceElement=null,this.originalSource=null}};export{i as AudioDescriptionManager};
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VidPly v1.2.0 - Universal, Accessible Video Player
2
+ * VidPly v1.2.1 - Universal, Accessible Video Player
3
3
  * (c) 2026 Matthias Peltzer
4
4
  * Released under GPL-2.0-or-later License
5
5
  */
6
- import{focusFirstElement as e}from"./vidply.chunk-P3PQBY7N.min.js";import{DOMUtils as t,i18n as a}from"./vidply.chunk-EKEYJWMG.min.js";function n(e){const t=e.replace("captions","");return t.charAt(0).toLowerCase()+t.slice(1)}function o(e,a,o,i){const s=t.createElement("div",{className:`${e.options.classPrefix}-style-group`}),l=`${e.options.classPrefix}-${o}-${Date.now()}`,r=t.createElement("label",{textContent:a,attributes:{for:l},style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});s.appendChild(r);const p=t.createElement("select",{className:`${e.options.classPrefix}-style-select`,attributes:{id:l},style:{width:"100%",padding:"6px",background:"var(--vidply-white)",border:"1px solid var(--vidply-white-10)",borderRadius:"4px",color:"var(--vidply-black)",fontSize:"13px"}}),c=e.options[o];return i.forEach(e=>{const a=t.createElement("option",{textContent:e.label,attributes:{value:e.value}});e.value===c&&(a.selected=!0),p.appendChild(a)}),p.addEventListener("mousedown",e=>{e.stopPropagation()}),p.addEventListener("click",e=>{e.stopPropagation()}),p.addEventListener("change",t=>{t.stopPropagation(),e.options[o]=t.target.value,e.captionManager&&e.captionManager.setCaptionStyle(n(o),t.target.value)}),s.appendChild(p),s}function i(e,a,o){const i=t.createElement("div",{className:`${e.options.classPrefix}-style-group`}),s=`${e.options.classPrefix}-${o}-${Date.now()}`,l=t.createElement("label",{textContent:a,attributes:{for:s},style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});i.appendChild(l);const r=t.createElement("input",{attributes:{id:s,type:"color",value:String(e.options[o]??"")},style:{width:"100%",height:"32px",padding:"2px",background:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"4px",cursor:"pointer"}});return r.addEventListener("mousedown",e=>{e.stopPropagation()}),r.addEventListener("click",e=>{e.stopPropagation()}),r.addEventListener("change",t=>{t.stopPropagation(),e.options[o]=t.target.value,e.captionManager&&e.captionManager.setCaptionStyle(n(o),t.target.value)}),i.appendChild(r),i}function s(s,l){const r=s.player,p=document.querySelector(`.${r.options.classPrefix}-caption-style-menu`);if(p)return p.remove(),l.setAttribute("aria-expanded","false"),void(s.openMenu===p&&(s.openMenu=null,s.openMenuButton=null));const c=`${r.options.classPrefix}-caption-style-label-${r.instanceId||""}`,d=t.createElement("div",{className:`${r.options.classPrefix}-caption-style-menu ${r.options.classPrefix}-menu ${r.options.classPrefix}-settings-menu`,attributes:{role:"dialog","aria-modal":"false","aria-labelledby":c}}),u=t.createElement("h2",{textContent:a.t("player.captionStyling"),attributes:{id:c,class:`${r.options.classPrefix}-sr-only`},style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:"0"}});if(d.appendChild(u),d.addEventListener("click",e=>{e.stopPropagation()}),!r.captionManager||0===r.captionManager.tracks.length){const e=t.createElement("div",{className:`${r.options.classPrefix}-menu-item`,textContent:a.t("player.noCaptions"),attributes:{role:"status"},style:{opacity:"0.5",cursor:"default",padding:"12px 16px"}});return d.appendChild(e),d.style.visibility="hidden",d.style.display="block",s.insertMenuIntoDOM(d,l),s.positionMenu(d,l,!0),requestAnimationFrame(()=>{d.style.visibility="visible"}),void s.attachMenuCloseHandler(d,l,!0)}d.appendChild(o(r,a.t("styleLabels.fontSize"),"captionsFontSize",[{label:a.t("fontSizes.small"),value:"87.5%"},{label:a.t("fontSizes.normal"),value:"100%"},{label:a.t("fontSizes.large"),value:"125%"},{label:a.t("fontSizes.xlarge"),value:"150%"}])),d.appendChild(o(r,a.t("styleLabels.font"),"captionsFontFamily",[{label:a.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:a.t("fontFamilies.serif"),value:"serif"},{label:a.t("fontFamilies.monospace"),value:"monospace"}])),d.appendChild(i(r,a.t("styleLabels.textColor"),"captionsColor")),d.appendChild(i(r,a.t("styleLabels.background"),"captionsBackgroundColor")),d.appendChild(((e,a,o)=>{const i=t.createElement("div",{className:`${e.options.classPrefix}-style-group`}),s=`${e.options.classPrefix}-${o}-${Date.now()}`,l=t.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"}}),r=t.createElement("label",{textContent:a,attributes:{for:s},style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}}),p=t.createElement("span",{textContent:Math.round(100*Number(e.options[o]??0))+"%",style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}});l.appendChild(r),l.appendChild(p),i.appendChild(l);const c=t.createElement("input",{attributes:{id:s,type:"range",min:"0",max:"1",step:"0.1",value:String(e.options[o])},style:{width:"100%",cursor:"pointer"}});return c.addEventListener("mousedown",e=>{e.stopPropagation()}),c.addEventListener("click",e=>{e.stopPropagation()}),c.addEventListener("input",t=>{t.stopPropagation();const a=parseFloat(t.target.value);p.textContent=Math.round(100*a)+"%",e.options[o]=a,e.captionManager&&e.captionManager.setCaptionStyle(n(o),a)}),i.appendChild(c),i})(r,a.t("styleLabels.opacity"),"captionsOpacity")),d.style.minWidth="220px",d.style.visibility="hidden",d.style.display="block",s.insertMenuIntoDOM(d,l),s.positionMenu(d,l,!0),requestAnimationFrame(()=>{d.style.visibility="visible"}),s.attachMenuCloseHandler(d,l,!0),e(d,`.${r.options.classPrefix}-style-select`)}export{s as showCaptionStyleMenu};
6
+ import{focusFirstElement as e}from"./vidply.chunk-L4O44K63.min.js";import{DOMUtils as t,i18n as a}from"./vidply.chunk-6ECBIYVI.min.js";function n(e){const t=e.replace("captions","");return t.charAt(0).toLowerCase()+t.slice(1)}function o(e,a,o,i){const s=t.createElement("div",{className:`${e.options.classPrefix}-style-group`}),l=`${e.options.classPrefix}-${o}-${Date.now()}`,r=t.createElement("label",{textContent:a,attributes:{for:l},style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});s.appendChild(r);const p=t.createElement("select",{className:`${e.options.classPrefix}-style-select`,attributes:{id:l},style:{width:"100%",padding:"6px",background:"var(--vidply-white)",border:"1px solid var(--vidply-white-10)",borderRadius:"4px",color:"var(--vidply-black)",fontSize:"13px"}}),c=e.options[o];return i.forEach(e=>{const a=t.createElement("option",{textContent:e.label,attributes:{value:e.value}});e.value===c&&(a.selected=!0),p.appendChild(a)}),p.addEventListener("mousedown",e=>{e.stopPropagation()}),p.addEventListener("click",e=>{e.stopPropagation()}),p.addEventListener("change",t=>{t.stopPropagation(),e.options[o]=t.target.value,e.captionManager&&e.captionManager.setCaptionStyle(n(o),t.target.value)}),s.appendChild(p),s}function i(e,a,o){const i=t.createElement("div",{className:`${e.options.classPrefix}-style-group`}),s=`${e.options.classPrefix}-${o}-${Date.now()}`,l=t.createElement("label",{textContent:a,attributes:{for:s},style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});i.appendChild(l);const r=t.createElement("input",{attributes:{id:s,type:"color",value:String(e.options[o]??"")},style:{width:"100%",height:"32px",padding:"2px",background:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"4px",cursor:"pointer"}});return r.addEventListener("mousedown",e=>{e.stopPropagation()}),r.addEventListener("click",e=>{e.stopPropagation()}),r.addEventListener("change",t=>{t.stopPropagation(),e.options[o]=t.target.value,e.captionManager&&e.captionManager.setCaptionStyle(n(o),t.target.value)}),i.appendChild(r),i}function s(s,l){const r=s.player,p=document.querySelector(`.${r.options.classPrefix}-caption-style-menu`);if(p)return p.remove(),l.setAttribute("aria-expanded","false"),void(s.openMenu===p&&(s.openMenu=null,s.openMenuButton=null));const c=`${r.options.classPrefix}-caption-style-label-${r.instanceId||""}`,d=t.createElement("div",{className:`${r.options.classPrefix}-caption-style-menu ${r.options.classPrefix}-menu ${r.options.classPrefix}-settings-menu`,attributes:{role:"dialog","aria-modal":"false","aria-labelledby":c}}),u=t.createElement("h2",{textContent:a.t("player.captionStyling"),attributes:{id:c,class:`${r.options.classPrefix}-sr-only`},style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:"0"}});if(d.appendChild(u),d.addEventListener("click",e=>{e.stopPropagation()}),!r.captionManager||0===r.captionManager.tracks.length){const e=t.createElement("div",{className:`${r.options.classPrefix}-menu-item`,textContent:a.t("player.noCaptions"),attributes:{role:"status"},style:{opacity:"0.5",cursor:"default",padding:"12px 16px"}});return d.appendChild(e),d.style.visibility="hidden",d.style.display="block",s.insertMenuIntoDOM(d,l),s.positionMenu(d,l,!0),requestAnimationFrame(()=>{d.style.visibility="visible"}),void s.attachMenuCloseHandler(d,l,!0)}d.appendChild(o(r,a.t("styleLabels.fontSize"),"captionsFontSize",[{label:a.t("fontSizes.small"),value:"87.5%"},{label:a.t("fontSizes.normal"),value:"100%"},{label:a.t("fontSizes.large"),value:"125%"},{label:a.t("fontSizes.xlarge"),value:"150%"}])),d.appendChild(o(r,a.t("styleLabels.font"),"captionsFontFamily",[{label:a.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:a.t("fontFamilies.serif"),value:"serif"},{label:a.t("fontFamilies.monospace"),value:"monospace"}])),d.appendChild(i(r,a.t("styleLabels.textColor"),"captionsColor")),d.appendChild(i(r,a.t("styleLabels.background"),"captionsBackgroundColor")),d.appendChild(((e,a,o)=>{const i=t.createElement("div",{className:`${e.options.classPrefix}-style-group`}),s=`${e.options.classPrefix}-${o}-${Date.now()}`,l=t.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"}}),r=t.createElement("label",{textContent:a,attributes:{for:s},style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}}),p=t.createElement("span",{textContent:Math.round(100*Number(e.options[o]??0))+"%",style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}});l.appendChild(r),l.appendChild(p),i.appendChild(l);const c=t.createElement("input",{attributes:{id:s,type:"range",min:"0",max:"1",step:"0.1",value:String(e.options[o])},style:{width:"100%",cursor:"pointer"}});return c.addEventListener("mousedown",e=>{e.stopPropagation()}),c.addEventListener("click",e=>{e.stopPropagation()}),c.addEventListener("input",t=>{t.stopPropagation();const a=parseFloat(t.target.value);p.textContent=Math.round(100*a)+"%",e.options[o]=a,e.captionManager&&e.captionManager.setCaptionStyle(n(o),a)}),i.appendChild(c),i})(r,a.t("styleLabels.opacity"),"captionsOpacity")),d.style.minWidth="220px",d.style.visibility="hidden",d.style.display="block",s.insertMenuIntoDOM(d,l),s.positionMenu(d,l,!0),requestAnimationFrame(()=>{d.style.visibility="visible"}),s.attachMenuCloseHandler(d,l,!0),e(d,`.${r.options.classPrefix}-style-select`)}export{s as showCaptionStyleMenu};
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VidPly v1.2.0 - Universal, Accessible Video Player
2
+ * VidPly v1.2.1 - Universal, Accessible Video Player
3
3
  * (c) 2026 Matthias Peltzer
4
4
  * Released under GPL-2.0-or-later License
5
5
  */
6
- import{loadScriptOnce as t}from"./vidply.chunk-P4UXOHWA.min.js";var e=class{player;media;dash;isStreaming=!0;_dashSourceLoaded;_pendingSrc;_dashSubtitleTracksCount;_dashTextTracks;_cueUpdateTimer;_captionEnabledHandler;_captionDisabledHandler;_lastKnownCueCount;_dashTextIsTtml;_pendingTimeouts;_ttmlDiv;_manifestUrl;_listenerController;_pendingReadyHandler;constructor(t){this.player=t,this.media=t.element,this.dash=null,this._dashSourceLoaded=!1,this._pendingSrc=null,this._dashSubtitleTracksCount=void 0,this._dashTextTracks=[],this._cueUpdateTimer=null,this._captionEnabledHandler=null,this._captionDisabledHandler=null,this._lastKnownCueCount=0,this._dashTextIsTtml=!1,this._pendingTimeouts=[],this._ttmlDiv=null,this._manifestUrl=null,this._listenerController=new AbortController,this._pendingReadyHandler=null}async init(){this.player.log("Using dash.js for DASH support"),await this.initDashJs()}async initDashJs(){this.media.controls=!1,this.media.removeAttribute("controls"),window.dashjs||await this.loadDashJs();const t=Array.from(this.media.querySelectorAll("source"));let e=null;t.length>0&&(e=t[0]?.getAttribute("src")??null,t.forEach(t=>t.remove()),this.player.log("Removed <source> elements for HTML5 validity (dash.js uses MSE)"));const i=window.dashjs;if(!i)throw new Error("dash.js not available");this.dash=i.MediaPlayer().create(),this.dash.updateSettings({debug:{logLevel:this.player.options.debug?4:0},streaming:{selectionModeForInitialTrack:"firstTrack",buffer:{bufferTimeAtTopQuality:30,bufferTimeAtTopQualityLongForm:60,bufferTimeDefault:12,bufferToKeep:20,bufferPruningInterval:10},retryAttempts:{MPD:4,MediaSegment:6,InitializationSegment:4,BitstreamSwitchingSegment:4},retryIntervals:{MPD:1e3,MediaSegment:1e3,InitializationSegment:1e3,BitstreamSwitchingSegment:1e3},abr:{autoSwitchBitrate:{video:!0,audio:!0}},text:{defaultEnabled:!0}}}),this._ttmlDiv=document.createElement("div"),this._ttmlDiv.className="vidply-dash-ttml",this._ttmlDiv.style.visibility="hidden";const s=this.player.videoWrapper||this.media.parentElement;s&&s.appendChild(this._ttmlDiv),this.dash.initialize(this.media,null,!1),this.dash.attachTTMLRenderingDiv(this._ttmlDiv);let a=this.player.currentSource;if(!a&&e&&(a=e),a||(a=this.player.element.getAttribute("data-vidply-src")),!a){const t=this.player.element.getAttribute("src")||this.player.element.src;t&&!t.startsWith("blob:")&&(a=t)}if(this.player.log(`Loading DASH source: ${a}`,"log"),!a)throw new Error("No DASH source found");this._pendingSrc=a,this._manifestUrl=a,this.dash.attachSource(a),this._dashSourceLoaded=!0,this.player.showPosterOverlay(),this.attachDashEvents(),this.attachMediaEvents(),this._setupCaptionSync()}async loadDashJs(){return t(this.player.options.dashScriptUrl||"https://cdn.jsdelivr.net/npm/dashjs@5.2.0/dist/modern/umd/dash.all.min.js",{integrity:this.player.options.dashScriptIntegrity})}_setTimeout(t,e){const i=setTimeout(()=>{this._pendingTimeouts=this._pendingTimeouts.filter(t=>t!==i),t()},e);return this._pendingTimeouts.push(i),i}attachDashEvents(){const t=window.dashjs,e=this.dash;if(!t||!e)return;const i=t.MediaPlayer.events;e.on(i.MANIFEST_LOADED,(...t)=>{const e=t[0],i=e?.data??e;this.player.log("DASH manifest loaded"),this.player.emit("dashmanifestloaded",i),this.player.container&&this.player.container.classList.remove("vidply-external-controls"),this._setTimeout(()=>{this._checkSubtitleTracks()},500)}),e.on(i.QUALITY_CHANGE_RENDERED,(...t)=>{const e=t[0];"video"===e.mediaType&&(this.player.log("DASH quality changed to index "+e.newQuality),this.player.emit("dashqualitychanged",e))}),e.on(i.TEXT_TRACKS_ADDED,(...t)=>{const i=t[0],s=i?.tracks??[];if(this._dashTextTracks=s,this._dashTextIsTtml=s.some(t=>t.isTTML||/stpp|ttml/i.test(t.codec||"")||/ttml/i.test(t.mimeType||"")),this.player.log(`DASH text tracks added: ${s.length} tracks, format: ${this._dashTextIsTtml?"TTML":"WebVTT"}`),this._dashSubtitleTracksCount=s.length,this.player.emit("dashsubtitletracksupdated",{tracks:s}),this.updateCaptionButtonsForDash(),s.length>0){try{e.setTextTrack(0)}catch{}this._dashTextIsTtml||this._startCueUpdatePolling()}}),e.on(i.STREAM_INITIALIZED,()=>{this.player.log("DASH stream initialized"),this.player.emit("dashstreaminitialized"),this._setTimeout(()=>{const t=this.getQualities();t.length>0&&this.player.emit("dashmanifestparsed",{qualities:t})},300)}),e.on(i.ERROR,(...t)=>{this.handleDashError(t[0])}),e.on(i.FRAGMENT_LOADING_COMPLETED,(...t)=>{const e=t[0];this.player.state.buffering=!1,"text"!==e?.request?.mediaType||this._dashTextIsTtml||this._setTimeout(()=>{const t=this._getTotalCueCount();t>this._lastKnownCueCount&&(this._lastKnownCueCount=t,this.player.emit("textcuesupdate"))},100)})}_getTotalCueCount(){const t=this.media.textTracks;let e=0;if(!t)return e;for(let i=0;i<t.length;i++){const s=t[i];!s||"subtitles"!==s.kind&&"captions"!==s.kind||s._vidplyStale||!s.cues||(e+=s.cues.length)}return e}_isTimeBuffered(t){const e=this.media.buffered;if(!e||0===e.length)return!1;for(let i=0;i<e.length;i++)if(t>=e.start(i)-.25&&t<=e.end(i)+.25)return!0;return!1}_setupCaptionSync(){this._captionEnabledHandler=t=>{this._dashTextIsTtml&&(t.track&&(t.track.mode="showing"),this._ttmlDiv&&(this._ttmlDiv.style.visibility="visible")),this._syncDashTextTrack(t)},this._captionDisabledHandler=()=>{if(this._dashTextIsTtml&&this._ttmlDiv&&(this._ttmlDiv.style.visibility="hidden"),this.dash)try{this.dash.setTextTrack(-1)}catch{}},this.player.on("captionsenabled",this._captionEnabledHandler),this.player.on("captionsdisabled",this._captionDisabledHandler)}_syncDashTextTrack(t){if(!this.dash||!this._dashTextTracks.length)return;const e=t.language;if(!e)return;const i=this._dashTextTracks.findIndex(t=>{const i=t.lang||t.language||t.srclang||"";return!!i&&(i===e||i.startsWith(e)||e.startsWith(i))});if(i>=0){this.player.log(`Syncing DASH text track to index ${i} (${e})`);try{this.dash.setTextTrack(i)}catch{}this._dashTextIsTtml||(this._lastKnownCueCount=0,this._startCueUpdatePolling())}}_startCueUpdatePolling(){this._stopCueUpdatePolling();let t=0,e=0;this._cueUpdateTimer=setInterval(()=>{const i=this._getTotalCueCount();i>t?(t=i,e=0,this.player.emit("textcuesupdate")):(e++,e>=8&&(this._stopCueUpdatePolling(),i>0&&this.player.emit("textcuesupdate")))},500)}_stopCueUpdatePolling(){this._cueUpdateTimer&&(clearInterval(this._cueUpdateTimer),this._cueUpdateTimer=null)}_checkSubtitleTracks(){if(void 0!==this._dashSubtitleTracksCount&&this._dashSubtitleTracksCount>0)return;const t=this.media.textTracks;let e=0;for(let i=0;i<t.length;i++){const s=t[i];!s||"subtitles"!==s.kind&&"captions"!==s.kind||s._vidplyStale||e++}this._dashSubtitleTracksCount=e,this.updateCaptionButtonsForDash()}updateCaptionButtonsForDash(t=0){const e=this._dashSubtitleTracksCount||0,i=()=>{if(this.player.invalidateTrackCache(),e>0){if(this.player.captionManager&&0===this.player.captionManager.refreshTracks()&&t<5){const e=200*(t+1);return this.player.log(`DASH caption tracks not yet on video element, retrying in ${e}ms (attempt ${t+1})`,"info"),void this._setTimeout(()=>{this.updateCaptionButtonsForDash(t+1)},e)}!this._dashTextIsTtml&&this.player.transcriptManager?.isVisible&&(this.player.transcriptManager.loadTranscriptData(),this.player.transcriptManager.updateLanguageSelector()),this.player.controlBar&&(this.player.controlBar.ensureCaptionsButton(),this._dashTextIsTtml||(this.player.controlBar.ensureCaptionStyleButton(),this.player.controlBar.ensureTranscriptButton()))}else this.player.captionManager&&this.player.captionManager.refreshTracks(),this.player.transcriptManager?.isVisible&&this.player.transcriptManager.hideTranscript(),this.player.controlBar&&this.player.controlBar.removeHlsCaptionButtons(!0)};if(this.player.controlBar)return void i();const s=()=>{this.player.off("ready",s),this._pendingReadyHandler=null,i()};this._pendingReadyHandler=s,this.player.on("ready",s)}attachMediaEvents(){const{signal:t}=this._listenerController;this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")},{signal:t}),this.media.addEventListener("durationchange",()=>{const t=this.media.duration;t&&isFinite(t)&&t>0&&(this.player.state.duration=t,this.player.emit("durationchange",t))},{signal:t}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)},{signal:t}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)},{signal:t}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())},{signal:t}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)},{signal:t}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume)},{signal:t}),this.media.addEventListener("seeking",()=>{this.player.state.seeking=!0,this.player.emit("seeking"),this._isTimeBuffered(this.media.currentTime)||(this.player.state.buffering=!0,this.player.emit("waiting"))},{signal:t}),this.media.addEventListener("seeked",()=>{this.player.state.seeking=!1,this.player.emit("seeked")},{signal:t}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")},{signal:t}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")},{signal:t}),this.media.addEventListener("error",()=>{this.player.handleError(this.media.error)},{signal:t})}handleDashError(t){const e=t,i=e?.error??e;if(!i)return;const s=i.code??"",a=i.message||"";this.player.log(`DASH Error - Code: ${s}, Message: ${a}`,"warn"),"number"==typeof s&&s>=100?(this.player.log("Fatal DASH error","error"),this.player.handleError(new Error(`DASH Error: ${s} - ${a}`))):this.player.log("Non-fatal DASH error: "+(a||String(i)),"warn")}ensureLoaded(){if(!this.player.options.deferLoad)return;if(!this.dash)return;if(this._dashSourceLoaded)return;const t=this._pendingSrc||this.player._pendingSource||this.player.currentSource;if(t)try{this.dash.attachSource(t),this._dashSourceLoaded=!0}catch{}}play(){const t=window.scrollX,e=window.scrollY;if(this.player.options.deferLoad&&this.dash&&!this._dashSourceLoaded){const t=this._pendingSrc||this.player.currentSource;if(t)try{this.dash.attachSource(t),this._dashSourceLoaded=!0}catch{}}const i=this.media.play();window.scrollTo(t,e),void 0!==i&&i.catch(t=>{this.player.log("Play failed:",t,"warn")})}pause(){this.media.pause()}seek(t){this.media.currentTime=t}setVolume(t){this.media.volume=t}setMuted(t){this.media.muted=t}setPlaybackSpeed(t){this.media.playbackRate=t}switchQuality(t){this.dash&&(-1===t?"function"==typeof this.dash.setAutoSwitchQualityFor?this.dash.setAutoSwitchQualityFor("video",!0):this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!0}}}}):("function"==typeof this.dash.setAutoSwitchQualityFor?this.dash.setAutoSwitchQualityFor("video",!1):this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!1}}}}),"function"==typeof this.dash.setRepresentationForTypeByIndex?this.dash.setRepresentationForTypeByIndex("video",t):"function"==typeof this.dash.setQualityFor&&this.dash.setQualityFor("video",t,!0)))}getQualities(){if(!this.dash)return[];try{let t=null;if("function"==typeof this.dash.getRepresentationsByType&&(t=this.dash.getRepresentationsByType("video")),t&&t.length>0){const e={};return t.forEach(t=>{const i=Number(t.height)||0;e[i]=(e[i]||0)+1}),t.map((t,i)=>{const s=Number(t.height)||0,a=Number(t.bandwidth||t.bitrate)||0,r=a>0?Math.round(a/1e3):0;let n;return n=s>0&&(e[s]??0)>1&&r>0?`${s}p (${r} kbps)`:s>0?`${s}p`:r>0?`${r} kbps`:"Auto",{index:i,id:t.id,height:t.height,width:t.width,bitrate:a,name:n}})}const e=this.dash.getBitrateInfoListFor("video");if(!e||0===e.length)return[];const i={};return e.forEach(t=>{const e=Number(t.height)||0;i[e]=(i[e]||0)+1}),e.map((t,e)=>{const s=Number(t.height)||0,a=Number(t.bitrate)||0,r=a>0?Math.round(a/1e3):0;let n;return n=s>0&&(i[s]??0)>1&&r>0?`${s}p (${r} kbps)`:s>0?`${s}p`:r>0?`${r} kbps`:"Auto",{index:e,height:t.height,width:t.width,bitrate:t.bitrate,name:n}})}catch{return[]}}getCurrentQuality(){if(!this.dash)return-1;try{if("function"==typeof this.dash.getRepresentationsByType){const t=this.dash.getRepresentationsByType("video"),e=this.dash.getCurrentRepresentationForType?.("video");if(e&&t){const i=t.findIndex(t=>t.id===e.id);if(i>=0)return i}}return this.dash.getQualityFor("video")}catch{return-1}}handlesOwnCaptions(){return this._dashTextIsTtml}activateTextTrackForLanguage(t){if(!this.dash||!this._dashTextTracks.length||!t)return!1;let e=this._dashTextTracks.findIndex(e=>{const i=e.lang||e.language||e.srclang||"";return!!i&&(i===t||i.startsWith(t)||t.startsWith(i))});if(e<0&&(e=this._dashTextTracks.findIndex(e=>(e.label||e.labels||"").toString().toLowerCase().includes(t.toLowerCase()))),e<0)return!1;this.player.log(`Activating DASH text track index ${e} for transcript language "${t}"`);try{this.dash.setTextTrack(e)}catch{}if(this.media.paused){const t=this.media.currentTime,e=this.media.muted;this.media.muted=!0;const i=this.media.play(),s=()=>{this.media&&!this.media.paused&&(this.media.pause(),this.media.muted=e,Math.abs(this.media.currentTime-t)>.5&&(this.media.currentTime=t))};i&&"function"==typeof i.then?i.then(()=>{this._setTimeout(s,250)}).catch(()=>{this.media.muted=e}):this._setTimeout(s,250)}return this._dashTextIsTtml||(this._lastKnownCueCount=0,this._startCueUpdatePolling()),!0}getTextTrackURLs(){if(!this.dash||!this._manifestUrl)return[];try{const t=this.dash.getManifest?.();if(!t)return[];const e=this._manifestUrl.substring(0,this._manifestUrl.lastIndexOf("/")+1),i=[],s=t.Period||t.period||t.periods||t,a=Array.isArray(s)?s:[s];for(const t of a){const s=t.AdaptationSet||t.adaptationSet||t.AdaptationSet_asArray||[],a=Array.isArray(s)?s:[s];for(const t of a){const s=String(t.contentType||t.ContentType||""),a=String(t.mimeType||t.MimeType||"");if("text"!==s&&!/text\/vtt|application\/ttml/i.test(a))continue;const r=String(t.lang||t.language||""),n=t.Representation||t.representation||t.Representation_asArray||[],h=Array.isArray(n)?n:[n];for(const t of h){const s=t.BaseURL||t.baseURL||t.BaseURL_asArray;let a;if(Array.isArray(s)){const t=s[0];a="string"==typeof t?t:t?.__text}else a="string"==typeof s?s:s?.__text;if(!a)continue;const n=a.startsWith("http")?a:new URL(a,e).href;i.push({lang:r,url:n});break}}}return i}catch{return[]}}supportsAutoQuality(){return!0}isAutoQuality(){if(!this.dash)return!0;try{if("function"==typeof this.dash.getAutoSwitchQualityFor)return this.dash.getAutoSwitchQualityFor("video");const t=this.dash.getSettings?.();return!1!==t?.streaming?.abr?.autoSwitchBitrate?.video}catch{return!0}}destroy(){this._pendingTimeouts.forEach(t=>clearTimeout(t)),this._pendingTimeouts=[],this._stopCueUpdatePolling(),this._lastKnownCueCount=0,this._listenerController.abort(),this._pendingReadyHandler&&(this.player.off("ready",this._pendingReadyHandler),this._pendingReadyHandler=null),this._captionEnabledHandler&&(this.player.off("captionsenabled",this._captionEnabledHandler),this._captionEnabledHandler=null),this._captionDisabledHandler&&(this.player.off("captionsdisabled",this._captionDisabledHandler),this._captionDisabledHandler=null),this._ttmlDiv&&this._ttmlDiv.parentNode&&(this._ttmlDiv.parentNode.removeChild(this._ttmlDiv),this._ttmlDiv=null);const t=this.media.textTracks;for(let e=0;e<t.length;e++){const i=t[e];!i||"subtitles"!==i.kind&&"captions"!==i.kind||(i._vidplyStale=!0,i.mode="disabled")}if(this.dash){try{this.dash.updateSettings({debug:{logLevel:0}}),this.dash.reset()}catch{}try{this.dash.destroy()}catch{}this.dash=null}this._dashTextTracks=[],this._dashTextIsTtml=!1,this._manifestUrl=null}};export{e as DASHRenderer};
6
+ import{loadScriptOnce as t}from"./vidply.chunk-EUOA2DJK.min.js";var e=class{player;media;dash;isStreaming=!0;_dashSourceLoaded;_pendingSrc;_dashSubtitleTracksCount;_dashTextTracks;_cueUpdateTimer;_captionEnabledHandler;_captionDisabledHandler;_lastKnownCueCount;_dashTextIsTtml;_pendingTimeouts;_ttmlDiv;_manifestUrl;_listenerController;_pendingReadyHandler;constructor(t){this.player=t,this.media=t.element,this.dash=null,this._dashSourceLoaded=!1,this._pendingSrc=null,this._dashSubtitleTracksCount=void 0,this._dashTextTracks=[],this._cueUpdateTimer=null,this._captionEnabledHandler=null,this._captionDisabledHandler=null,this._lastKnownCueCount=0,this._dashTextIsTtml=!1,this._pendingTimeouts=[],this._ttmlDiv=null,this._manifestUrl=null,this._listenerController=new AbortController,this._pendingReadyHandler=null}async init(){this.player.log("Using dash.js for DASH support"),await this.initDashJs()}async initDashJs(){this.media.controls=!1,this.media.removeAttribute("controls"),window.dashjs||await this.loadDashJs();const t=Array.from(this.media.querySelectorAll("source"));let e=null;t.length>0&&(e=t[0]?.getAttribute("src")??null,t.forEach(t=>t.remove()),this.player.log("Removed <source> elements for HTML5 validity (dash.js uses MSE)"));const i=window.dashjs;if(!i)throw new Error("dash.js not available");this.dash=i.MediaPlayer().create(),this.dash.updateSettings({debug:{logLevel:this.player.options.debug?4:0},streaming:{selectionModeForInitialTrack:"firstTrack",buffer:{bufferTimeAtTopQuality:30,bufferTimeAtTopQualityLongForm:60,bufferTimeDefault:12,bufferToKeep:20,bufferPruningInterval:10},retryAttempts:{MPD:4,MediaSegment:6,InitializationSegment:4,BitstreamSwitchingSegment:4},retryIntervals:{MPD:1e3,MediaSegment:1e3,InitializationSegment:1e3,BitstreamSwitchingSegment:1e3},abr:{autoSwitchBitrate:{video:!0,audio:!0}},text:{defaultEnabled:!0}}}),this._ttmlDiv=document.createElement("div"),this._ttmlDiv.className="vidply-dash-ttml",this._ttmlDiv.style.visibility="hidden";const s=this.player.videoWrapper||this.media.parentElement;s&&s.appendChild(this._ttmlDiv),this.dash.initialize(this.media,null,!1),this.dash.attachTTMLRenderingDiv(this._ttmlDiv);let a=this.player.currentSource;if(!a&&e&&(a=e),a||(a=this.player.element.getAttribute("data-vidply-src")),!a){const t=this.player.element.getAttribute("src")||this.player.element.src;t&&!t.startsWith("blob:")&&(a=t)}if(this.player.log(`Loading DASH source: ${a}`,"log"),!a)throw new Error("No DASH source found");this._pendingSrc=a,this._manifestUrl=a,this.dash.attachSource(a),this._dashSourceLoaded=!0,this.player.showPosterOverlay(),this.attachDashEvents(),this.attachMediaEvents(),this._setupCaptionSync()}async loadDashJs(){return t(this.player.options.dashScriptUrl||"https://cdn.jsdelivr.net/npm/dashjs@5.2.0/dist/modern/umd/dash.all.min.js",{integrity:this.player.options.dashScriptIntegrity})}_setTimeout(t,e){const i=setTimeout(()=>{this._pendingTimeouts=this._pendingTimeouts.filter(t=>t!==i),t()},e);return this._pendingTimeouts.push(i),i}attachDashEvents(){const t=window.dashjs,e=this.dash;if(!t||!e)return;const i=t.MediaPlayer.events;e.on(i.MANIFEST_LOADED,(...t)=>{const e=t[0],i=e?.data??e;this.player.log("DASH manifest loaded"),this.player.emit("dashmanifestloaded",i),this.player.container&&this.player.container.classList.remove("vidply-external-controls"),this._setTimeout(()=>{this._checkSubtitleTracks()},500)}),e.on(i.QUALITY_CHANGE_RENDERED,(...t)=>{const e=t[0];"video"===e.mediaType&&(this.player.log("DASH quality changed to index "+e.newQuality),this.player.emit("dashqualitychanged",e))}),e.on(i.TEXT_TRACKS_ADDED,(...t)=>{const i=t[0],s=i?.tracks??[];if(this._dashTextTracks=s,this._dashTextIsTtml=s.some(t=>t.isTTML||/stpp|ttml/i.test(t.codec||"")||/ttml/i.test(t.mimeType||"")),this.player.log(`DASH text tracks added: ${s.length} tracks, format: ${this._dashTextIsTtml?"TTML":"WebVTT"}`),this._dashSubtitleTracksCount=s.length,this.player.emit("dashsubtitletracksupdated",{tracks:s}),this.updateCaptionButtonsForDash(),s.length>0){try{e.setTextTrack(0)}catch{}this._dashTextIsTtml||this._startCueUpdatePolling()}}),e.on(i.STREAM_INITIALIZED,()=>{this.player.log("DASH stream initialized"),this.player.emit("dashstreaminitialized"),this._setTimeout(()=>{const t=this.getQualities();t.length>0&&this.player.emit("dashmanifestparsed",{qualities:t})},300)}),e.on(i.ERROR,(...t)=>{this.handleDashError(t[0])}),e.on(i.FRAGMENT_LOADING_COMPLETED,(...t)=>{const e=t[0];this.player.state.buffering=!1,"text"!==e?.request?.mediaType||this._dashTextIsTtml||this._setTimeout(()=>{const t=this._getTotalCueCount();t>this._lastKnownCueCount&&(this._lastKnownCueCount=t,this.player.emit("textcuesupdate"))},100)})}_getTotalCueCount(){const t=this.media.textTracks;let e=0;if(!t)return e;for(let i=0;i<t.length;i++){const s=t[i];!s||"subtitles"!==s.kind&&"captions"!==s.kind||s._vidplyStale||!s.cues||(e+=s.cues.length)}return e}_isTimeBuffered(t){const e=this.media.buffered;if(!e||0===e.length)return!1;for(let i=0;i<e.length;i++)if(t>=e.start(i)-.25&&t<=e.end(i)+.25)return!0;return!1}_setupCaptionSync(){this._captionEnabledHandler=t=>{this._dashTextIsTtml&&(t.track&&(t.track.mode="showing"),this._ttmlDiv&&(this._ttmlDiv.style.visibility="visible")),this._syncDashTextTrack(t)},this._captionDisabledHandler=()=>{if(this._dashTextIsTtml&&this._ttmlDiv&&(this._ttmlDiv.style.visibility="hidden"),this.dash)try{this.dash.setTextTrack(-1)}catch{}},this.player.on("captionsenabled",this._captionEnabledHandler),this.player.on("captionsdisabled",this._captionDisabledHandler)}_syncDashTextTrack(t){if(!this.dash||!this._dashTextTracks.length)return;const e=t.language;if(!e)return;const i=this._dashTextTracks.findIndex(t=>{const i=t.lang||t.language||t.srclang||"";return!!i&&(i===e||i.startsWith(e)||e.startsWith(i))});if(i>=0){this.player.log(`Syncing DASH text track to index ${i} (${e})`);try{this.dash.setTextTrack(i)}catch{}this._dashTextIsTtml||(this._lastKnownCueCount=0,this._startCueUpdatePolling())}}_startCueUpdatePolling(){this._stopCueUpdatePolling();let t=0,e=0;this._cueUpdateTimer=setInterval(()=>{const i=this._getTotalCueCount();i>t?(t=i,e=0,this.player.emit("textcuesupdate")):(e++,e>=8&&(this._stopCueUpdatePolling(),i>0&&this.player.emit("textcuesupdate")))},500)}_stopCueUpdatePolling(){this._cueUpdateTimer&&(clearInterval(this._cueUpdateTimer),this._cueUpdateTimer=null)}_checkSubtitleTracks(){if(void 0!==this._dashSubtitleTracksCount&&this._dashSubtitleTracksCount>0)return;const t=this.media.textTracks;let e=0;for(let i=0;i<t.length;i++){const s=t[i];!s||"subtitles"!==s.kind&&"captions"!==s.kind||s._vidplyStale||e++}this._dashSubtitleTracksCount=e,this.updateCaptionButtonsForDash()}updateCaptionButtonsForDash(t=0){const e=this._dashSubtitleTracksCount||0,i=()=>{if(this.player.invalidateTrackCache(),e>0){if(this.player.captionManager&&0===this.player.captionManager.refreshTracks()&&t<5){const e=200*(t+1);return this.player.log(`DASH caption tracks not yet on video element, retrying in ${e}ms (attempt ${t+1})`,"info"),void this._setTimeout(()=>{this.updateCaptionButtonsForDash(t+1)},e)}!this._dashTextIsTtml&&this.player.transcriptManager?.isVisible&&(this.player.transcriptManager.loadTranscriptData(),this.player.transcriptManager.updateLanguageSelector()),this.player.controlBar&&(this.player.controlBar.ensureCaptionsButton(),this._dashTextIsTtml||(this.player.controlBar.ensureCaptionStyleButton(),this.player.controlBar.ensureTranscriptButton()))}else this.player.captionManager&&this.player.captionManager.refreshTracks(),this.player.transcriptManager?.isVisible&&this.player.transcriptManager.hideTranscript(),this.player.controlBar&&this.player.controlBar.removeHlsCaptionButtons(!0)};if(this.player.controlBar)return void i();const s=()=>{this.player.off("ready",s),this._pendingReadyHandler=null,i()};this._pendingReadyHandler=s,this.player.on("ready",s)}attachMediaEvents(){const{signal:t}=this._listenerController;this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")},{signal:t}),this.media.addEventListener("durationchange",()=>{const t=this.media.duration;t&&isFinite(t)&&t>0&&(this.player.state.duration=t,this.player.emit("durationchange",t))},{signal:t}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)},{signal:t}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)},{signal:t}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())},{signal:t}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)},{signal:t}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume)},{signal:t}),this.media.addEventListener("seeking",()=>{this.player.state.seeking=!0,this.player.emit("seeking"),this._isTimeBuffered(this.media.currentTime)||(this.player.state.buffering=!0,this.player.emit("waiting"))},{signal:t}),this.media.addEventListener("seeked",()=>{this.player.state.seeking=!1,this.player.emit("seeked")},{signal:t}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")},{signal:t}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")},{signal:t}),this.media.addEventListener("error",()=>{this.player.handleError(this.media.error)},{signal:t})}handleDashError(t){const e=t,i=e?.error??e;if(!i)return;const s=i.code??"",a=i.message||"";this.player.log(`DASH Error - Code: ${s}, Message: ${a}`,"warn"),"number"==typeof s&&s>=100?(this.player.log("Fatal DASH error","error"),this.player.handleError(new Error(`DASH Error: ${s} - ${a}`))):this.player.log("Non-fatal DASH error: "+(a||String(i)),"warn")}ensureLoaded(){if(!this.player.options.deferLoad)return;if(!this.dash)return;if(this._dashSourceLoaded)return;const t=this._pendingSrc||this.player._pendingSource||this.player.currentSource;if(t)try{this.dash.attachSource(t),this._dashSourceLoaded=!0}catch{}}play(){const t=window.scrollX,e=window.scrollY;if(this.player.options.deferLoad&&this.dash&&!this._dashSourceLoaded){const t=this._pendingSrc||this.player.currentSource;if(t)try{this.dash.attachSource(t),this._dashSourceLoaded=!0}catch{}}const i=this.media.play();window.scrollTo(t,e),void 0!==i&&i.catch(t=>{this.player.log("Play failed:",t,"warn")})}pause(){this.media.pause()}seek(t){this.media.currentTime=t}setVolume(t){this.media.volume=t}setMuted(t){this.media.muted=t}setPlaybackSpeed(t){this.media.playbackRate=t}switchQuality(t){this.dash&&(-1===t?"function"==typeof this.dash.setAutoSwitchQualityFor?this.dash.setAutoSwitchQualityFor("video",!0):this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!0}}}}):("function"==typeof this.dash.setAutoSwitchQualityFor?this.dash.setAutoSwitchQualityFor("video",!1):this.dash.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!1}}}}),"function"==typeof this.dash.setRepresentationForTypeByIndex?this.dash.setRepresentationForTypeByIndex("video",t):"function"==typeof this.dash.setQualityFor&&this.dash.setQualityFor("video",t,!0)))}getQualities(){if(!this.dash)return[];try{let t=null;if("function"==typeof this.dash.getRepresentationsByType&&(t=this.dash.getRepresentationsByType("video")),t&&t.length>0){const e={};return t.forEach(t=>{const i=Number(t.height)||0;e[i]=(e[i]||0)+1}),t.map((t,i)=>{const s=Number(t.height)||0,a=Number(t.bandwidth||t.bitrate)||0,r=a>0?Math.round(a/1e3):0;let n;return n=s>0&&(e[s]??0)>1&&r>0?`${s}p (${r} kbps)`:s>0?`${s}p`:r>0?`${r} kbps`:"Auto",{index:i,id:t.id,height:t.height,width:t.width,bitrate:a,name:n}})}const e=this.dash.getBitrateInfoListFor("video");if(!e||0===e.length)return[];const i={};return e.forEach(t=>{const e=Number(t.height)||0;i[e]=(i[e]||0)+1}),e.map((t,e)=>{const s=Number(t.height)||0,a=Number(t.bitrate)||0,r=a>0?Math.round(a/1e3):0;let n;return n=s>0&&(i[s]??0)>1&&r>0?`${s}p (${r} kbps)`:s>0?`${s}p`:r>0?`${r} kbps`:"Auto",{index:e,height:t.height,width:t.width,bitrate:t.bitrate,name:n}})}catch{return[]}}getCurrentQuality(){if(!this.dash)return-1;try{if("function"==typeof this.dash.getRepresentationsByType){const t=this.dash.getRepresentationsByType("video"),e=this.dash.getCurrentRepresentationForType?.("video");if(e&&t){const i=t.findIndex(t=>t.id===e.id);if(i>=0)return i}}return this.dash.getQualityFor("video")}catch{return-1}}handlesOwnCaptions(){return this._dashTextIsTtml}activateTextTrackForLanguage(t){if(!this.dash||!this._dashTextTracks.length||!t)return!1;let e=this._dashTextTracks.findIndex(e=>{const i=e.lang||e.language||e.srclang||"";return!!i&&(i===t||i.startsWith(t)||t.startsWith(i))});if(e<0&&(e=this._dashTextTracks.findIndex(e=>(e.label||e.labels||"").toString().toLowerCase().includes(t.toLowerCase()))),e<0)return!1;this.player.log(`Activating DASH text track index ${e} for transcript language "${t}"`);try{this.dash.setTextTrack(e)}catch{}if(this.media.paused){const t=this.media.currentTime,e=this.media.muted;this.media.muted=!0;const i=this.media.play(),s=()=>{this.media&&!this.media.paused&&(this.media.pause(),this.media.muted=e,Math.abs(this.media.currentTime-t)>.5&&(this.media.currentTime=t))};i&&"function"==typeof i.then?i.then(()=>{this._setTimeout(s,250)}).catch(()=>{this.media.muted=e}):this._setTimeout(s,250)}return this._dashTextIsTtml||(this._lastKnownCueCount=0,this._startCueUpdatePolling()),!0}getTextTrackURLs(){if(!this.dash||!this._manifestUrl)return[];try{const t=this.dash.getManifest?.();if(!t)return[];const e=this._manifestUrl.substring(0,this._manifestUrl.lastIndexOf("/")+1),i=[],s=t.Period||t.period||t.periods||t,a=Array.isArray(s)?s:[s];for(const t of a){const s=t.AdaptationSet||t.adaptationSet||t.AdaptationSet_asArray||[],a=Array.isArray(s)?s:[s];for(const t of a){const s=String(t.contentType||t.ContentType||""),a=String(t.mimeType||t.MimeType||"");if("text"!==s&&!/text\/vtt|application\/ttml/i.test(a))continue;const r=String(t.lang||t.language||""),n=t.Representation||t.representation||t.Representation_asArray||[],h=Array.isArray(n)?n:[n];for(const t of h){const s=t.BaseURL||t.baseURL||t.BaseURL_asArray;let a;if(Array.isArray(s)){const t=s[0];a="string"==typeof t?t:t?.__text}else a="string"==typeof s?s:s?.__text;if(!a)continue;const n=a.startsWith("http")?a:new URL(a,e).href;i.push({lang:r,url:n});break}}}return i}catch{return[]}}supportsAutoQuality(){return!0}isAutoQuality(){if(!this.dash)return!0;try{if("function"==typeof this.dash.getAutoSwitchQualityFor)return this.dash.getAutoSwitchQualityFor("video");const t=this.dash.getSettings?.();return!1!==t?.streaming?.abr?.autoSwitchBitrate?.video}catch{return!0}}destroy(){this._pendingTimeouts.forEach(t=>clearTimeout(t)),this._pendingTimeouts=[],this._stopCueUpdatePolling(),this._lastKnownCueCount=0,this._listenerController.abort(),this._pendingReadyHandler&&(this.player.off("ready",this._pendingReadyHandler),this._pendingReadyHandler=null),this._captionEnabledHandler&&(this.player.off("captionsenabled",this._captionEnabledHandler),this._captionEnabledHandler=null),this._captionDisabledHandler&&(this.player.off("captionsdisabled",this._captionDisabledHandler),this._captionDisabledHandler=null),this._ttmlDiv&&this._ttmlDiv.parentNode&&(this._ttmlDiv.parentNode.removeChild(this._ttmlDiv),this._ttmlDiv=null);const t=this.media.textTracks;for(let e=0;e<t.length;e++){const i=t[e];!i||"subtitles"!==i.kind&&"captions"!==i.kind||(i._vidplyStale=!0,i.mode="disabled")}if(this.dash){try{this.dash.updateSettings({debug:{logLevel:0}}),this.dash.reset()}catch{}try{this.dash.destroy()}catch{}this.dash=null}this._dashTextTracks=[],this._dashTextIsTtml=!1,this._manifestUrl=null}};export{e as DASHRenderer};
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VidPly v1.2.0 - Universal, Accessible Video Player
2
+ * VidPly v1.2.1 - Universal, Accessible Video Player
3
3
  * (c) 2026 Matthias Peltzer
4
4
  * Released under GPL-2.0-or-later License
5
5
  */
6
- import{DraggableResizable as t}from"./vidply.chunk-2TB6MUHO.min.js";import{createIconElement as e}from"./vidply.chunk-ABPXVDLZ.min.js";import{DOMUtils as i,i18n as s}from"./vidply.chunk-EKEYJWMG.min.js";var a="vidply:floating-claim",l=240,n=16,r=class{player;classPrefix;shell;dragHandle;closeButton;resizeHandles;placeholder;draggable;originalParent;originalNextSibling;intersectionObserver;observerTarget;lastRatio;_autoDismissedThisPlay;_playListenerAttached;_onPlayAfterDismiss;_onClaim;_onResize;_onKeyDown;_onEnterFullscreen;_destroyed;_triggerFocusEl;_claimId;_lastAutoExitTime;constructor(t){this.player=t,this.classPrefix=t.options.classPrefix||"vidply",this.shell=null,this.dragHandle=null,this.closeButton=null,this.resizeHandles=[],this.placeholder=null,this.draggable=null,this.originalParent=null,this.originalNextSibling=null,this.intersectionObserver=null,this.observerTarget=null,this.lastRatio=1,this._autoDismissedThisPlay=!1,this._playListenerAttached=!1,this._onPlayAfterDismiss=null,this._onClaim=null,this._onResize=null,this._onKeyDown=null,this._onEnterFullscreen=null,this._destroyed=!1,this._triggerFocusEl=null,this._claimId=`floating-${t.instanceId}-${Date.now()}`,this._lastAutoExitTime=0,this._setupClaimListener(),this._setupFullscreenGuard(),this._startObserving()}togglePinned(t){if(!this._destroyed){if("pinned"===this.player.state.floating)return this._autoDismissedThisPlay=!0,this._armPlayListenerToClearDismiss(),void this.exit("manual");this._autoDismissedThisPlay=!1,this._triggerFocusEl=t||this._activeElement(),this.enter("pinned")}}enter(t){if(!this._destroyed&&this.player.state.floating!==t&&this._canFloat(t)){if(this.player.state.floating&&this.player.state.floating!==t)return this.player.state.floating=t,void this.player.emit("floatingchange",t);this._claimSingleton(),this._ensureShell(),this._mountIntoShell(),this._applyInitialGeometry(),this.player.state.floating=t,this.player.emit("floatingchange",t),queueMicrotask(()=>{if(this.closeButton&&this.player.state.floating)try{this.closeButton.focus({preventScroll:!0})}catch{}})}}exit(t="manual"){if(this._destroyed&&"destroy"!==t)return;if(!this.player.state.floating)return;"auto"===t&&(this._lastAutoExitTime=Date.now()),this._unmountFromShell(),this._teardownShell();const e=this._triggerFocusEl;if(this._triggerFocusEl=null,this.player.state.floating=null,this.player.emit("floatingchange",null),("manual"===t||"dismiss"===t)&&e)try{e.focus({preventScroll:!0})}catch{}}dismiss(){if(!this._destroyed){this._autoDismissedThisPlay=!0,this._armPlayListenerToClearDismiss();try{this.player.pause()}catch{}this.exit("dismiss")}}destroy(){if(this._destroyed)return;if(this._destroyed=!0,this.player.state&&this.player.state.floating)try{this.exit("destroy")}catch{}if(this.intersectionObserver){try{this.intersectionObserver.disconnect()}catch{}this.intersectionObserver=null}this.observerTarget=null,this._onClaim&&(window.removeEventListener(a,this._onClaim),this._onClaim=null),this._onResize&&(window.removeEventListener("resize",this._onResize),this._onResize=null);const t=this._onEnterFullscreen;t&&(this.player.off("enterfullscreen",t),this._onEnterFullscreen=null);const e=this._onPlayAfterDismiss;e&&this._playListenerAttached&&(this.player.off("play",e),this._playListenerAttached=!1,this._onPlayAfterDismiss=null)}_canFloat(t){if(!this.player.options.floating)return!1;if(!this.player.container)return!1;if(!this.player.element||"VIDEO"!==this.player.element.tagName)return!1;if(this.player.state.fullscreen)return!1;if(this.player.playlistManager)return!1;if(window.innerWidth<(this.player.options.floatingMinViewportWidth??768))return!1;if("auto"===t){if(this._autoDismissedThisPlay)return!1;if(this.player.state.paused)return!1;if(!this.player.state.hasStartedPlayback)return!1}return!0}_claimSingleton(){try{window.dispatchEvent(new CustomEvent(a,{detail:{claimId:this._claimId}}))}catch{}}_setupClaimListener(){this._onClaim=t=>{const e=t.detail;e&&e.claimId!==this._claimId&&this.player.state.floating&&this.exit("claim")};const t=this.player.lifecycleSignal;window.addEventListener(a,this._onClaim,{signal:t}),this._onResize=()=>{this.player.state.floating&&window.innerWidth<(this.player.options.floatingMinViewportWidth??768)&&this.exit("auto")},window.addEventListener("resize",this._onResize,{signal:t})}_setupFullscreenGuard(){const t=()=>{this.player.state.floating&&this.exit("manual")};this._onEnterFullscreen=t,this.player.on("enterfullscreen",t)}_armPlayListenerToClearDismiss(){if(this._playListenerAttached)return;const t=()=>{this._autoDismissedThisPlay=!1;const t=this._onPlayAfterDismiss;t&&this.player.off("play",t),this._playListenerAttached=!1,this._onPlayAfterDismiss=null};this._onPlayAfterDismiss=t,this.player.on("play",t),this._playListenerAttached=!0}_startObserving(){"IntersectionObserver"in window&&this.player.container&&(this.observerTarget=this.player.container,this.intersectionObserver=new IntersectionObserver(t=>{const e=t[t.length-1];if(e){if(this.lastRatio=e.intersectionRatio,this.player.options.debug)try{console.log("[vidply:floating] intersection",{ratio:Number(e.intersectionRatio.toFixed(3)),state:this.player.state.floating,paused:this.player.state.paused,hasStartedPlayback:this.player.state.hasStartedPlayback,dismissed:this._autoDismissedThisPlay})}catch{}if("auto"!==this.player.state.floating){if("pinned"!==this.player.state.floating&&e.intersectionRatio<.1&&this._canFloat("auto")){const t=500;if(Date.now()-this._lastAutoExitTime<t)return;this.enter("auto")}}else e.intersectionRatio>=.5&&this.exit("auto")}},{threshold:[0,.1,.5,.9]}),this.intersectionObserver.observe(this.observerTarget))}_retargetObserver(t){if(this.intersectionObserver){if(this.observerTarget)try{this.intersectionObserver.unobserve(this.observerTarget)}catch{}this.observerTarget=t;try{this.intersectionObserver.observe(t)}catch{}}}_ensureShell(){if(this.shell)return;this.shell=i.createElement("div",{className:`${this.classPrefix}-floating-shell`,attributes:{role:"dialog","aria-modal":"false","aria-label":s.t("player.floatingPlayer"),"data-vidply-floating":"true",tabindex:"-1"}}),this.dragHandle=i.createElement("div",{className:`${this.classPrefix}-floating-drag-handle`,attributes:{"aria-hidden":"true"}}),this.shell.appendChild(this.dragHandle),this.closeButton=i.createElement("button",{className:`${this.classPrefix}-floating-close`,attributes:{type:"button","aria-label":s.t("player.floatingPlayerClose"),title:s.t("player.floatingPlayerClose")}}),this.closeButton.appendChild(e("close")),this.closeButton.addEventListener("click",t=>{t.stopPropagation(),this.dismiss()}),this.shell.appendChild(this.closeButton),this._createResizeHandles();const t=this.shell;this.resizeHandles.forEach(e=>t.appendChild(e)),this._onKeyDown=t=>{if("Escape"===t.key){const e=this.draggable;if(e&&(e.keyboardDragMode||e.keyboardResizeMode||e.pointerResizeMode))return;t.stopPropagation(),this.dismiss()}},this.shell.addEventListener("keydown",this._onKeyDown)}_createResizeHandles(){this.resizeHandles=["n","s","e","w","ne","nw","se","sw"].map(t=>i.createElement("div",{className:`${this.classPrefix}-floating-resize-handle ${this.classPrefix}-floating-resize-${t}`,attributes:{"data-direction":t,"aria-hidden":"true"}}))}_teardownShell(){if(this.draggable){try{this.draggable.destroy()}catch{}this.draggable=null}this.shell&&(this._onKeyDown&&(this.shell.removeEventListener("keydown",this._onKeyDown),this._onKeyDown=null),this.shell.parentNode&&this.shell.parentNode.removeChild(this.shell)),this.shell=null,this.dragHandle=null,this.closeButton=null,this.resizeHandles=[]}_mountIntoShell(){const t=this.player.container;if(!t||!t.parentNode)return;if(!this.shell)return;const s=t.getBoundingClientRect();this.originalParent=t.parentNode,this.originalNextSibling=t.nextSibling,this.placeholder=i.createElement("div",{className:`${this.classPrefix}-floating-placeholder`,attributes:{"aria-hidden":"true"}}),this.placeholder.style.width=`${Math.max(1,s.width)}px`,this.placeholder.style.height=`${Math.max(1,s.height)}px`;const a=e("pip",`${this.classPrefix}-floating-placeholder-icon`);this.placeholder.appendChild(a),this.originalParent.insertBefore(this.placeholder,t),this.shell.appendChild(t),document.body.appendChild(this.shell),t.classList.add(`${this.classPrefix}-is-floating`),this._retargetObserver(this.placeholder)}_unmountFromShell(){const t=this.player.container;t&&(t.classList.remove(`${this.classPrefix}-is-floating`),t.style.removeProperty("width"),t.style.removeProperty("height")),this.placeholder&&this.placeholder.parentNode?(t&&this.placeholder.parentNode.insertBefore(t,this.placeholder),this.placeholder.parentNode.removeChild(this.placeholder)):t&&this.originalParent&&(this.originalNextSibling&&this.originalNextSibling.parentNode===this.originalParent?this.originalParent.insertBefore(t,this.originalNextSibling):this.originalParent.appendChild(t)),this.placeholder=null,this.originalParent=null,this.originalNextSibling=null,t&&this._retargetObserver(t)}_applyInitialGeometry(){if(!this.shell)return;const t=this.player.storage?.getFloatingPreferences?.()||{},e=window.innerWidth,i=window.innerHeight;let s=t.width&&t.width>=l?t.width:400;s=Math.min(s,Math.max(l,e-32));const a=this.player.container?.getBoundingClientRect(),r=Math.round(s/(a&&a.height>0?a.width/a.height:16/9));let h,o,d=t.height&&t.height>=100?t.height:r;if(d=Math.min(d,Math.max(100,i-32)),"number"==typeof t.left&&"number"==typeof t.top)h=Math.max(n,Math.min(t.left,e-s-n)),o=Math.max(n,Math.min(t.top,i-d-n));else switch(this.player.options.floatingPosition||"bottom-right"){case"bottom-left":h=n,o=i-d-n;break;case"top-right":h=e-s-n,o=n;break;case"top-left":h=n,o=n;break;default:h=e-s-n,o=i-d-n}this.shell.style.width=`${s}px`,this.shell.style.height=`${d}px`,this.shell.style.left=`${h}px`,this.shell.style.top=`${o}px`,this._initDraggable()}_initDraggable(){this.shell&&(this.draggable||(this.draggable=new t(this.shell,{dragHandle:this.dragHandle,resizeHandles:this.resizeHandles,constrainToViewport:!0,maintainAspectRatio:!0,minWidth:l,minHeight:100,maxWidth:()=>Math.max(l,window.innerWidth-32),maxHeight:()=>Math.max(100,window.innerHeight-32),classPrefix:`${this.classPrefix}-floating`,keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:10,keyboardStepLarge:50,pointerResizeIndicatorText:s.t("player.floatingPlayerDialog"),onDragEnd:()=>this._savePrefs(),onResizeEnd:()=>this._savePrefs(),onDragStart:t=>{const e=t.target;return!e||!e.closest(`.${this.classPrefix}-floating-close`)&&!e.closest(`.${this.classPrefix}-controls`)&&!e.closest(`.${this.classPrefix}-floating-resize-handle`)}})))}_savePrefs(){if(!this.shell||!this.player.storage?.saveFloatingPreferences)return;const t=this.shell.getBoundingClientRect();this.player.storage.saveFloatingPreferences({width:Math.round(t.width),height:Math.round(t.height),left:Math.round(t.left),top:Math.round(t.top)})}_activeElement(){const t=document.activeElement;return t&&t instanceof HTMLElement?t:null}};export{r as FloatingPlayerManager};
6
+ import{DraggableResizable as t}from"./vidply.chunk-G6KGXNEW.min.js";import{createIconElement as e}from"./vidply.chunk-JPMAK3NS.min.js";import{DOMUtils as i,i18n as s}from"./vidply.chunk-6ECBIYVI.min.js";var a="vidply:floating-claim",l=240,n=16,r=class{player;classPrefix;shell;dragHandle;closeButton;resizeHandles;placeholder;draggable;originalParent;originalNextSibling;intersectionObserver;observerTarget;lastRatio;_autoDismissedThisPlay;_playListenerAttached;_onPlayAfterDismiss;_onClaim;_onResize;_onKeyDown;_onEnterFullscreen;_destroyed;_triggerFocusEl;_claimId;_lastAutoExitTime;constructor(t){this.player=t,this.classPrefix=t.options.classPrefix||"vidply",this.shell=null,this.dragHandle=null,this.closeButton=null,this.resizeHandles=[],this.placeholder=null,this.draggable=null,this.originalParent=null,this.originalNextSibling=null,this.intersectionObserver=null,this.observerTarget=null,this.lastRatio=1,this._autoDismissedThisPlay=!1,this._playListenerAttached=!1,this._onPlayAfterDismiss=null,this._onClaim=null,this._onResize=null,this._onKeyDown=null,this._onEnterFullscreen=null,this._destroyed=!1,this._triggerFocusEl=null,this._claimId=`floating-${t.instanceId}-${Date.now()}`,this._lastAutoExitTime=0,this._setupClaimListener(),this._setupFullscreenGuard(),this._startObserving()}togglePinned(t){if(!this._destroyed){if("pinned"===this.player.state.floating)return this._autoDismissedThisPlay=!0,this._armPlayListenerToClearDismiss(),void this.exit("manual");this._autoDismissedThisPlay=!1,this._triggerFocusEl=t||this._activeElement(),this.enter("pinned")}}enter(t){if(!this._destroyed&&this.player.state.floating!==t&&this._canFloat(t)){if(this.player.state.floating&&this.player.state.floating!==t)return this.player.state.floating=t,void this.player.emit("floatingchange",t);this._claimSingleton(),this._ensureShell(),this._mountIntoShell(),this._applyInitialGeometry(),this.player.state.floating=t,this.player.emit("floatingchange",t),queueMicrotask(()=>{if(this.closeButton&&this.player.state.floating)try{this.closeButton.focus({preventScroll:!0})}catch{}})}}exit(t="manual"){if(this._destroyed&&"destroy"!==t)return;if(!this.player.state.floating)return;"auto"===t&&(this._lastAutoExitTime=Date.now()),this._unmountFromShell(),this._teardownShell();const e=this._triggerFocusEl;if(this._triggerFocusEl=null,this.player.state.floating=null,this.player.emit("floatingchange",null),("manual"===t||"dismiss"===t)&&e)try{e.focus({preventScroll:!0})}catch{}}dismiss(){if(!this._destroyed){this._autoDismissedThisPlay=!0,this._armPlayListenerToClearDismiss();try{this.player.pause()}catch{}this.exit("dismiss")}}destroy(){if(this._destroyed)return;if(this._destroyed=!0,this.player.state&&this.player.state.floating)try{this.exit("destroy")}catch{}if(this.intersectionObserver){try{this.intersectionObserver.disconnect()}catch{}this.intersectionObserver=null}this.observerTarget=null,this._onClaim&&(window.removeEventListener(a,this._onClaim),this._onClaim=null),this._onResize&&(window.removeEventListener("resize",this._onResize),this._onResize=null);const t=this._onEnterFullscreen;t&&(this.player.off("enterfullscreen",t),this._onEnterFullscreen=null);const e=this._onPlayAfterDismiss;e&&this._playListenerAttached&&(this.player.off("play",e),this._playListenerAttached=!1,this._onPlayAfterDismiss=null)}_canFloat(t){if(!this.player.options.floating)return!1;if(!this.player.container)return!1;if(!this.player.element||"VIDEO"!==this.player.element.tagName)return!1;if(this.player.state.fullscreen)return!1;if(this.player.playlistManager)return!1;if(window.innerWidth<(this.player.options.floatingMinViewportWidth??768))return!1;if("auto"===t){if(this._autoDismissedThisPlay)return!1;if(this.player.state.paused)return!1;if(!this.player.state.hasStartedPlayback)return!1}return!0}_claimSingleton(){try{window.dispatchEvent(new CustomEvent(a,{detail:{claimId:this._claimId}}))}catch{}}_setupClaimListener(){this._onClaim=t=>{const e=t.detail;e&&e.claimId!==this._claimId&&this.player.state.floating&&this.exit("claim")};const t=this.player.lifecycleSignal;window.addEventListener(a,this._onClaim,{signal:t}),this._onResize=()=>{this.player.state.floating&&window.innerWidth<(this.player.options.floatingMinViewportWidth??768)&&this.exit("auto")},window.addEventListener("resize",this._onResize,{signal:t})}_setupFullscreenGuard(){const t=()=>{this.player.state.floating&&this.exit("manual")};this._onEnterFullscreen=t,this.player.on("enterfullscreen",t)}_armPlayListenerToClearDismiss(){if(this._playListenerAttached)return;const t=()=>{this._autoDismissedThisPlay=!1;const t=this._onPlayAfterDismiss;t&&this.player.off("play",t),this._playListenerAttached=!1,this._onPlayAfterDismiss=null};this._onPlayAfterDismiss=t,this.player.on("play",t),this._playListenerAttached=!0}_startObserving(){"IntersectionObserver"in window&&this.player.container&&(this.observerTarget=this.player.container,this.intersectionObserver=new IntersectionObserver(t=>{const e=t[t.length-1];if(e){if(this.lastRatio=e.intersectionRatio,this.player.options.debug)try{console.log("[vidply:floating] intersection",{ratio:Number(e.intersectionRatio.toFixed(3)),state:this.player.state.floating,paused:this.player.state.paused,hasStartedPlayback:this.player.state.hasStartedPlayback,dismissed:this._autoDismissedThisPlay})}catch{}if("auto"!==this.player.state.floating){if("pinned"!==this.player.state.floating&&e.intersectionRatio<.1&&this._canFloat("auto")){const t=500;if(Date.now()-this._lastAutoExitTime<t)return;this.enter("auto")}}else e.intersectionRatio>=.5&&this.exit("auto")}},{threshold:[0,.1,.5,.9]}),this.intersectionObserver.observe(this.observerTarget))}_retargetObserver(t){if(this.intersectionObserver){if(this.observerTarget)try{this.intersectionObserver.unobserve(this.observerTarget)}catch{}this.observerTarget=t;try{this.intersectionObserver.observe(t)}catch{}}}_ensureShell(){if(this.shell)return;this.shell=i.createElement("div",{className:`${this.classPrefix}-floating-shell`,attributes:{role:"dialog","aria-modal":"false","aria-label":s.t("player.floatingPlayer"),"data-vidply-floating":"true",tabindex:"-1"}}),this.dragHandle=i.createElement("div",{className:`${this.classPrefix}-floating-drag-handle`,attributes:{"aria-hidden":"true"}}),this.shell.appendChild(this.dragHandle),this.closeButton=i.createElement("button",{className:`${this.classPrefix}-floating-close`,attributes:{type:"button","aria-label":s.t("player.floatingPlayerClose"),title:s.t("player.floatingPlayerClose")}}),this.closeButton.appendChild(e("close")),this.closeButton.addEventListener("click",t=>{t.stopPropagation(),this.dismiss()}),this.shell.appendChild(this.closeButton),this._createResizeHandles();const t=this.shell;this.resizeHandles.forEach(e=>t.appendChild(e)),this._onKeyDown=t=>{if("Escape"===t.key){const e=this.draggable;if(e&&(e.keyboardDragMode||e.keyboardResizeMode||e.pointerResizeMode))return;t.stopPropagation(),this.dismiss()}},this.shell.addEventListener("keydown",this._onKeyDown)}_createResizeHandles(){this.resizeHandles=["n","s","e","w","ne","nw","se","sw"].map(t=>i.createElement("div",{className:`${this.classPrefix}-floating-resize-handle ${this.classPrefix}-floating-resize-${t}`,attributes:{"data-direction":t,"aria-hidden":"true"}}))}_teardownShell(){if(this.draggable){try{this.draggable.destroy()}catch{}this.draggable=null}this.shell&&(this._onKeyDown&&(this.shell.removeEventListener("keydown",this._onKeyDown),this._onKeyDown=null),this.shell.parentNode&&this.shell.parentNode.removeChild(this.shell)),this.shell=null,this.dragHandle=null,this.closeButton=null,this.resizeHandles=[]}_mountIntoShell(){const t=this.player.container;if(!t||!t.parentNode)return;if(!this.shell)return;const s=t.getBoundingClientRect();this.originalParent=t.parentNode,this.originalNextSibling=t.nextSibling,this.placeholder=i.createElement("div",{className:`${this.classPrefix}-floating-placeholder`,attributes:{"aria-hidden":"true"}}),this.placeholder.style.width=`${Math.max(1,s.width)}px`,this.placeholder.style.height=`${Math.max(1,s.height)}px`;const a=e("pip",`${this.classPrefix}-floating-placeholder-icon`);this.placeholder.appendChild(a),this.originalParent.insertBefore(this.placeholder,t),this.shell.appendChild(t),document.body.appendChild(this.shell),t.classList.add(`${this.classPrefix}-is-floating`),this._retargetObserver(this.placeholder)}_unmountFromShell(){const t=this.player.container;t&&(t.classList.remove(`${this.classPrefix}-is-floating`),t.style.removeProperty("width"),t.style.removeProperty("height")),this.placeholder&&this.placeholder.parentNode?(t&&this.placeholder.parentNode.insertBefore(t,this.placeholder),this.placeholder.parentNode.removeChild(this.placeholder)):t&&this.originalParent&&(this.originalNextSibling&&this.originalNextSibling.parentNode===this.originalParent?this.originalParent.insertBefore(t,this.originalNextSibling):this.originalParent.appendChild(t)),this.placeholder=null,this.originalParent=null,this.originalNextSibling=null,t&&this._retargetObserver(t)}_applyInitialGeometry(){if(!this.shell)return;const t=this.player.storage?.getFloatingPreferences?.()||{},e=window.innerWidth,i=window.innerHeight;let s=t.width&&t.width>=l?t.width:400;s=Math.min(s,Math.max(l,e-32));const a=this.player.container?.getBoundingClientRect(),r=Math.round(s/(a&&a.height>0?a.width/a.height:16/9));let h,o,d=t.height&&t.height>=100?t.height:r;if(d=Math.min(d,Math.max(100,i-32)),"number"==typeof t.left&&"number"==typeof t.top)h=Math.max(n,Math.min(t.left,e-s-n)),o=Math.max(n,Math.min(t.top,i-d-n));else switch(this.player.options.floatingPosition||"bottom-right"){case"bottom-left":h=n,o=i-d-n;break;case"top-right":h=e-s-n,o=n;break;case"top-left":h=n,o=n;break;default:h=e-s-n,o=i-d-n}this.shell.style.width=`${s}px`,this.shell.style.height=`${d}px`,this.shell.style.left=`${h}px`,this.shell.style.top=`${o}px`,this._initDraggable()}_initDraggable(){this.shell&&(this.draggable||(this.draggable=new t(this.shell,{dragHandle:this.dragHandle,resizeHandles:this.resizeHandles,constrainToViewport:!0,maintainAspectRatio:!0,minWidth:l,minHeight:100,maxWidth:()=>Math.max(l,window.innerWidth-32),maxHeight:()=>Math.max(100,window.innerHeight-32),classPrefix:`${this.classPrefix}-floating`,keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:10,keyboardStepLarge:50,pointerResizeIndicatorText:s.t("player.floatingPlayerDialog"),onDragEnd:()=>this._savePrefs(),onResizeEnd:()=>this._savePrefs(),onDragStart:t=>{const e=t.target;return!e||!e.closest(`.${this.classPrefix}-floating-close`)&&!e.closest(`.${this.classPrefix}-controls`)&&!e.closest(`.${this.classPrefix}-floating-resize-handle`)}})))}_savePrefs(){if(!this.shell||!this.player.storage?.saveFloatingPreferences)return;const t=this.shell.getBoundingClientRect();this.player.storage.saveFloatingPreferences({width:Math.round(t.width),height:Math.round(t.height),left:Math.round(t.left),top:Math.round(t.top)})}_activeElement(){const t=document.activeElement;return t&&t instanceof HTMLElement?t:null}};export{r as FloatingPlayerManager};