@instructure/studio-player 0.3.0 → 0.3.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './StudioPlayer/StudioPlayer';
2
2
  export * from './types';
3
3
  export * from './constants';
4
+ export { useMediaState, useMediaStore } from '@vidstack/react';
@@ -4,6 +4,7 @@ var N = (e, n, o) => Ue(e, typeof n != "symbol" ? n + "" : n, o);
4
4
  import { jsx as t, jsxs as a, Fragment as te } from "react/jsx-runtime";
5
5
  import { createContext as ne, useContext as oe, useState as P, useCallback as f, useEffect as H, useMemo as I, useRef as ie } from "react";
6
6
  import { useMediaPlayer as B, Spinner as J, useMediaRemote as Q, useMediaState as p, isTrackCaptionKind as qe, Track as Ge, Captions as We, usePlaybackRateOptions as je, useCaptionOptions as Qe, useVideoQualityOptions as Ye, useMediaStore as ge, Poster as Xe, FullscreenButton as Je, Time as ue, TimeSlider as z, VolumeSlider as q, MediaPlayer as et, MediaProvider as tt } from "@vidstack/react";
7
+ import { useMediaState as Vi, useMediaStore as Hi } from "@vidstack/react";
7
8
  import { initReactI18next as nt, useTranslation as C } from "react-i18next";
8
9
  import ot from "i18next";
9
10
  import it from "i18next-resources-to-backend";
@@ -84,7 +85,7 @@ function ut({
84
85
  };
85
86
  return /* @__PURE__ */ t(Pe.Provider, { value: b, children: v });
86
87
  }
