@clipmux/player 0.1.0 → 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.
package/README.md CHANGED
@@ -38,6 +38,7 @@ The player resolves the video URL automatically from the `playbackId`.
38
38
  ```
39
39
 
40
40
  The `token` is appended to the playback URL as a query parameter for secure delivery.
41
+ When provided, the same token is also appended to `subtitles` and `poster` URLs (if set).
41
42
 
42
43
  ### Custom Source (Escape Hatch)
43
44
 
@@ -81,7 +82,7 @@ If you use your own CDN or proxy, pass `src` directly. Keep `playbackId` so anal
81
82
  | `playbackId` | `string` | — | ClipMux video ID. Resolves to the HLS URL automatically. |
82
83
  | `src` | `string` | — | Direct HLS/DASH URL. Overrides `playbackId` for playback. |
83
84
  | `envKey` | `string` | — | Tenant/environment key for multi-tenant analytics. |
84
- | `token` | `string` | — | Signed playback token for private content. |
85
+ | `token` | `string` | — | Signed playback token for private content (auto-appended to playback, subtitles, and poster URLs). |
85
86
  | `title` | `string` | — | Video title displayed in the player UI. |
86
87
  | `poster` | `string` | — | Poster/thumbnail image URL. |
87
88
  | `subtitles` | `string` | — | VTT subtitle file URL. |
package/dist/index.cjs CHANGED
@@ -20886,12 +20886,14 @@ styleInject('[data-media-player] {\n width: 100%;\n display: inline-flex;\n a
20886
20886
  styleInject(".clipmux-player[data-view-type=video] {\n aspect-ratio: 16 / 9;\n}\n.clipmux-player .vds-video-layout {\n --video-brand: hsl(0, 0%, 96%);\n}\n");
20887
20887
  var DEFAULT_ANALYTICS_URL = "https://api.clipmux.com/api/playback/journal";
20888
20888
  var CDN_BASE = "https://delivery.clipmux.com/videos";
20889
+ function withToken(url, token) {
20890
+ if (!token || /(?:\?|&)token=/.test(url) || url.startsWith("data:") || url.startsWith("blob:")) return url;
20891
+ const separator = url.includes("?") ? "&" : "?";
20892
+ return `${url}${separator}token=${encodeURIComponent(token)}`;
20893
+ }
20889
20894
  function resolveSourceUrl(props) {
20890
- let url = props.src || `${CDN_BASE}/${props.playbackId}/playlist.m3u8`;
20891
- if (props.token && !url.includes("token=")) {
20892
- url += `${url.includes("?") ? "&" : "?"}token=${props.token}`;
20893
- }
20894
- return url;
20895
+ const url = props.src || `${CDN_BASE}/${props.playbackId}/playlist.m3u8`;
20896
+ return withToken(url, props.token);
20895
20897
  }
20896
20898
  function chaptersToVttUrl(chapters) {
20897
20899
  let vtt = "WEBVTT\n\n";
@@ -21102,6 +21104,14 @@ function ClipMuxPlayer({
21102
21104
  if (!chapters || chapters.length === 0) return null;
21103
21105
  return chaptersToVttUrl(chapters);
21104
21106
  }, [chapters]);
21107
+ const posterSrc = React8__namespace.useMemo(() => {
21108
+ if (!poster) return void 0;
21109
+ return withToken(poster, token);
21110
+ }, [poster, token]);
21111
+ const subtitlesSrc = React8__namespace.useMemo(() => {
21112
+ if (!subtitles) return void 0;
21113
+ return withToken(subtitles, token);
21114
+ }, [subtitles, token]);
21105
21115
  const mergedStyle = React8__namespace.useMemo(() => {
21106
21116
  const vars = {};
21107
21117
  if (theme?.primaryColor) vars["--video-brand"] = theme.primaryColor;
@@ -21151,14 +21161,14 @@ function ClipMuxPlayer({
21151
21161
  Poster2,
21152
21162
  {
21153
21163
  className: "vds-poster absolute inset-0 block h-full w-full object-cover opacity-0 transition-opacity data-[visible]:opacity-100",
21154
- src: poster,
21164
+ src: posterSrc,
21155
21165
  alt: title || "Video poster"
21156
21166
  }
21157
21167
  ),
21158
- subtitles && /* @__PURE__ */ jsxRuntime.jsx(
21168
+ subtitlesSrc && /* @__PURE__ */ jsxRuntime.jsx(
21159
21169
  Track3,
21160
21170
  {
21161
- src: subtitles,
21171
+ src: subtitlesSrc,
21162
21172
  kind: "subtitles",
21163
21173
  label: "English",
21164
21174
  lang: "en",
@@ -21179,7 +21189,7 @@ function ClipMuxPlayer({
21179
21189
  /* @__PURE__ */ jsxRuntime.jsx(
21180
21190
  DefaultVideoLayout,
21181
21191
  {
21182
- thumbnails: poster,
21192
+ thumbnails: posterSrc,
21183
21193
  icons: defaultLayoutIcons,
21184
21194
  menuGroup: "bottom",
21185
21195
  smallLayoutWhen: ({ width }) => width < 520