@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 +2 -1
- package/dist/index.cjs +19 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/package.json +49 -49
package/dist/index.js
CHANGED
|
@@ -20864,12 +20864,14 @@ styleInject('[data-media-player] {\n width: 100%;\n display: inline-flex;\n a
|
|
|
20864
20864
|
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");
|
|
20865
20865
|
var DEFAULT_ANALYTICS_URL = "https://api.clipmux.com/api/playback/journal";
|
|
20866
20866
|
var CDN_BASE = "https://delivery.clipmux.com/videos";
|
|
20867
|
+
function withToken(url, token) {
|
|
20868
|
+
if (!token || /(?:\?|&)token=/.test(url) || url.startsWith("data:") || url.startsWith("blob:")) return url;
|
|
20869
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
20870
|
+
return `${url}${separator}token=${encodeURIComponent(token)}`;
|
|
20871
|
+
}
|
|
20867
20872
|
function resolveSourceUrl(props) {
|
|
20868
|
-
|
|
20869
|
-
|
|
20870
|
-
url += `${url.includes("?") ? "&" : "?"}token=${props.token}`;
|
|
20871
|
-
}
|
|
20872
|
-
return url;
|
|
20873
|
+
const url = props.src || `${CDN_BASE}/${props.playbackId}/playlist.m3u8`;
|
|
20874
|
+
return withToken(url, props.token);
|
|
20873
20875
|
}
|
|
20874
20876
|
function chaptersToVttUrl(chapters) {
|
|
20875
20877
|
let vtt = "WEBVTT\n\n";
|
|
@@ -21080,6 +21082,14 @@ function ClipMuxPlayer({
|
|
|
21080
21082
|
if (!chapters || chapters.length === 0) return null;
|
|
21081
21083
|
return chaptersToVttUrl(chapters);
|
|
21082
21084
|
}, [chapters]);
|
|
21085
|
+
const posterSrc = React8.useMemo(() => {
|
|
21086
|
+
if (!poster) return void 0;
|
|
21087
|
+
return withToken(poster, token);
|
|
21088
|
+
}, [poster, token]);
|
|
21089
|
+
const subtitlesSrc = React8.useMemo(() => {
|
|
21090
|
+
if (!subtitles) return void 0;
|
|
21091
|
+
return withToken(subtitles, token);
|
|
21092
|
+
}, [subtitles, token]);
|
|
21083
21093
|
const mergedStyle = React8.useMemo(() => {
|
|
21084
21094
|
const vars = {};
|
|
21085
21095
|
if (theme?.primaryColor) vars["--video-brand"] = theme.primaryColor;
|
|
@@ -21129,14 +21139,14 @@ function ClipMuxPlayer({
|
|
|
21129
21139
|
Poster2,
|
|
21130
21140
|
{
|
|
21131
21141
|
className: "vds-poster absolute inset-0 block h-full w-full object-cover opacity-0 transition-opacity data-[visible]:opacity-100",
|
|
21132
|
-
src:
|
|
21142
|
+
src: posterSrc,
|
|
21133
21143
|
alt: title || "Video poster"
|
|
21134
21144
|
}
|
|
21135
21145
|
),
|
|
21136
|
-
|
|
21146
|
+
subtitlesSrc && /* @__PURE__ */ jsx(
|
|
21137
21147
|
Track3,
|
|
21138
21148
|
{
|
|
21139
|
-
src:
|
|
21149
|
+
src: subtitlesSrc,
|
|
21140
21150
|
kind: "subtitles",
|
|
21141
21151
|
label: "English",
|
|
21142
21152
|
lang: "en",
|
|
@@ -21157,7 +21167,7 @@ function ClipMuxPlayer({
|
|
|
21157
21167
|
/* @__PURE__ */ jsx(
|
|
21158
21168
|
DefaultVideoLayout,
|
|
21159
21169
|
{
|
|
21160
|
-
thumbnails:
|
|
21170
|
+
thumbnails: posterSrc,
|
|
21161
21171
|
icons: defaultLayoutIcons,
|
|
21162
21172
|
menuGroup: "bottom",
|
|
21163
21173
|
smallLayoutWhen: ({ width }) => width < 520
|