87
- function E() {
88
+ function A() {
88
89
  const e = oe(Pe);
89
90
  if (!e)
90
91
  throw new Error(
@@ -103,7 +104,7 @@ const dt = "_annotation-overlay_1kxzn_1", mt = {
103
104
  };
104
105
  };
105
106
  function pt({ annotations: e }) {
106
- const n = B(), o = g(), i = E(), [s, c] = P(
107
+ const n = B(), o = g(), i = A(), [s, c] = P(
107
108
  null
108
109
  ), r = f(
109
110
  (m) => {
@@ -216,7 +217,7 @@ function xt({ captions: e }) {
216
217
  ) : null
217
218
  ] });
218
219
  }
219
- const R = [0.5, 0.75, 1, 1.25, 1.5, 2], Lt = [0.5, 1, 2, 3, 4], Se = 5, Nt = (e) => {
220
+ const V = [0.5, 0.75, 1, 1.25, 1.5, 2], Lt = [0.5, 1, 2, 3, 4], Se = 5, Nt = (e) => {
220
221
  const [, n] = P({});
221
222
  return I(() => {
222
223
  let o = [];
@@ -261,7 +262,7 @@ const R = [0.5, 0.75, 1, 1.25, 1.5, 2], Lt = [0.5, 1, 2, 3, 4], Se = 5, Nt = (e)
261
262
  i.clear();
262
263
  };
263
264
  }, [o, i, e]), i;
264
- }, It = "_comments-overlay_1puzm_1", St = "_comments-container_1puzm_10", Tt = "_comment_1puzm_1", Et = "_comment-text_1puzm_47", At = "_comment-author-avatar_1puzm_70", Rt = "_comment-author-name_1puzm_89", V = {
265
+ }, It = "_comments-overlay_1puzm_1", St = "_comments-container_1puzm_10", Tt = "_comment_1puzm_1", Et = "_comment-text_1puzm_47", At = "_comment-author-avatar_1puzm_70", Rt = "_comment-author-name_1puzm_89", E = {
265
266
  "comments-overlay": "_comments-overlay_1puzm_1",
266
267
  commentsOverlay: It,
267
268
  "comments-container": "_comments-container_1puzm_10",
@@ -275,20 +276,20 @@ const R = [0.5, 0.75, 1, 1.25, 1.5, 2], Lt = [0.5, 1, 2, 3, 4], Se = 5, Nt = (e)
275
276
  commentAuthorName: Rt
276
277
  };
277
278
  function Vt({ comment: e }) {
278
- return /* @__PURE__ */ a("div", { className: V.comment, onClick: () => {
279
+ return e.render ? e.render(e, E) : /* @__PURE__ */ a("div", { className: E.comment, onClick: () => {
279
280
  var n;
280
281
  return (n = e.onClick) == null ? void 0 : n.call(e, e);
281
282
  }, children: [
282
283
  /* @__PURE__ */ t(
283
284
  "img",
284
285
  {
285
- className: V.commentAuthorAvatar,
286
+ className: E.commentAuthorAvatar,
286
287
  src: e.user.avatar,
287
288
  alt: e.user.name
288
289
  }
289
290
  ),
290
- /* @__PURE__ */ t("span", { className: V.commentText, children: e.text }),
291
- /* @__PURE__ */ t("span", { className: V.commentAuthorName, children: e.user.name })
291
+ /* @__PURE__ */ t("span", { className: E.commentText, children: e.text }),
292
+ /* @__PURE__ */ t("span", { className: E.commentAuthorName, children: e.user.name })
292
293
  ] });
293
294
  }
294
295
  const Ht = 5;
@@ -297,15 +298,15 @@ function Bt({ comments: e }) {
297
298
  return e.length > 0 && n.state.commentsEnabled ? /* @__PURE__ */ t(
298
299
  "div",
299
300
  {
300
- className: V.commentsOverlay,
301
+ className: E.commentsOverlay,
301
302
  style: {
302
303
  flexDirection: n.state.captionPositionOnTop && i ? "column-reverse" : "column"
303
304
  },
304
- children: /* @__PURE__ */ t("div", { className: V.commentsContainer, children: i ? s.slice(-4) : s })
305
+ children: /* @__PURE__ */ t("div", { className: E.commentsContainer, children: i ? s.slice(-4) : s })
305
306
  }
306
307
  ) : null;
307
308
  }
308
- const Ot = "_root_1x28e_1", Ft = "_left-controls_1x28e_28", zt = "_right-controls_1x28e_34", Zt = "_indicators_1x28e_40", Kt = "_normal-timeline_1x28e_49", Dt = "_compact-timeline_1x28e_55", A = {
309
+ const Ot = "_root_1x28e_1", Ft = "_left-controls_1x28e_28", zt = "_right-controls_1x28e_34", Zt = "_indicators_1x28e_40", Kt = "_normal-timeline_1x28e_49", Dt = "_compact-timeline_1x28e_55", R = {
309
310
  root: Ot,
310
311
  "left-controls": "_left-controls_1x28e_28",
311
312
  leftControls: Ft,
@@ -325,15 +326,15 @@ function $t({
325
326
  const i = B();
326
327
  return H(() => {
327
328
  i && (i.remoteControl.pauseControls(), n && (n.current = i));
328
- }, [i, n]), /* @__PURE__ */ a("div", { "data-darkmode": e, className: A.root, children: [
329
- /* @__PURE__ */ t(pe, { className: A.normalTimeline }),
330
- /* @__PURE__ */ a("div", { className: A.leftControls, children: [
329
+ }, [i, n]), /* @__PURE__ */ a("div", { "data-darkmode": e, className: R.root, children: [
330
+ /* @__PURE__ */ t(pe, { className: R.normalTimeline }),
331
+ /* @__PURE__ */ a("div", { className: R.leftControls, children: [
331
332
  /* @__PURE__ */ t(fo, {}),
332
333
  /* @__PURE__ */ t(vi, {})
333
334
  ] }),
334
- /* @__PURE__ */ t("div", { className: A.indicators, children: /* @__PURE__ */ t(Io, {}) }),
335
- /* @__PURE__ */ t(pe, { className: A.compactTimeline }),
336
- /* @__PURE__ */ a("div", { className: A.rightControls, children: [
335
+ /* @__PURE__ */ t("div", { className: R.indicators, children: /* @__PURE__ */ t(Io, {}) }),
336
+ /* @__PURE__ */ t(pe, { className: R.compactTimeline }),
337
+ /* @__PURE__ */ a("div", { className: R.rightControls, children: [
337
338
  o && /* @__PURE__ */ t(yt, {}),
338
339
  /* @__PURE__ */ t(zn, {}),
339
340
  /* @__PURE__ */ t(no, {})
@@ -459,7 +460,7 @@ function se({
459
460
  }
460
461
  const dn = (e) => /* @__PURE__ */ t("svg", { width: 18, height: 18, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e, children: /* @__PURE__ */ t("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M1 0V12.7489H5.44V18L10.5007 12.7489H16.582V0H1ZM2 1H15.58V11.7339H9.98655L6.52667 15.25V11.7339H2V1ZM5.24963 5.35011H12.3323V4.24835H5.24963V5.35011ZM5.24963 8.18462H9.50067V7.08285H5.24963V8.18462Z", fill: "currentColor" }) });
461
462
  function mn() {
462
- const { t: e } = C(), n = E(), o = g();
463
+ const { t: e } = C(), n = A(), o = g();
463
464
  return !n.forceComments && n.hasComments ? /* @__PURE__ */ t(
464
465
  se,
465
466
  {
@@ -587,7 +588,7 @@ const Y = (e) => /* @__PURE__ */ t("svg", { width: 18, height: 18, viewBox: "0 0
587
588
  };
588
589
  function Pn() {
589
590
  const e = L(), n = je({
590
- rates: R,
591
+ rates: V,
591
592
  normalLabel: "1x"
592
593
  }), { t: o } = C(), i = O();
593
594
  return /* @__PURE__ */ a(
@@ -1045,7 +1046,7 @@ const Xn = (e) => /* @__PURE__ */ t("svg", { width: 24, height: 24, viewBox: "0
1045
1046
  fullScreenButton: eo
1046
1047
  };
1047
1048
  function no() {
1048
- const e = p("fullscreen"), n = B(), o = g(), i = E(), { t: s } = C();
1049
+ const e = p("fullscreen"), n = B(), o = g(), i = A(), { t: s } = C();
1049
1050
  return i.hideFullScreen ? null : /* @__PURE__ */ t(
1050
1051
  "button",
1051
1052
  {
@@ -1452,7 +1453,7 @@ function ai(e, n, o, i) {
1452
1453
  }
1453
1454
  }
1454
1455
  function ci() {
1455
- const e = Q(), n = p("duration"), o = E(), i = I(() => [
1456
+ const e = Q(), n = p("duration"), o = A(), i = I(() => [
1456
1457
  ...ii(
1457
1458
  o.annotations,
1458
1459
  o.onAnnotationClick
@@ -1462,7 +1463,7 @@ function ci() {
1462
1463
  return /* @__PURE__ */ t("div", { className: u.pins, children: i });
1463
1464
  }
1464
1465
  function ri() {
1465
- const e = p("duration"), n = E(), o = g();
1466
+ const e = p("duration"), n = A(), o = g();
1466
1467
  return n.hasComments && o.state.commentsEnabled ? /* @__PURE__ */ t("div", { className: u.commentMarkers, children: n.comments.map((i) => {
1467
1468
  const s = Math.min(
1468
1469
  Math.abs(e - i.timestamp),
@@ -1482,7 +1483,7 @@ function ri() {
1482
1483
  }) }) : null;
1483
1484
  }
1484
1485
  function li({ currentTime: e, position: n }) {
1485
- const [o, i] = P(!1), s = E(), c = f(() => s.interactiveMenuElements.length > 0 ? i((b) => !b) : s.onInteractivePinClick(e), [
1486
+ const [o, i] = P(!1), s = A(), c = f(() => s.interactiveMenuElements.length > 0 ? i((b) => !b) : s.onInteractivePinClick(e), [
1486
1487
  s.interactiveMenuElements,
1487
1488
  s.onInteractivePinClick,
1488
1489
  e
@@ -1614,7 +1615,7 @@ function di() {
1614
1615
  }
1615
1616
  const mi = `${u.progress} ${u.trackInner}`, hi = `${u.trackFill} ${u.trackInner}`;
1616
1617
  function pe({ className: e }) {
1617
- const n = g(), { hasAnnotations: o, hasQuizmarkers: i, interactive: s } = E(), c = e ? `${u.timelineWrapper} ${e}` : u.timelineWrapper;
1618
+ const n = g(), { hasAnnotations: o, hasQuizmarkers: i, interactive: s } = A(), c = e ? `${u.timelineWrapper} ${e}` : u.timelineWrapper;
1618
1619
  return /* @__PURE__ */ a("div", { className: c, children: [
1619
1620
  s ? /* @__PURE__ */ t(di, {}) : null,
1620
1621
  s || o || i ? /* @__PURE__ */ t(ci, {}) : null,
@@ -1711,8 +1712,8 @@ const _e = {
1711
1712
  decreasePlaybackRate: {
1712
1713
  keys: ["a"],
1713
1714
  onKeyUp({ event: e, player: n, remote: o }) {
1714
- const s = R.indexOf(n.playbackRate) - 1;
1715
- s >= 0 && (o.changePlaybackRate(R[s]), n.$state.lastKeyboardAction.set({
1715
+ const s = V.indexOf(n.playbackRate) - 1;
1716
+ s >= 0 && (o.changePlaybackRate(V[s]), n.$state.lastKeyboardAction.set({
1716
1717
  action: "decreasePlaybackRate",
1717
1718
  event: e
1718
1719
  }));
@@ -1721,8 +1722,8 @@ const _e = {
1721
1722
  increasePlaybackRate: {
1722
1723
  keys: ["d"],
1723
1724
  onKeyUp({ event: e, player: n, remote: o }) {
1724
- const s = R.indexOf(n.playbackRate) + 1;
1725
- s < R.length && (o.changePlaybackRate(R[s]), n.$state.lastKeyboardAction.set({
1725
+ const s = V.indexOf(n.playbackRate) + 1;
1726
+ s < V.length && (o.changePlaybackRate(V[s]), n.$state.lastKeyboardAction.set({
1726
1727
  action: "increasePlaybackRate",
1727
1728
  event: e
1728
1729
  }));
@@ -2045,6 +2046,8 @@ function Ei({
2045
2046
  export {
2046
2047
  Lt as CAPTION_FONT_SIZE_MULTIPLIERS,
2047
2048
  Se as COMMENT_DURATION,
2048
- R as PLAYBACK_RATES,
2049
- Ei as StudioPlayer
2049
+ V as PLAYBACK_RATES,
2050
+ Ei as StudioPlayer,
2051
+ Vi as useMediaState,
2052
+ Hi as useMediaStore
2050
2053
  };
package/dist/types.d.ts CHANGED
@@ -15,6 +15,7 @@ export type Comment = {
15
15
  avatar?: string;
16
16
  };
17
17
  onClick?: (comment: Comment) => void;
18
+ render?: (comment: Comment, styles: Record<string, string>) => React.ReactNode;
18
19
  };
19
20
  export type Annotation = {
20
21
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/studio-player",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "description": "Next generation media player for Instructure",
6
6
  "module": "./dist/studio-player.es.js",