@hanifhan1f/vidstack-react 1.12.34 → 1.12.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/package.json +1 -1
  2. package/player/layouts/default.d.ts +9 -1
  3. package/dev/chunks/vidstack-3rdEWplD.js +0 -189
  4. package/dev/chunks/vidstack-B-FM4-oZ.js +0 -668
  5. package/dev/chunks/vidstack-B92UncBI.js +0 -61
  6. package/dev/chunks/vidstack-BDiAEW1N.js +0 -11691
  7. package/dev/chunks/vidstack-BNwnoM-l.js +0 -84
  8. package/dev/chunks/vidstack-BOPSNTgH.js +0 -668
  9. package/dev/chunks/vidstack-BPymmnxm.js +0 -551
  10. package/dev/chunks/vidstack-BSZY6sbC.js +0 -180
  11. package/dev/chunks/vidstack-BSpAxhO6.js +0 -643
  12. package/dev/chunks/vidstack-BVVxkUlq.js +0 -288
  13. package/dev/chunks/vidstack-BXgKy_7V.js +0 -11693
  14. package/dev/chunks/vidstack-BalWqr4j.js +0 -1422
  15. package/dev/chunks/vidstack-Bfi_jCvb.js +0 -476
  16. package/dev/chunks/vidstack-BoLZuw80.js +0 -34
  17. package/dev/chunks/vidstack-BrqDQG-r.js +0 -643
  18. package/dev/chunks/vidstack-C3QPOZNd.js +0 -476
  19. package/dev/chunks/vidstack-C7BwfK5c.js +0 -1537
  20. package/dev/chunks/vidstack-CEUjDh4x.js +0 -34
  21. package/dev/chunks/vidstack-CFOPpDTy.js +0 -476
  22. package/dev/chunks/vidstack-CFZ0rYJz.js +0 -34
  23. package/dev/chunks/vidstack-CKsUl4ll.js +0 -1384
  24. package/dev/chunks/vidstack-CM82l-7o.js +0 -551
  25. package/dev/chunks/vidstack-CQSHFVu7.js +0 -401
  26. package/dev/chunks/vidstack-CXrXBlpD.js +0 -11692
  27. package/dev/chunks/vidstack-CevuS08D.js +0 -1504
  28. package/dev/chunks/vidstack-CkRXb9Ia.js +0 -1537
  29. package/dev/chunks/vidstack-CniPzPQc.js +0 -1537
  30. package/dev/chunks/vidstack-CqNX679o.js +0 -669
  31. package/dev/chunks/vidstack-Csfg08VS.js +0 -551
  32. package/dev/chunks/vidstack-CvWDiSTs.js +0 -84
  33. package/dev/chunks/vidstack-CzU-uC5f.js +0 -189
  34. package/dev/chunks/vidstack-D2Bi2Td9.js +0 -1537
  35. package/dev/chunks/vidstack-D3ZXOE4d.js +0 -643
  36. package/dev/chunks/vidstack-D6_9yy0x.js +0 -643
  37. package/dev/chunks/vidstack-DJQOTrl6.js +0 -180
  38. package/dev/chunks/vidstack-DNbKNc4R.js +0 -288
  39. package/dev/chunks/vidstack-DOtIyh4c.js +0 -288
  40. package/dev/chunks/vidstack-DTow20pt.js +0 -189
  41. package/dev/chunks/vidstack-DY2iivhG.js +0 -84
  42. package/dev/chunks/vidstack-DjqYvkVp.js +0 -84
  43. package/dev/chunks/vidstack-Dov8gjdq.js +0 -401
  44. package/dev/chunks/vidstack-DqaqkU4T.js +0 -9
  45. package/dev/chunks/vidstack-DwdhbP5c.js +0 -189
  46. package/dev/chunks/vidstack-DweQYzVw.js +0 -180
  47. package/dev/chunks/vidstack-FuCbl228.js +0 -226
  48. package/dev/chunks/vidstack-H9OdEKUQ.js +0 -375
  49. package/dev/chunks/vidstack-KntYDWMe.js +0 -668
  50. package/dev/chunks/vidstack-L5mw2iPb.js +0 -375
  51. package/dev/chunks/vidstack-NCBSBZE-.js +0 -61
  52. package/dev/chunks/vidstack-PREbBNMG.js +0 -125
  53. package/dev/chunks/vidstack-S_S6XDnL.js +0 -375
  54. package/dev/chunks/vidstack-UWMPvwsa.js +0 -1537
  55. package/dev/chunks/vidstack-f6WXkmfP.js +0 -375
  56. package/dev/chunks/vidstack-gqKBE4xH.js +0 -376
  57. package/dev/chunks/vidstack-iRuTLfhk.js +0 -61
  58. package/dev/chunks/vidstack-lYFZKRUc.js +0 -401
  59. package/dev/chunks/vidstack-oOGofWSl.js +0 -668
  60. package/dev/chunks/vidstack-vh0BKYWJ.js +0 -84
  61. package/prod/chunks/vidstack-0Foyib2F.js +0 -34
  62. package/prod/chunks/vidstack-58ZavMvv.js +0 -159
  63. package/prod/chunks/vidstack-B0SSIHIv.js +0 -1537
  64. package/prod/chunks/vidstack-B9nEslvl.js +0 -11197
  65. package/prod/chunks/vidstack-BCBskRpc.js +0 -664
  66. package/prod/chunks/vidstack-BOObgZd8.js +0 -504
  67. package/prod/chunks/vidstack-BS445j5D.js +0 -84
  68. package/prod/chunks/vidstack-BZVrgeRF.js +0 -9
  69. package/prod/chunks/vidstack-B_9VGrZQ.js +0 -504
  70. package/prod/chunks/vidstack-B_wD853-.js +0 -386
  71. package/prod/chunks/vidstack-BbPEqH3g.js +0 -11196
  72. package/prod/chunks/vidstack-Bh7M8kL6.js +0 -663
  73. package/prod/chunks/vidstack-BlPINAXN.js +0 -189
  74. package/prod/chunks/vidstack-Bm2UemPE.js +0 -470
  75. package/prod/chunks/vidstack-Bp_hAwzI.js +0 -61
  76. package/prod/chunks/vidstack-C4tNkfXj.js +0 -470
  77. package/prod/chunks/vidstack-C4tuISYG.js +0 -1504
  78. package/prod/chunks/vidstack-C5Rzkyfp.js +0 -375
  79. package/prod/chunks/vidstack-CKapDFwB.js +0 -376
  80. package/prod/chunks/vidstack-CNJwYQRW.js +0 -84
  81. package/prod/chunks/vidstack-CQll06Hv.js +0 -34
  82. package/prod/chunks/vidstack-CVzVtf1j.js +0 -61
  83. package/prod/chunks/vidstack-CYK75vJF.js +0 -1382
  84. package/prod/chunks/vidstack-CZNlvfmV.js +0 -288
  85. package/prod/chunks/vidstack-CbejzCJs.js +0 -1537
  86. package/prod/chunks/vidstack-CiQEyk_l.js +0 -189
  87. package/prod/chunks/vidstack-CiTWSpv_.js +0 -34
  88. package/prod/chunks/vidstack-CikQpsuo.js +0 -1537
  89. package/prod/chunks/vidstack-CtxjO6HG.js +0 -84
  90. package/prod/chunks/vidstack-CzjHdPIT.js +0 -375
  91. package/prod/chunks/vidstack-D0XCUWbp.js +0 -159
  92. package/prod/chunks/vidstack-D3cSYtez.js +0 -663
  93. package/prod/chunks/vidstack-D91K36KQ.js +0 -206
  94. package/prod/chunks/vidstack-DJThTSEm.js +0 -125
  95. package/prod/chunks/vidstack-DTyDOhwS.js +0 -504
  96. package/prod/chunks/vidstack-DVMwXUgY.js +0 -189
  97. package/prod/chunks/vidstack-DXSNXDnS.js +0 -1384
  98. package/prod/chunks/vidstack-D_Sd7838.js +0 -663
  99. package/prod/chunks/vidstack-D_ijTIbV.js +0 -11198
  100. package/prod/chunks/vidstack-DdiGCJVp.js +0 -504
  101. package/prod/chunks/vidstack-DgGDsAKh.js +0 -375
  102. package/prod/chunks/vidstack-DgsBXr1J.js +0 -84
  103. package/prod/chunks/vidstack-DhC5F6c8.js +0 -470
  104. package/prod/chunks/vidstack-DhSvljmQ.js +0 -375
  105. package/prod/chunks/vidstack-Djmla_FM.js +0 -545
  106. package/prod/chunks/vidstack-DpQw1Y33.js +0 -663
  107. package/prod/chunks/vidstack-DrEorv9m.js +0 -189
  108. package/prod/chunks/vidstack-Ma9rwtR0.js +0 -386
  109. package/prod/chunks/vidstack-VTpvHAdU.js +0 -1537
  110. package/prod/chunks/vidstack-dbLRgf2L.js +0 -159
  111. package/prod/chunks/vidstack-ehqxnvc9.js +0 -1537
  112. package/prod/chunks/vidstack-jIPoNqhj.js +0 -545
  113. package/prod/chunks/vidstack-lc8NHly9.js +0 -288
  114. package/prod/chunks/vidstack-rHvQ8f6c.js +0 -288
  115. package/prod/chunks/vidstack-rKV98aQH.js +0 -545
  116. package/prod/chunks/vidstack-uA7h-Bsq.js +0 -386
  117. package/prod/chunks/vidstack-xo_SmgiV.js +0 -84
  118. package/prod/chunks/vidstack-xvxeRtaN.js +0 -61
  119. package/server/chunks/vidstack--ufi23Q6.js +0 -1537
  120. package/server/chunks/vidstack-B3AXUfgF.js +0 -189
  121. package/server/chunks/vidstack-B4rJ1ZKK.js +0 -376
  122. package/server/chunks/vidstack-BJCx78pm.js +0 -386
  123. package/server/chunks/vidstack-BTdEfKqV.js +0 -84
  124. package/server/chunks/vidstack-BV_VpWlJ.js +0 -1537
  125. package/server/chunks/vidstack-BtitkRvR.js +0 -11198
  126. package/server/chunks/vidstack-BtqWstSj.js +0 -375
  127. package/server/chunks/vidstack-BweZhuNd.js +0 -1537
  128. package/server/chunks/vidstack-ByG5MvLs.js +0 -545
  129. package/server/chunks/vidstack-C-HdFsZi.js +0 -84
  130. package/server/chunks/vidstack-C0xOpWYR.js +0 -470
  131. package/server/chunks/vidstack-C481iXqe.js +0 -386
  132. package/server/chunks/vidstack-C4iWXMC-.js +0 -545
  133. package/server/chunks/vidstack-C5zFBMwg.js +0 -386
  134. package/server/chunks/vidstack-CEh38XpD.js +0 -288
  135. package/server/chunks/vidstack-CSiPajWY.js +0 -470
  136. package/server/chunks/vidstack-CbNRZgUA.js +0 -11197
  137. package/server/chunks/vidstack-CgXa6YO3.js +0 -61
  138. package/server/chunks/vidstack-CkMAeO-e.js +0 -34
  139. package/server/chunks/vidstack-Cm0qnRvu.js +0 -11196
  140. package/server/chunks/vidstack-CoGzBr_V.js +0 -663
  141. package/server/chunks/vidstack-Ct1NFlBa.js +0 -1537
  142. package/server/chunks/vidstack-CyFwkPiu.js +0 -470
  143. package/server/chunks/vidstack-D4t_SZbb.js +0 -1416
  144. package/server/chunks/vidstack-D7D9kiW6.js +0 -34
  145. package/server/chunks/vidstack-DH6N0AoF.js +0 -375
  146. package/server/chunks/vidstack-DJJmNib6.js +0 -504
  147. package/server/chunks/vidstack-DKr7br9D.js +0 -34
  148. package/server/chunks/vidstack-DM-5dPT-.js +0 -663
  149. package/server/chunks/vidstack-DOIUveQF.js +0 -504
  150. package/server/chunks/vidstack-DTn72IA8.js +0 -1504
  151. package/server/chunks/vidstack-DWfS9vAY.js +0 -84
  152. package/server/chunks/vidstack-DWt5LAKE.js +0 -375
  153. package/server/chunks/vidstack-DY51lx0R.js +0 -189
  154. package/server/chunks/vidstack-DbNoKLjz.js +0 -664
  155. package/server/chunks/vidstack-Dbs_rXUT.js +0 -663
  156. package/server/chunks/vidstack-DeS67_gx.js +0 -9
  157. package/server/chunks/vidstack-DiHlnSws.js +0 -1384
  158. package/server/chunks/vidstack-DnoqxmOs.js +0 -125
  159. package/server/chunks/vidstack-DsZKgA8y.js +0 -663
  160. package/server/chunks/vidstack-DtQSvsQr.js +0 -189
  161. package/server/chunks/vidstack-E7eUOyFt.js +0 -288
  162. package/server/chunks/vidstack-JkJEYEQM.js +0 -159
  163. package/server/chunks/vidstack-KhtuR229.js +0 -504
  164. package/server/chunks/vidstack-NXcLNXxO.js +0 -84
  165. package/server/chunks/vidstack-OKdxH1xx.js +0 -189
  166. package/server/chunks/vidstack-SkX-mSrw.js +0 -206
  167. package/server/chunks/vidstack-VGPw_CQP.js +0 -375
  168. package/server/chunks/vidstack-X1Hex9PH.js +0 -84
  169. package/server/chunks/vidstack-i9a2TQLO.js +0 -1537
  170. package/server/chunks/vidstack-iVN8uBAv.js +0 -288
  171. package/server/chunks/vidstack-jlaBqZq5.js +0 -61
  172. package/server/chunks/vidstack-m8aA99tE.js +0 -159
  173. package/server/chunks/vidstack-rUHVQoo3.js +0 -61
  174. package/server/chunks/vidstack-rWs25cS9.js +0 -159
  175. package/server/chunks/vidstack-uyCXITen.js +0 -504
  176. package/server/chunks/vidstack-yf18YVAb.js +0 -545
