@instructure/studio-player 0.1.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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/StudioPlayer/StudioPlayer.d.ts +10 -0
  4. package/dist/StudioPlayer/StudioPlayerContext.d.ts +11 -0
  5. package/dist/StudioPlayer/components/BufferingIndicator/BufferingIndicator.d.ts +1 -0
  6. package/dist/StudioPlayer/components/CaptionsButton/CaptionsButton.d.ts +1 -0
  7. package/dist/StudioPlayer/components/CaptionsOverlay/CaptionsOverlay.d.ts +5 -0
  8. package/dist/StudioPlayer/components/ControlsLayout/ControlsLayout.d.ts +1 -0
  9. package/dist/StudioPlayer/components/CustomSettingsMenu/CustomSettingsMenu.d.ts +1 -0
  10. package/dist/StudioPlayer/components/CustomSettingsMenu/CustomSettingsMenuContext.d.ts +8 -0
  11. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/CaptionsMenu/CaptionsFontSizeMenu.d.ts +1 -0
  12. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/CaptionsMenu/CaptionsLanguageMenu.d.ts +1 -0
  13. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/CaptionsMenu/CaptionsMenu.d.ts +1 -0
  14. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/MainMenu/MainMenu.d.ts +1 -0
  15. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/QualityMenu/QualityMenu.d.ts +1 -0
  16. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/SpeedMenu/SpeedMenu.d.ts +1 -0
  17. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/buttons/BaseButton.d.ts +8 -0
  18. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/buttons/CaptionsButton.d.ts +1 -0
  19. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/buttons/CaptionsFontSizeButton.d.ts +1 -0
  20. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/buttons/CaptionsLanguageButton.d.ts +1 -0
  21. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/buttons/QualityButton.d.ts +1 -0
  22. package/dist/StudioPlayer/components/CustomSettingsMenu/menus/buttons/SpeedButton.d.ts +1 -0
  23. package/dist/StudioPlayer/components/CustomSettingsMenu/useCallbackOnEsc.d.ts +1 -0
  24. package/dist/StudioPlayer/components/CustomSettingsMenu/useCustomSettingsMenu.d.ts +18 -0
  25. package/dist/StudioPlayer/components/FeedbackOverlay/FeedbackIcon.d.ts +1 -0
  26. package/dist/StudioPlayer/components/FeedbackOverlay/FeedbackMessage.d.ts +1 -0
  27. package/dist/StudioPlayer/components/FeedbackOverlay/FeedbackOverlay.d.ts +1 -0
  28. package/dist/StudioPlayer/components/FeedbackOverlay/createFeedbackComponent.d.ts +1 -0
  29. package/dist/StudioPlayer/components/FullscreenButton/FullscreenButton.d.ts +1 -0
  30. package/dist/StudioPlayer/components/GesturesContainer/GesturesContainer.d.ts +1 -0
  31. package/dist/StudioPlayer/components/PlayPauseButton/PlayPauseButton.d.ts +1 -0
  32. package/dist/StudioPlayer/components/PosterContainer/PosterContainer.d.ts +4 -0
  33. package/dist/StudioPlayer/components/SmallLayoutOverlay/SmallLayoutOverlay.d.ts +1 -0
  34. package/dist/StudioPlayer/components/TimeIndicator/TimeIndicator.d.ts +1 -0
  35. package/dist/StudioPlayer/components/TimeLine/TimeLine.d.ts +4 -0
  36. package/dist/StudioPlayer/components/VolumeMenu/VolumeMenu.d.ts +1 -0
  37. package/dist/StudioPlayer/components/index.d.ts +14 -0
  38. package/dist/StudioPlayer/shortcuts.d.ts +2 -0
  39. package/dist/constants.d.ts +5 -0
  40. package/dist/errors-DCJKAXTz.js +70 -0
  41. package/dist/index-BM9a_WKH.js +33480 -0
  42. package/dist/index.css +1 -0
  43. package/dist/index.d.ts +3 -0
  44. package/dist/prod-DTLJXtPo.js +994 -0
  45. package/dist/srt-parser-CWqahKwO.js +27 -0
  46. package/dist/ssa-parser-BqjjKy4M.js +209 -0
  47. package/dist/studio-player.es.js +6 -0
  48. package/dist/types.d.ts +6 -0
  49. package/dist/vidstack-B-YW57m0-DZMwUKSQ.js +140 -0
  50. package/dist/vidstack-BFbyAy5g-DqVWIlTG.js +378 -0
  51. package/dist/vidstack-BGEqnOoX-BiZsT73r.js +434 -0
  52. package/dist/vidstack-CC0Rsbn0-Cf76Gp3K.js +32 -0
  53. package/dist/vidstack-CbSFenOv-DX2VhxT6.js +60 -0
  54. package/dist/vidstack-D2cUZes0-BnrvKkrf.js +237 -0
  55. package/dist/vidstack-Xu8hy52p-DHV2kI-e.js +323 -0
  56. package/dist/vidstack-Zc3I7oOd-DDsBgkhs.js +31 -0
  57. package/dist/vidstack-krOAtKMi-B4IZWKdc.js +29 -0
  58. package/package.json +78 -0
