@xiping/react-components 1.0.54 → 1.0.55
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/cjs/components/video-subtitle-player/VideoSubtitlePlayer.d.ts +1 -1
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.js +1 -1
- package/dist/cjs/react-components.css +1 -1
- package/dist/es/components/subtitle-player/LyricsMode.js +20 -9
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.d.ts +1 -1
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.js +98 -95
- package/dist/es/react-components.css +1 -1
- package/package.json +7 -7
|
@@ -1,125 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useEffect as u, useCallback as H } from "react";
|
|
3
3
|
import I from "xgplayer";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { PanelGroup as z, Panel as o, PanelResizeHandle as S } from "react-resizable-panels";
|
|
6
|
+
import { SubtitlePlayer as j } from "../subtitle-player/SubtitlePlayer.js";
|
|
7
|
+
import { useVideoSubtitleStore as D } from "./useVideoSubtitleStore.js";
|
|
7
8
|
/* empty css */
|
|
8
|
-
const
|
|
9
|
-
videoUrl:
|
|
10
|
-
subtitles:
|
|
11
|
-
poster:
|
|
12
|
-
className:
|
|
9
|
+
const q = ({
|
|
10
|
+
videoUrl: m,
|
|
11
|
+
subtitles: p,
|
|
12
|
+
poster: v,
|
|
13
|
+
className: P = "",
|
|
13
14
|
style: w,
|
|
14
|
-
onFetchDetail:
|
|
15
|
+
onFetchDetail: c
|
|
15
16
|
}) => {
|
|
16
|
-
const n =
|
|
17
|
+
const n = N(null), d = N(null), {
|
|
17
18
|
currentTime: r,
|
|
18
|
-
isPlaying:
|
|
19
|
-
setCurrentTime:
|
|
19
|
+
isPlaying: E,
|
|
20
|
+
setCurrentTime: _,
|
|
20
21
|
setIsPlaying: s,
|
|
21
|
-
setSubtitles:
|
|
22
|
+
setSubtitles: h,
|
|
22
23
|
currentDetail: l,
|
|
23
|
-
isLoadingDetail:
|
|
24
|
+
isLoadingDetail: T,
|
|
24
25
|
fetchDetail: y
|
|
25
|
-
} =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, [
|
|
26
|
+
} = D();
|
|
27
|
+
u(() => {
|
|
28
|
+
h(p);
|
|
29
|
+
}, [p, h]), u(() => {
|
|
29
30
|
if (!n.current) return;
|
|
30
|
-
const
|
|
31
|
-
n.current && (n.current.id =
|
|
31
|
+
const a = `xiping-video-subtitle-player-${Date.now()}`;
|
|
32
|
+
n.current && (n.current.id = a);
|
|
32
33
|
const i = new I({
|
|
33
|
-
id:
|
|
34
|
-
url:
|
|
35
|
-
poster:
|
|
34
|
+
id: a,
|
|
35
|
+
url: m,
|
|
36
|
+
poster: v,
|
|
36
37
|
autoplay: !1,
|
|
37
|
-
fluid: !
|
|
38
|
+
fluid: !1,
|
|
38
39
|
width: "100%",
|
|
39
40
|
height: "100%",
|
|
40
41
|
controls: !0
|
|
41
42
|
});
|
|
42
43
|
d.current = i;
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}, f = () => {
|
|
47
|
-
s(!0);
|
|
44
|
+
const f = () => {
|
|
45
|
+
const R = i.currentTime || 0;
|
|
46
|
+
_(R);
|
|
48
47
|
}, x = () => {
|
|
49
|
-
s(!
|
|
48
|
+
s(!0);
|
|
50
49
|
}, g = () => {
|
|
51
50
|
s(!1);
|
|
51
|
+
}, b = () => {
|
|
52
|
+
s(!1);
|
|
52
53
|
};
|
|
53
|
-
return i.on("timeupdate",
|
|
54
|
-
i.off("timeupdate",
|
|
54
|
+
return i.on("timeupdate", f), i.on("play", x), i.on("pause", g), i.on("ended", b), () => {
|
|
55
|
+
i.off("timeupdate", f), i.off("play", x), i.off("pause", g), i.off("ended", b), i.destroy(), d.current = null;
|
|
55
56
|
};
|
|
56
|
-
}, [
|
|
57
|
+
}, [m, v, _, s]), u(() => {
|
|
57
58
|
if (d.current) {
|
|
58
|
-
const
|
|
59
|
-
Math.abs(
|
|
59
|
+
const a = d.current;
|
|
60
|
+
Math.abs(a.currentTime - r) > 0.5 && (a.currentTime = r);
|
|
60
61
|
}
|
|
61
62
|
}, [r]);
|
|
62
|
-
const
|
|
63
|
-
async (
|
|
64
|
-
|
|
63
|
+
const C = H(
|
|
64
|
+
async (a) => {
|
|
65
|
+
c ? await c(a) : await y(a);
|
|
65
66
|
},
|
|
66
|
-
[
|
|
67
|
-
);
|
|
68
|
-
return /* @__PURE__ */ a(
|
|
69
|
-
"div",
|
|
70
|
-
{
|
|
71
|
-
className: `xiping-video-subtitle-player ${N}`,
|
|
72
|
-
style: w,
|
|
73
|
-
children: [
|
|
74
|
-
/* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__left", children: [
|
|
75
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__video-container", children: /* @__PURE__ */ e(
|
|
76
|
-
"div",
|
|
77
|
-
{
|
|
78
|
-
ref: n,
|
|
79
|
-
className: "xiping-video-subtitle-player__video"
|
|
80
|
-
}
|
|
81
|
-
) }),
|
|
82
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__subtitle-container", children: /* @__PURE__ */ e(
|
|
83
|
-
R,
|
|
84
|
-
{
|
|
85
|
-
subtitles: o,
|
|
86
|
-
currentTime: r,
|
|
87
|
-
mode: "current",
|
|
88
|
-
onWordHoverChange: S
|
|
89
|
-
}
|
|
90
|
-
) })
|
|
91
|
-
] }),
|
|
92
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__right", children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail", children: P ? /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-loading", children: [
|
|
93
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-loading-spinner" }),
|
|
94
|
-
/* @__PURE__ */ e("span", { children: "加载中..." })
|
|
95
|
-
] }) : l ? /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-content", children: [
|
|
96
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-word", children: l.word }),
|
|
97
|
-
l.pronunciation && /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-pronunciation", children: l.pronunciation }),
|
|
98
|
-
l.partOfSpeech && /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-pos", children: l.partOfSpeech }),
|
|
99
|
-
l.translation && /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-translation", children: [
|
|
100
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "中文翻译" }),
|
|
101
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-text", children: l.translation })
|
|
102
|
-
] }),
|
|
103
|
-
l.definition && /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-definition", children: [
|
|
104
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "英文解释" }),
|
|
105
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-text", children: l.definition })
|
|
106
|
-
] }),
|
|
107
|
-
l.examples && l.examples.length > 0 && /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-examples", children: [
|
|
108
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "例句" }),
|
|
109
|
-
l.examples.map((t, i) => /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-example", children: [
|
|
110
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-example-en", children: t.sentence }),
|
|
111
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-example-zh", children: t.translation })
|
|
112
|
-
] }, i))
|
|
113
|
-
] })
|
|
114
|
-
] }) : /* @__PURE__ */ a("div", { className: "xiping-video-subtitle-player__detail-empty", children: [
|
|
115
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-empty-icon", children: "📖" }),
|
|
116
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-empty-text", children: "将鼠标悬停在字幕单词上查看详情" })
|
|
117
|
-
] }) }) })
|
|
118
|
-
]
|
|
119
|
-
}
|
|
67
|
+
[c, y]
|
|
120
68
|
);
|
|
69
|
+
return /* @__PURE__ */ e("div", { className: `xiping-video-subtitle-player ${P}`, style: w, children: /* @__PURE__ */ t(z, { direction: "horizontal", children: [
|
|
70
|
+
/* @__PURE__ */ e(o, { defaultSize: 65, minSize: 40, children: /* @__PURE__ */ t(z, { direction: "vertical", children: [
|
|
71
|
+
/* @__PURE__ */ e(o, { defaultSize: 60, minSize: 30, children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__video-wrapper", children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__video-container", children: /* @__PURE__ */ e(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
ref: n,
|
|
75
|
+
className: "xiping-video-subtitle-player__video"
|
|
76
|
+
}
|
|
77
|
+
) }) }) }),
|
|
78
|
+
/* @__PURE__ */ e(S, { className: "xiping-video-subtitle-player__resize-handle xiping-video-subtitle-player__resize-handle--vertical" }),
|
|
79
|
+
/* @__PURE__ */ e(o, { defaultSize: 40, minSize: 20, children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__subtitle-container", children: /* @__PURE__ */ e(
|
|
80
|
+
j,
|
|
81
|
+
{
|
|
82
|
+
subtitles: p,
|
|
83
|
+
currentTime: r,
|
|
84
|
+
mode: "current",
|
|
85
|
+
onWordHoverChange: C
|
|
86
|
+
}
|
|
87
|
+
) }) })
|
|
88
|
+
] }) }),
|
|
89
|
+
/* @__PURE__ */ e(S, { className: "xiping-video-subtitle-player__resize-handle xiping-video-subtitle-player__resize-handle--horizontal" }),
|
|
90
|
+
/* @__PURE__ */ e(o, { defaultSize: 35, minSize: 25, maxSize: 50, children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__right", children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail", children: T ? /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-loading", children: [
|
|
91
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-loading-spinner" }),
|
|
92
|
+
/* @__PURE__ */ e("span", { children: "加载中..." })
|
|
93
|
+
] }) : l ? /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-content", children: [
|
|
94
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-word", children: l.word }),
|
|
95
|
+
l.pronunciation && /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-pronunciation", children: l.pronunciation }),
|
|
96
|
+
l.partOfSpeech && /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-pos", children: l.partOfSpeech }),
|
|
97
|
+
l.translation && /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-translation", children: [
|
|
98
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "中文翻译" }),
|
|
99
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-text", children: l.translation })
|
|
100
|
+
] }),
|
|
101
|
+
l.definition && /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-definition", children: [
|
|
102
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "英文解释" }),
|
|
103
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-text", children: l.definition })
|
|
104
|
+
] }),
|
|
105
|
+
l.examples && l.examples.length > 0 && /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-examples", children: [
|
|
106
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "例句" }),
|
|
107
|
+
l.examples.map((a, i) => /* @__PURE__ */ t(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: "xiping-video-subtitle-player__detail-example",
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-example-en", children: a.sentence }),
|
|
113
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-example-zh", children: a.translation })
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
i
|
|
117
|
+
))
|
|
118
|
+
] })
|
|
119
|
+
] }) : /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-empty", children: [
|
|
120
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-empty-icon", children: "📖" }),
|
|
121
|
+
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-empty-text", children: "将鼠标悬停在字幕单词上查看详情" })
|
|
122
|
+
] }) }) }) })
|
|
123
|
+
] }) });
|
|
121
124
|
};
|
|
122
125
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
q as VideoSubtitlePlayer,
|
|
127
|
+
q as default
|
|
125
128
|
};
|