@@ -1,551 +0,0 @@
1
- "use client"
2
-
3
- import { createScope, signal, effect, peek, isString, deferredPromise, listenEvent, isArray } from './vidstack-D_bWd66h.js';
4
- import { TimeRange, RAFLoop, preconnect, ListSymbol, TextTrack, QualitySymbol } from './vidstack-CXrXBlpD.js';
5
- import { EmbedProvider } from './vidstack-NCBSBZE-.js';
6
- import { resolveVimeoVideoId, getVimeoVideoInfo } from './vidstack-krOAtKMi.js';
7
- import 'react';
8
- import '@floating-ui/dom';
9
-
10
- const trackedVimeoEvents = [
11
- "bufferend",
12
- "bufferstart",
13
- // 'cuechange',
14
- "durationchange",
15
- "ended",
16
- "enterpictureinpicture",
17
- "error",
18
- "fullscreenchange",
19
- "leavepictureinpicture",
20
- "loaded",
21
- // 'loadeddata',
22
- // 'loadedmetadata',
23
- // 'loadstart',
24
- "playProgress",
25
- "loadProgress",
26
- "pause",
27
- "play",
28
- "playbackratechange",
29
- // 'progress',
30
- "qualitychange",
31
- "seeked",
32
- "seeking",
33
- // 'texttrackchange',
34
- "timeupdate",
35
- "volumechange",
36
- "waiting"
37
- // 'adstarted',
38
- // 'adcompleted',
39
- // 'aderror',
40
- // 'adskipped',
41
- // 'adallcompleted',
42
- // 'adclicked',
43
- // 'chapterchange',
44
- // 'chromecastconnected',
45
- // 'remoteplaybackavailabilitychange',
46
- // 'remoteplaybackconnecting',
47
- // 'remoteplaybackconnect',
48
- // 'remoteplaybackdisconnect',
49
- // 'liveeventended',
50
- // 'liveeventstarted',
51
- // 'livestreamoffline',
52
- // 'livestreamonline',
53
- ];
54
-
55
- class VimeoProvider extends EmbedProvider {
56
- $$PROVIDER_TYPE = "VIMEO";
57
- scope = createScope();
58
- fullscreen;
59
- #ctx;
60
- #videoId = signal("");
61
- #pro = signal(false);
62
- #hash = null;
63
- #currentSrc = null;
64
- #fullscreenActive = false;
65
- #seekableRange = new TimeRange(0, 0);
66
- #timeRAF = new RAFLoop(this.#onAnimationFrame.bind(this));
67
- #currentCue = null;
68
- #chaptersTrack = null;
69
- #promises = /* @__PURE__ */ new Map();
70
- #videoInfoPromise = null;
71
- constructor(iframe, ctx) {
72
- super(iframe);
73
- this.#ctx = ctx;
74
- const self = this;
75
- this.fullscreen = {
76
- get active() {
77
- return self.#fullscreenActive;
78
- },
79
- supported: true,
80
- enter: () => this.#remote("requestFullscreen"),
81
- exit: () => this.#remote("exitFullscreen")
82
- };
83
- }
84
- /**
85
- * Whether tracking session data should be enabled on the embed, including cookies and analytics.
86
- * This is turned off by default to be GDPR-compliant.
87
- *
88
- * @defaultValue `false`
89
- */
90
- cookies = false;
91
- title = true;
92
- byline = true;
93
- portrait = true;
94
- color = "00ADEF";
95
- get type() {
96
- return "vimeo";
97
- }
98
- get currentSrc() {
99
- return this.#currentSrc;
100
- }
101
- get videoId() {
102
- return this.#videoId();
103
- }
104
- get hash() {
105
- return this.#hash;
106
- }
107
- get isPro() {
108
- return this.#pro();
109
- }
110
- preconnect() {
111
- preconnect(this.getOrigin());
112
- }
113
- setup() {
114
- super.setup();
115
- effect(this.#watchVideoId.bind(this));
116
- effect(this.#watchVideoInfo.bind(this));
117
- effect(this.#watchPro.bind(this));
118
- this.#ctx.notify("provider-setup", this);
119
- }
120
- destroy() {
121
- this.#reset();
122
- this.fullscreen = void 0;
123
- const message = "provider destroyed";
124
- for (const promises of this.#promises.values()) {
125
- for (const { reject } of promises) reject(message);
126
- }
127
- this.#promises.clear();
128
- this.#remote("destroy");
129
- }
130
- async play() {
131
- return this.#remote("play");
132
- }
133
- async pause() {
134
- return this.#remote("pause");
135
- }
136
- setMuted(muted) {
137
- this.#remote("setMuted", muted);
138
- }
139
- setCurrentTime(time) {
140
- this.#remote("seekTo", time);
141
- this.#ctx.notify("seeking", time);
142
- }
143
- setVolume(volume) {
144
- this.#remote("setVolume", volume);
145
- this.#remote("setMuted", peek(this.#ctx.$state.muted));
146
- }
147
- setPlaybackRate(rate) {
148
- this.#remote("setPlaybackRate", rate);
149
- }
150
- async loadSource(src) {
151
- if (!isString(src.src)) {
152
- this.#currentSrc = null;
153
- this.#hash = null;
154
- this.#videoId.set("");
155
- return;
156
- }
157
- const { videoId, hash } = resolveVimeoVideoId(src.src);
158
- this.#videoId.set(videoId ?? "");
159
- this.#hash = hash ?? null;
160
- this.#currentSrc = src;
161
- }
162
- #watchVideoId() {
163
- this.#reset();
164
- const videoId = this.#videoId();
165
- if (!videoId) {
166
- this.src.set("");
167
- return;
168
- }
169
- this.src.set(`${this.getOrigin()}/video/${videoId}`);
170
- this.#ctx.notify("load-start");
171
- }
172
- #watchVideoInfo() {
173
- const videoId = this.#videoId();
174
- if (!videoId) return;
175
- const promise = deferredPromise(), abort = new AbortController();
176
- this.#videoInfoPromise = promise;
177
- getVimeoVideoInfo(videoId, abort, this.#hash).then((info) => {
178
- promise.resolve(info);
179
- }).catch((e) => {
180
- promise.reject();
181
- {
182
- this.#ctx.logger?.warnGroup(`Failed to fetch vimeo video info for id \`${videoId}\`.`).labelledLog("Error", e).dispatch();
183
- }
184
- });
185
- return () => {
186
- promise.reject();
187
- abort.abort();
188
- };
189
- }
190
- #watchPro() {
191
- const isPro = this.#pro(), { $state, qualities } = this.#ctx;
192
- $state.canSetPlaybackRate.set(isPro);
193
- qualities[ListSymbol.setReadonly](!isPro);
194
- if (isPro) {
195
- return listenEvent(qualities, "change", () => {
196
- if (qualities.auto) return;
197
- const id = qualities.selected?.id;
198
- if (id) this.#remote("setQuality", id);
199
- });
200
- }
201
- }
202
- getOrigin() {
203
- return "https://player.vimeo.com";
204
- }
205
- buildParams() {
206
- const { keyDisabled } = this.#ctx.$props, { playsInline, nativeControls } = this.#ctx.$state, showControls = nativeControls();
207
- return {
208
- title: this.title,
209
- byline: this.byline,
210
- color: this.color,
211
- portrait: this.portrait,
212
- controls: showControls,
213
- h: this.hash,
214
- keyboard: showControls && !keyDisabled(),
215
- transparent: true,
216
- playsinline: playsInline(),
217
- dnt: !this.cookies
218
- };
219
- }
220
- #onAnimationFrame() {
221
- this.#remote("getCurrentTime");
222
- }
223
- // Embed will sometimes dispatch 0 at end of playback.
224
- #preventTimeUpdates = false;
225
- #onTimeUpdate(time, trigger) {
226
- if (this.#preventTimeUpdates && time === 0) return;
227
- const { realCurrentTime, paused, bufferedEnd, seekableEnd, live } = this.#ctx.$state;
228
- if (realCurrentTime() === time) return;
229
- const prevTime = realCurrentTime();
230
- this.#ctx.notify("time-change", time, trigger);
231
- if (Math.abs(prevTime - time) > 1.5) {
232
- this.#ctx.notify("seeking", time, trigger);
233
- if (!paused() && bufferedEnd() < time) {
234
- this.#ctx.notify("waiting", void 0, trigger);
235
- }
236
- }
237
- if (!live() && seekableEnd() - time < 0.01) {
238
- this.#ctx.notify("end", void 0, trigger);
239
- this.#preventTimeUpdates = true;
240
- setTimeout(() => {
241
- this.#preventTimeUpdates = false;
242
- }, 500);
243
- }
244
- }
245
- #onSeeked(time, trigger) {
246
- this.#ctx.notify("seeked", time, trigger);
247
- }
248
- #onLoaded(trigger) {
249
- const videoId = this.#videoId();
250
- this.#videoInfoPromise?.promise.then((info) => {
251
- if (!info) return;
252
- const { title, poster, duration, pro } = info;
253
- this.#pro.set(pro);
254
- this.#ctx.notify("title-change", title, trigger);
255
- this.#ctx.notify("poster-change", poster, trigger);
256
- this.#ctx.notify("duration-change", duration, trigger);
257
- this.#onReady(duration, trigger);
258
- }).catch(() => {
259
- if (videoId !== this.#videoId()) return;
260
- this.#remote("getVideoTitle");
261
- this.#remote("getDuration");
262
- });
263
- }
264
- #onReady(duration, trigger) {
265
- const { nativeControls } = this.#ctx.$state, showEmbedControls = nativeControls();
266
- this.#seekableRange = new TimeRange(0, duration);
267
- const detail = {
268
- buffered: new TimeRange(0, 0),
269
- seekable: this.#seekableRange,
270
- duration
271
- };
272
- this.#ctx.delegate.ready(detail, trigger);
273
- if (!showEmbedControls) {
274
- this.#remote("_hideOverlay");
275
- }
276
- this.#remote("getQualities");
277
- this.#remote("getChapters");
278
- }
279
- #onMethod(method, data, trigger) {
280
- switch (method) {
281
- case "getVideoTitle":
282
- const videoTitle = data;
283
- this.#ctx.notify("title-change", videoTitle, trigger);
284
- break;
285
- case "getDuration":
286
- const duration = data;
287
- if (!this.#ctx.$state.canPlay()) {
288
- this.#onReady(duration, trigger);
289
- } else {
290
- this.#ctx.notify("duration-change", duration, trigger);
291
- }
292
- break;
293
- case "getCurrentTime":
294
- this.#onTimeUpdate(data, trigger);
295
- break;
296
- case "getBuffered":
297
- if (isArray(data) && data.length) {
298
- this.#onLoadProgress(data[data.length - 1][1], trigger);
299
- }
300
- break;
301
- case "setMuted":
302
- case "getMuted":
303
- this.#onVolumeChange(peek(this.#ctx.$state.volume), data, trigger);
304
- break;
305
- // case 'getTextTracks':
306
- // this.#onTextTracksChange(data as VimeoTextTrack[], trigger);
307
- // break;
308
- case "getChapters":
309
- this.#onChaptersChange(data);
310
- break;
311
- case "getQualities":
312
- this.#onQualitiesChange(data, trigger);
313
- break;
314
- }
315
- this.#getPromise(method)?.resolve();
316
- }
317
- #attachListeners() {
318
- for (const type of trackedVimeoEvents) {
319
- this.#remote("addEventListener", type);
320
- }
321
- }
322
- #onPause(trigger) {
323
- this.#timeRAF.stop();
324
- this.#ctx.notify("pause", void 0, trigger);
325
- }
326
- async #onPlay(trigger) {
327
- this.#timeRAF.start();
328
- await this.#remote("getMuted");
329
- this.#ctx.notify("play", void 0, trigger);
330
- }
331
- #onPlayProgress(trigger) {
332
- const { paused } = this.#ctx.$state;
333
- if (!paused() && !this.#preventTimeUpdates) {
334
- this.#ctx.notify("playing", void 0, trigger);
335
- }
336
- }
337
- #onLoadProgress(buffered, trigger) {
338
- const detail = {
339
- buffered: new TimeRange(0, buffered),
340
- seekable: this.#seekableRange
341
- };
342
- this.#ctx.notify("progress", detail, trigger);
343
- }
344
- #onBufferStart(trigger) {
345
- this.#ctx.notify("waiting", void 0, trigger);
346
- }
347
- #onBufferEnd(trigger) {
348
- const { paused } = this.#ctx.$state;
349
- if (!paused()) this.#ctx.notify("playing", void 0, trigger);
350
- }
351
- async #onWaiting(trigger) {
352
- const { paused } = this.#ctx.$state;
353
- if (paused()) {
354
- await this.#remote("getMuted");
355
- this.#ctx.notify("play", void 0, trigger);
356
- }
357
- this.#ctx.notify("waiting", void 0, trigger);
358
- }
359
- #onVolumeChange(volume, muted, trigger) {
360
- const detail = { volume, muted };
361
- this.#ctx.notify("volume-change", detail, trigger);
362
- }
363
- // #onTextTrackChange(track: VimeoTextTrack, trigger: Event) {
364
- // const textTrack = this.#ctx.textTracks.toArray().find((t) => t.language === track.language);
365
- // if (textTrack) textTrack.mode = track.mode;
366
- // }
367
- // #onTextTracksChange(tracks: VimeoTextTrack[], trigger: Event) {
368
- // for (const init of tracks) {
369
- // const textTrack = new TextTrack({
370
- // ...init,
371
- // label: init.label.replace('auto-generated', 'auto'),
372
- // });
373
- // textTrack[TextTrackSymbol.readyState] = 2;
374
- // this.#ctx.textTracks.add(textTrack, trigger);
375
- // textTrack.setMode(init.mode, trigger);
376
- // }
377
- // }
378
- // #onCueChange(cue: VimeoTextCue, trigger: Event) {
379
- // const { textTracks, $state } = this.#ctx,
380
- // { currentTime } = $state,
381
- // track = textTracks.selected;
382
- // if (this.#currentCue) track?.removeCue(this.#currentCue, trigger);
383
- // this.#currentCue = new window.VTTCue(currentTime(), Number.MAX_SAFE_INTEGER, cue.text);
384
- // track?.addCue(this.#currentCue, trigger);
385
- // }
386
- #onChaptersChange(chapters) {
387
- this.#removeChapters();
388
- if (!chapters.length) return;
389
- const track = new TextTrack({
390
- kind: "chapters",
391
- default: true
392
- }), { seekableEnd } = this.#ctx.$state;
393
- for (let i = 0; i < chapters.length; i++) {
394
- const chapter = chapters[i], nextChapter = chapters[i + 1];
395
- track.addCue(
396
- new window.VTTCue(
397
- chapter.startTime,
398
- nextChapter?.startTime ?? seekableEnd(),
399
- chapter.title
400
- )
401
- );
402
- }
403
- this.#chaptersTrack = track;
404
- this.#ctx.textTracks.add(track);
405
- }
406
- #removeChapters() {
407
- if (!this.#chaptersTrack) return;
408
- this.#ctx.textTracks.remove(this.#chaptersTrack);
409
- this.#chaptersTrack = null;
410
- }
411
- #onQualitiesChange(qualities, trigger) {
412
- this.#ctx.qualities[QualitySymbol.enableAuto] = qualities.some((q) => q.id === "auto") ? () => this.#remote("setQuality", "auto") : void 0;
413
- for (const quality of qualities) {
414
- if (quality.id === "auto") continue;
415
- const height = +quality.id.slice(0, -1);
416
- if (isNaN(height)) continue;
417
- this.#ctx.qualities[ListSymbol.add](
418
- {
419
- id: quality.id,
420
- width: height * (16 / 9),
421
- height,
422
- codec: "avc1,h.264",
423
- bitrate: -1
424
- },
425
- trigger
426
- );
427
- }
428
- this.#onQualityChange(
429
- qualities.find((q) => q.active),
430
- trigger
431
- );
432
- }
433
- #onQualityChange({ id } = {}, trigger) {
434
- if (!id) return;
435
- const isAuto = id === "auto", newQuality = this.#ctx.qualities.getById(id);
436
- if (isAuto) {
437
- this.#ctx.qualities[QualitySymbol.setAuto](isAuto, trigger);
438
- this.#ctx.qualities[ListSymbol.select](void 0, true, trigger);
439
- } else {
440
- this.#ctx.qualities[ListSymbol.select](newQuality ?? void 0, true, trigger);
441
- }
442
- }
443
- #onEvent(event, payload, trigger) {
444
- switch (event) {
445
- case "ready":
446
- this.#attachListeners();
447
- break;
448
- case "loaded":
449
- this.#onLoaded(trigger);
450
- break;
451
- case "play":
452
- this.#onPlay(trigger);
453
- break;
454
- case "playProgress":
455
- this.#onPlayProgress(trigger);
456
- break;
457
- case "pause":
458
- this.#onPause(trigger);
459
- break;
460
- case "loadProgress":
461
- this.#onLoadProgress(payload.seconds, trigger);
462
- break;
463
- case "waiting":
464
- this.#onWaiting(trigger);
465
- break;
466
- case "bufferstart":
467
- this.#onBufferStart(trigger);
468
- break;
469
- case "bufferend":
470
- this.#onBufferEnd(trigger);
471
- break;
472
- case "volumechange":
473
- this.#onVolumeChange(payload.volume, peek(this.#ctx.$state.muted), trigger);
474
- break;
475
- case "durationchange":
476
- this.#seekableRange = new TimeRange(0, payload.duration);
477
- this.#ctx.notify("duration-change", payload.duration, trigger);
478
- break;
479
- case "playbackratechange":
480
- this.#ctx.notify("rate-change", payload.playbackRate, trigger);
481
- break;
482
- case "qualitychange":
483
- this.#onQualityChange(payload, trigger);
484
- break;
485
- case "fullscreenchange":
486
- this.#fullscreenActive = payload.fullscreen;
487
- this.#ctx.notify("fullscreen-change", payload.fullscreen, trigger);
488
- break;
489
- case "enterpictureinpicture":
490
- this.#ctx.notify("picture-in-picture-change", true, trigger);
491
- break;
492
- case "leavepictureinpicture":
493
- this.#ctx.notify("picture-in-picture-change", false, trigger);
494
- break;
495
- case "ended":
496
- this.#ctx.notify("end", void 0, trigger);
497
- break;
498
- case "error":
499
- this.#onError(payload, trigger);
500
- break;
501
- case "seek":
502
- case "seeked":
503
- this.#onSeeked(payload.seconds, trigger);
504
- break;
505
- }
506
- }
507
- #onError(error, trigger) {
508
- const { message, method } = error;
509
- if (method === "setPlaybackRate") {
510
- this.#pro.set(false);
511
- }
512
- if (method) {
513
- this.#getPromise(method)?.reject(message);
514
- }
515
- {
516
- this.#ctx.logger?.errorGroup(`[vimeo]: ${message}`).labelledLog("Error", error).labelledLog("Provider", this).labelledLog("Event", trigger).dispatch();
517
- }
518
- }
519
- onMessage(message, event) {
520
- if (message.event) {
521
- this.#onEvent(message.event, message.data, event);
522
- } else if (message.method) {
523
- this.#onMethod(message.method, message.value, event);
524
- }
525
- }
526
- onLoad() {
527
- }
528
- async #remote(command, arg) {
529
- let promise = deferredPromise(), promises = this.#promises.get(command);
530
- if (!promises) this.#promises.set(command, promises = []);
531
- promises.push(promise);
532
- this.postMessage({
533
- method: command,
534
- value: arg
535
- });
536
- return promise.promise;
537
- }
538
- #reset() {
539
- this.#timeRAF.stop();
540
- this.#seekableRange = new TimeRange(0, 0);
541
- this.#videoInfoPromise = null;
542
- this.#currentCue = null;
543
- this.#pro.set(false);
544
- this.#removeChapters();
545
- }
546
- #getPromise(command) {
547
- return this.#promises.get(command)?.shift();
548
- }
549
- }
550
-
551
- export { VimeoProvider };