@@ -0,0 +1,27 @@
1
+ import { V as c, a as i, b as a } from "./prod-DTLJXtPo.js";
2
+ const n = /,/g, u = "-->";
3
+ class o extends c {
4
+ parse(s, e) {
5
+ var h, r;
6
+ if (s === "")
7
+ this.c && (this.l.push(this.c), (r = (h = this.h).onCue) == null || r.call(h, this.c), this.c = null), this.e = i.None;
8
+ else if (this.e === i.Cue)
9
+ this.c.text += (this.c.text ? `
10
+ ` : "") + s;
11
+ else if (s.includes(u)) {
12
+ const t = this.q(s, e);
13
+ t && (this.c = new a(t[0], t[1], t[2].join(" ")), this.c.id = this.n, this.e = i.Cue);
14
+ }
15
+ this.n = s;
16
+ }
17
+ q(s, e) {
18
+ return super.q(s.replace(n, "."), e);
19
+ }
20
+ }
21
+ function l() {
22
+ return new o();
23
+ }
24
+ export {
25
+ o as SRTParser,
26
+ l as default
27
+ };
@@ -0,0 +1,209 @@
1
+ var F = Object.defineProperty;
2
+ var A = (c, t, s) => t in c ? F(c, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : c[t] = s;
3
+ var u = (c, t, s) => A(c, typeof t != "symbol" ? t + "" : t, s);
4
+ import { b as L, p as y } from "./prod-DTLJXtPo.js";
5
+ const S = /^Format:[\s\t]*/, O = /^Style:[\s\t]*/, _ = /^Dialogue:[\s\t]*/, d = /[\s\t]*,[\s\t]*/, w = /\{[^}]+\}/g, I = /\\N/g, x = /^\[(.*)[\s\t]?Styles\]$/, k = /^\[(.*)[\s\t]?Events\]$/;
6
+ class $ {
7
+ constructor() {
8
+ u(this, "h");
9
+ u(this, "O", 0);
10
+ u(this, "c", null);
11
+ u(this, "l", []);
12
+ u(this, "m", []);
13
+ u(this, "N", null);
14
+ u(this, "f");
15
+ u(this, "P", {});
16
+ }
17
+ async init(t) {
18
+ this.h = t, t.errors && (this.f = (await import("./errors-DCJKAXTz.js")).ParseErrorBuilder);
19
+ }
20
+ parse(t, s) {
21
+ var e, a;
22
+ if (this.O)
23
+ switch (this.O) {
24
+ case 1:
25
+ if (t === "")
26
+ this.O = 0;
27
+ else if (O.test(t))
28
+ if (this.N) {
29
+ const i = t.replace(O, "").split(d);
30
+ this.S(i);
31
+ } else
32
+ this.g((e = this.f) == null ? void 0 : e.T("Style", s));
33
+ else S.test(t) ? this.N = t.replace(S, "").split(d) : k.test(t) && (this.N = null, this.O = 2);
34
+ break;
35
+ case 2:
36
+ if (t === "")
37
+ this.Q();
38
+ else if (_.test(t))
39
+ if (this.Q(), this.N) {
40
+ const i = t.replace(_, "").split(d), r = this.U(i, s);
41
+ r && (this.c = r);
42
+ } else
43
+ this.g((a = this.f) == null ? void 0 : a.T("Dialogue", s));
44
+ else this.c ? this.c.text += `
45
+ ` + t.replace(w, "").replace(I, `
46
+ `) : S.test(t) ? this.N = t.replace(S, "").split(d) : x.test(t) ? (this.N = null, this.O = 1) : k.test(t) && (this.N = null);
47
+ }
48
+ else t === "" || (x.test(t) ? (this.N = null, this.O = 1) : k.test(t) && (this.N = null, this.O = 2));
49
+ }
50
+ done() {
51
+ return {
52
+ metadata: {},
53
+ cues: this.l,
54
+ regions: [],
55
+ errors: this.m
56
+ };
57
+ }
58
+ Q() {
59
+ var t, s;
60
+ this.c && (this.l.push(this.c), (s = (t = this.h).onCue) == null || s.call(t, this.c), this.c = null);
61
+ }
62
+ S(t) {
63
+ let s = "Default", e = {}, a, i = "center", r = "bottom", f, n = 1.2, o, p, h = 3, b = [];
64
+ for (let g = 0; g < this.N.length; g++) {
65
+ const M = this.N[g], l = t[g];
66
+ switch (M) {
67
+ case "Name":
68
+ s = l;
69
+ break;
70
+ case "Fontname":
71
+ e["font-family"] = l;
72
+ break;
73
+ case "Fontsize":
74
+ e["font-size"] = `calc(${l} / var(--overlay-height))`;
75
+ break;
76
+ case "PrimaryColour":
77
+ const E = N(l);
78
+ E && (e["--cue-color"] = E);
79
+ break;
80
+ case "BorderStyle":
81
+ h = parseInt(l, 10);
82
+ break;
83
+ case "BackColour":
84
+ p = N(l);
85
+ break;
86
+ case "OutlineColour":
87
+ const R = N(l);
88
+ R && (o = R);
89
+ break;
90
+ case "Bold":
91
+ parseInt(l) && (e["font-weight"] = "bold");
92
+ break;
93
+ case "Italic":
94
+ parseInt(l) && (e["font-style"] = "italic");
95
+ break;
96
+ case "Underline":
97
+ parseInt(l) && (e["text-decoration"] = "underline");
98
+ break;
99
+ case "StrikeOut":
100
+ parseInt(l) && (e["text-decoration"] = "line-through");
101
+ break;
102
+ case "Spacing":
103
+ e["letter-spacing"] = l + "px";
104
+ break;
105
+ case "AlphaLevel":
106
+ e.opacity = parseFloat(l);
107
+ break;
108
+ case "ScaleX":
109
+ b.push(`scaleX(${parseFloat(l) / 100})`);
110
+ break;
111
+ case "ScaleY":
112
+ b.push(`scaleY(${parseFloat(l) / 100})`);
113
+ break;
114
+ case "Angle":
115
+ b.push(`rotate(${l}deg)`);
116
+ break;
117
+ case "Shadow":
118
+ n = parseInt(l, 10) * 1.2;
119
+ break;
120
+ case "MarginL":
121
+ e["--cue-width"] = "auto", e["--cue-left"] = parseFloat(l) + "px";
122
+ break;
123
+ case "MarginR":
124
+ e["--cue-width"] = "auto", e["--cue-right"] = parseFloat(l) + "px";
125
+ break;
126
+ case "MarginV":
127
+ f = parseFloat(l);
128
+ break;
129
+ case "Outline":
130
+ a = parseInt(l, 10);
131
+ break;
132
+ case "Alignment":
133
+ const m = parseInt(l, 10);
134
+ switch (m >= 4 && (r = m >= 7 ? "top" : "center"), m % 3) {
135
+ case 1:
136
+ i = "start";
137
+ break;
138
+ case 2:
139
+ i = "center";
140
+ break;
141
+ case 3:
142
+ i = "end";
143
+ break;
144
+ }
145
+ }
146
+ }
147
+ if (e.R = r, e["--cue-white-space"] = "normal", e["--cue-line-height"] = "normal", e["--cue-text-align"] = i, r === "center" ? (e["--cue-top"] = "50%", b.push("translateY(-50%)")) : e[`--cue-${r}`] = (f || 0) + "px", h === 1 && (e["--cue-padding-y"] = "0"), (h === 1 || p) && (e["--cue-bg-color"] = h === 1 ? "none" : p), h === 3 && o && (e["--cue-outline"] = `${a}px solid ${o}`), h === 1 && typeof a == "number") {
148
+ const g = p ?? "#000";
149
+ e["--cue-text-shadow"] = [
150
+ o && T(a * 1.2, n * 1.2, o),
151
+ o ? T(a * (a / 2), n * (a / 2), g) : T(a, n, g)
152
+ ].filter(Boolean).join(", ");
153
+ }
154
+ b.length && (e["--cue-transform"] = b.join(" ")), this.P[s] = e;
155
+ }
156
+ U(t, s) {
157
+ const e = this.V(t), a = this.q(e.Start, e.End, s);
158
+ if (!a)
159
+ return;
160
+ const i = new L(a[0], a[1], ""), r = { ...this.P[e.Style] || {} }, f = e.Name ? `<v ${e.Name}>` : "", n = r.R, o = e.MarginL && parseFloat(e.MarginL), p = e.MarginR && parseFloat(e.MarginR), h = e.MarginV && parseFloat(e.MarginV);
161
+ return o && (r["--cue-width"] = "auto", r["--cue-left"] = o + "px"), p && (r["--cue-width"] = "auto", r["--cue-right"] = p + "px"), h && n !== "center" && (r[`--cue-${n}`] = h + "px"), i.text = f + t.slice(this.N.length - 1).join(", ").replace(w, "").replace(I, `
162
+ `), delete r.R, Object.keys(r).length && (i.style = r), i;
163
+ }
164
+ V(t) {
165
+ const s = {};
166
+ for (let e = 0; e < this.N.length; e++)
167
+ s[this.N[e]] = t[e];
168
+ return s;
169
+ }
170
+ q(t, s, e) {
171
+ var r, f, n;
172
+ const a = y(t), i = y(s);
173
+ if (a !== null && i !== null && i > a)
174
+ return [a, i];
175
+ a === null && this.g((r = this.f) == null ? void 0 : r.s(t, e)), i === null && this.g((f = this.f) == null ? void 0 : f.t(s, e)), a != null && i !== null && i > a && this.g((n = this.f) == null ? void 0 : n.u(a, i, e));
176
+ }
177
+ g(t) {
178
+ var s, e;
179
+ if (t) {
180
+ if (this.m.push(t), this.h.strict)
181
+ throw this.h.cancel(), t;
182
+ (e = (s = this.h).onError) == null || e.call(s, t);
183
+ }
184
+ }
185
+ }
186
+ function N(c) {
187
+ const t = parseInt(c.replace("&H", ""), 16);
188
+ if (t >= 0) {
189
+ const e = (t >> 24 & 255 ^ 255) / 255, a = t >> 16 & 255, i = t >> 8 & 255;
190
+ return "rgba(" + [t & 255, i, a, e].join(",") + ")";
191
+ }
192
+ return null;
193
+ }
194
+ function T(c, t, s) {
195
+ const e = Math.ceil(2 * Math.PI * c);
196
+ let a = "";
197
+ for (let i = 0; i < e; i++) {
198
+ const r = 2 * Math.PI * i / e;
199
+ a += c * Math.cos(r) + "px " + t * Math.sin(r) + "px 0 " + s + (i == e - 1 ? "" : ",");
200
+ }
201
+ return a;
202
+ }
203
+ function v() {
204
+ return new $();
205
+ }
206
+ export {
207
+ $ as SSAParser,
208
+ v as default
209
+ };
@@ -0,0 +1,6 @@
1
+ import { E as a, P as A, S as E } from "./index-BM9a_WKH.js";
2
+ export {
3
+ a as CAPTION_FONT_SIZE_MULTIPLIERS,
4
+ A as PLAYBACK_RATES,
5
+ E as StudioPlayer
6
+ };
@@ -0,0 +1,6 @@
1
+ export type CaptionMetaData = {
2
+ src: string;
3
+ label: string;
4
+ language: string;
5
+ type: 'vtt' | 'srt';
6
+ };
@@ -0,0 +1,140 @@
1
+ var k = Object.defineProperty;
2
+ var w = (t) => {
3
+ throw TypeError(t);
4
+ };
5
+ var A = (t, e, a) => e in t ? k(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
+ var u = (t, e, a) => A(t, typeof e != "symbol" ? e + "" : e, a), C = (t, e, a) => e.has(t) || w("Cannot " + a);
7
+ var c = (t, e, a) => (C(t, e, "read from private field"), a ? a.call(t) : e.get(t)), h = (t, e, a) => e.has(t) ? w("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), E = (t, e, a, o) => (C(t, e, "write to private field"), o ? o.call(t, a) : e.set(t, a), a), s = (t, e, a) => (C(t, e, "access private method"), a);
8
+ import { l as P, I as O, y as R, z as b, c as D, x as G, h as L } from "./index-BM9a_WKH.js";
9
+ function M() {
10
+ return "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
11
+ }
12
+ function N() {
13
+ var t;
14
+ return !!((t = window.cast) != null && t.framework);
15
+ }
16
+ function F() {
17
+ var t, e;
18
+ return !!((e = (t = window.chrome) == null ? void 0 : t.cast) != null && e.isAvailable);
19
+ }
20
+ function v() {
21
+ return g().getCastState() === cast.framework.CastState.CONNECTED;
22
+ }
23
+ function g() {
24
+ return window.cast.framework.CastContext.getInstance();
25
+ }
26
+ function y() {
27
+ return g().getCurrentSession();
28
+ }
29
+ function T() {
30
+ var t;
31
+ return (t = y()) == null ? void 0 : t.getSessionObj().media[0];
32
+ }
33
+ function J(t) {
34
+ var a;
35
+ return ((a = T()) == null ? void 0 : a.media.contentId) === (t == null ? void 0 : t.src);
36
+ }
37
+ function U() {
38
+ return {
39
+ language: "en-US",
40
+ autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
41
+ receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,
42
+ resumeSavedSession: !0,
43
+ androidReceiverCompatible: !0
44
+ };
45
+ }
46
+ function j(t) {
47
+ return `Google Cast Error Code: ${t}`;
48
+ }
49
+ function q(t, e) {
50
+ return P(g(), t, e);
51
+ }
52
+ var n, r, S, I, _, l, d;
53
+ class z {
54
+ constructor() {
55
+ h(this, r);
56
+ u(this, "name", "google-cast");
57
+ u(this, "target");
58
+ h(this, n);
59
+ }
60
+ /**
61
+ * @see {@link https://developers.google.com/cast/docs/reference/web_sender/cast.framework.CastContext}
62
+ */
63
+ get cast() {
64
+ return g();
65
+ }
66
+ mediaType() {
67
+ return "video";
68
+ }
69
+ canPlay(e) {
70
+ return O && !R && b(e);
71
+ }
72
+ async prompt(e) {
73
+ var m;
74
+ let a, o, i;
75
+ try {
76
+ a = await s(this, r, S).call(this, e), c(this, n) || (E(this, n, new cast.framework.RemotePlayer()), new cast.framework.RemotePlayerController(c(this, n))), o = e.player.createEvent("google-cast-prompt-open", {
77
+ trigger: a
78
+ }), e.player.dispatchEvent(o), s(this, r, l).call(this, e, "connecting", o), await s(this, r, I).call(this, D(e.$props.googleCast)), e.$state.remotePlaybackInfo.set({
79
+ deviceName: (m = y()) == null ? void 0 : m.getCastDevice().friendlyName
80
+ }), v() && s(this, r, l).call(this, e, "connected", o);
81
+ } catch (p) {
82
+ const f = p instanceof Error ? p : s(this, r, d).call(this, (p + "").toUpperCase(), "Prompt failed.");
83
+ throw i = e.player.createEvent("google-cast-prompt-error", {
84
+ detail: f,
85
+ trigger: o ?? a,
86
+ cancelable: !0
87
+ }), e.player.dispatch(i), s(this, r, l).call(this, e, v() ? "connected" : "disconnected", i), f;
88
+ } finally {
89
+ e.player.dispatch("google-cast-prompt-close", {
90
+ trigger: i ?? o ?? a
91
+ });
92
+ }
93
+ }
94
+ async load(e) {
95
+ if (G)
96
+ throw Error("[vidstack] can not load google cast provider server-side");
97
+ if (!c(this, n))
98
+ throw Error("[vidstack] google cast player was not initialized");
99
+ return new (await import("./vidstack-BFbyAy5g-DqVWIlTG.js")).GoogleCastProvider(c(this, n), e);
100
+ }
101
+ }
102
+ n = new WeakMap(), r = new WeakSet(), S = async function(e) {
103
+ if (N()) return;
104
+ const a = e.player.createEvent("google-cast-load-start");
105
+ e.player.dispatch(a), await L(M()), await customElements.whenDefined("google-cast-launcher");
106
+ const o = e.player.createEvent("google-cast-loaded", { trigger: a });
107
+ if (e.player.dispatch(o), !F())
108
+ throw s(this, r, d).call(this, "CAST_NOT_AVAILABLE", "Google Cast not available on this platform.");
109
+ return o;
110
+ }, I = async function(e) {
111
+ s(this, r, _).call(this, e);
112
+ const a = await this.cast.requestSession();
113
+ if (a)
114
+ throw s(this, r, d).call(this, a.toUpperCase(), j(a));
115
+ }, _ = function(e) {
116
+ var a;
117
+ (a = this.cast) == null || a.setOptions({
118
+ ...U(),
119
+ ...e
120
+ });
121
+ }, l = function(e, a, o) {
122
+ const i = { type: "google-cast", state: a };
123
+ e.notify("remote-playback-change", i, o);
124
+ }, d = function(e, a) {
125
+ const o = Error(a);
126
+ return o.code = e, o;
127
+ };
128
+ var B = /* @__PURE__ */ Object.freeze({
129
+ __proto__: null,
130
+ GoogleCastLoader: z
131
+ });
132
+ export {
133
+ g as getCastContext,
134
+ j as getCastErrorMessage,
135
+ y as getCastSession,
136
+ T as getCastSessionMedia,
137
+ J as hasActiveCastSession,
138
+ q as listenCastContextEvent,
139
+ B as loader
140
+ };