@banou/media-player 0.10.32 → 0.10.34
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 +8 -1
- package/dist/ar-CS4Yzfxw.js +52 -0
- package/dist/he-DbFw1CdO.js +52 -0
- package/dist/index.js +265 -252
- package/dist/react/components/chrome.d.ts +3 -1
- package/dist/react/components/skip-chapter.d.ts +5 -1
- package/dist/remote/index.d.ts +17 -4
- package/dist/remote/index.js +17 -5
- package/dist/remote/protocol.d.ts +4 -2
- package/package.json +1 -1
- package/src/lib/locales/ar.json +49 -0
- package/src/lib/locales/he.json +49 -0
- package/src/lib/react/components/chrome.tsx +4 -2
- package/src/lib/react/components/overlay.tsx +2 -1
- package/src/lib/react/components/skip-chapter.tsx +8 -2
- package/src/lib/react/components/tooltip-display.tsx +3 -1
- package/src/lib/react/components/track-menu.tsx +1 -1
- package/src/lib/react/labels.tsx +2 -0
- package/src/lib/react/video-player.tsx +12 -3
- package/src/lib/remote/index.ts +29 -6
- package/src/lib/remote/protocol.ts +6 -3
|
@@ -12,7 +12,9 @@ export type ChromeProps = {
|
|
|
12
12
|
shortcuts?: 'window' | 'player';
|
|
13
13
|
/** Fullscreen kept by the host: a press calls its `request` instead of fullscreening the player. */
|
|
14
14
|
fullscreen?: HostFullscreen;
|
|
15
|
+
/** False leaves the last ending out of the skip offer. */
|
|
16
|
+
endingOffered: boolean;
|
|
15
17
|
children?: ReactNode;
|
|
16
18
|
};
|
|
17
|
-
export declare const Chrome: ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shortcuts, fullscreen, children }: ChromeProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const Chrome: ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shortcuts, fullscreen, endingOffered, children }: ChromeProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
20
|
export default Chrome;
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* of the pair: the classifier reads titles written by whoever muxed the file, so it is sometimes
|
|
6
6
|
* going to be wrong. Making the offer expire, and never acting on its own, is what makes being wrong
|
|
7
7
|
* cheap. See the classifier for what it matches and the sample it was measured against.
|
|
8
|
+
*
|
|
9
|
+
* `endingOffered` false leaves the last ending out, for an embedder that fills this corner itself.
|
|
8
10
|
*/
|
|
9
|
-
export declare const SkipChapter: (
|
|
11
|
+
export declare const SkipChapter: ({ endingOffered }: {
|
|
12
|
+
endingOffered: boolean;
|
|
13
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
10
14
|
export default SkipChapter;
|
package/dist/remote/index.d.ts
CHANGED
|
@@ -46,14 +46,17 @@ export type ExposePlayerOptions = {
|
|
|
46
46
|
player?: ServedPlayer;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
-
* The player around a served media, as `<MediaPlayer expose>` passes it: its chapters
|
|
50
|
-
* announced on its `chapterschange`, and its fullscreen, which a mirror made
|
|
51
|
-
* one has it, `onHostFullscreen` is told the state that mirror sets, and null
|
|
52
|
-
* dispatches `fullscreenrequest` for each press of its fullscreen, which reaches the
|
|
49
|
+
* The player around a served media, as `<MediaPlayer expose>` passes it: its chapters and whether it offers to skip its
|
|
50
|
+
* last ending, sent with every snapshot and announced on its `chapterschange`, and its fullscreen, which a mirror made
|
|
51
|
+
* with `fullscreen: true` takes over. While one has it, `onHostFullscreen` is told the state that mirror sets, and null
|
|
52
|
+
* once none has it; the player then dispatches `fullscreenrequest` for each press of its fullscreen, which reaches the
|
|
53
|
+
* mirror. `onEndingOffered` is told what a mirror sets on `endingOffered`.
|
|
53
54
|
*/
|
|
54
55
|
export type ServedPlayer = EventTarget & {
|
|
55
56
|
readonly chapters: MediaChapter[];
|
|
57
|
+
readonly endingOffered: boolean;
|
|
56
58
|
onHostFullscreen: (active: boolean | null) => void;
|
|
59
|
+
onEndingOffered: (offered: boolean) => void;
|
|
57
60
|
};
|
|
58
61
|
/**
|
|
59
62
|
* Serve `media` to this document's embedder. Returns the teardown for THIS media.
|
|
@@ -92,6 +95,16 @@ export type MediaPlayerHandle = {
|
|
|
92
95
|
* shortcuts follow it. Set it on every change. Without the option it stays here.
|
|
93
96
|
*/
|
|
94
97
|
fullscreen: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the far `<MediaPlayer expose>` offers to skip its last ending, as it last said. Set it to false to have
|
|
100
|
+
* that offer taken away, for a page with something of its own in that corner, and to true to have it back; a
|
|
101
|
+
* mirror's `destroy()` leaves it as it is, and a new player starts out offering.
|
|
102
|
+
*
|
|
103
|
+
* Unlike every other write here this one does NOT move the mirror: a read answers what the far player reports,
|
|
104
|
+
* from after its render, with a `chapterschange` event following each change. So a false here means the offer is
|
|
105
|
+
* off the far screen, and a player that cannot take it (a bare element, a version older than this) stays true.
|
|
106
|
+
*/
|
|
107
|
+
endingOffered: boolean;
|
|
95
108
|
/**
|
|
96
109
|
* Settles once the far side has first answered with its state; reads before that answer the
|
|
97
110
|
* empty defaults. Stays pending for as long as nobody answers, and rejects with an AbortError on
|
package/dist/remote/index.js
CHANGED
|
@@ -49,7 +49,7 @@ var t = [
|
|
|
49
49
|
let t = [];
|
|
50
50
|
for (let n = 0; n < e.length; n++) t.push([e.start(n), e.end(n)]);
|
|
51
51
|
return t;
|
|
52
|
-
}, l = (e, t = []) => ({
|
|
52
|
+
}, l = (e, t = [], n = !0) => ({
|
|
53
53
|
currentTime: u(e.currentTime),
|
|
54
54
|
duration: u(e.duration),
|
|
55
55
|
paused: e.paused,
|
|
@@ -69,7 +69,8 @@ var t = [
|
|
|
69
69
|
} : null,
|
|
70
70
|
videoWidth: e.videoWidth ?? 0,
|
|
71
71
|
videoHeight: e.videoHeight ?? 0,
|
|
72
|
-
chapters: t
|
|
72
|
+
chapters: t,
|
|
73
|
+
endingOffered: n
|
|
73
74
|
}), u = (e) => Number.isNaN(e) ? 0 : e, d = {
|
|
74
75
|
currentTime: 0,
|
|
75
76
|
duration: 0,
|
|
@@ -87,7 +88,8 @@ var t = [
|
|
|
87
88
|
error: null,
|
|
88
89
|
videoWidth: 0,
|
|
89
90
|
videoHeight: 0,
|
|
90
|
-
chapters: []
|
|
91
|
+
chapters: [],
|
|
92
|
+
endingOffered: !0
|
|
91
93
|
}, f = (e) => ({
|
|
92
94
|
length: e.length,
|
|
93
95
|
start: (t) => e[t]?.[0] ?? 0,
|
|
@@ -111,8 +113,8 @@ var t = [
|
|
|
111
113
|
T(e, r);
|
|
112
114
|
}
|
|
113
115
|
}, D = (e) => {
|
|
114
|
-
let t = m.get(e);
|
|
115
|
-
return t ? l(t,
|
|
116
|
+
let t = m.get(e), n = h.get(e);
|
|
117
|
+
return t ? l(t, n?.chapters, n?.endingOffered) : void 0;
|
|
116
118
|
}, O = (e, t) => {
|
|
117
119
|
let n = t === "fullscreenrequest" ? S.get(e) : v.get(e);
|
|
118
120
|
if (!n?.size) return;
|
|
@@ -143,6 +145,10 @@ var t = [
|
|
|
143
145
|
C.set(e, n), w(e);
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
148
|
+
if (t === "endingOffered") {
|
|
149
|
+
typeof n == "boolean" && h.get(e)?.onEndingOffered(n);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
146
152
|
let i = m.get(e);
|
|
147
153
|
if (i && r.includes(t)) try {
|
|
148
154
|
i[t] = n;
|
|
@@ -315,6 +321,12 @@ var t = [
|
|
|
315
321
|
S = !!e, t.fullscreen && O(() => k.set(a, "fullscreen", S));
|
|
316
322
|
},
|
|
317
323
|
enumerable: !0
|
|
324
|
+
}), Object.defineProperty(c, "endingOffered", {
|
|
325
|
+
get: () => o.endingOffered,
|
|
326
|
+
set: (e) => {
|
|
327
|
+
O(() => k.set(a, "endingOffered", e));
|
|
328
|
+
},
|
|
329
|
+
enumerable: !0
|
|
318
330
|
});
|
|
319
331
|
let A = (e) => g.then(() => {
|
|
320
332
|
if (i.aborted) throw _();
|
|
@@ -30,6 +30,8 @@ export type PlayerSnapshot = {
|
|
|
30
30
|
videoHeight: number;
|
|
31
31
|
/** A `<MediaPlayer expose>`'s chapters, empty for a bare element. */
|
|
32
32
|
chapters: MediaChapter[];
|
|
33
|
+
/** Whether a `<MediaPlayer expose>` offers to skip its last ending. Set after its render, so false means the offer is off the screen. */
|
|
34
|
+
endingOffered: boolean;
|
|
33
35
|
};
|
|
34
36
|
/**
|
|
35
37
|
* The events a player raises that an embedder can hear, each carrying a fresh snapshot.
|
|
@@ -86,7 +88,7 @@ export type PlayerService = {
|
|
|
86
88
|
fullscreen?: boolean;
|
|
87
89
|
}) => void;
|
|
88
90
|
/** `fullscreen` is the state shown by a player whose fullscreen a mirror has taken over, and is ignored otherwise. */
|
|
89
|
-
set: (id: string, name: Writable | 'fullscreen', value: number | boolean) => void;
|
|
91
|
+
set: (id: string, name: Writable | 'fullscreen' | 'endingOffered', value: number | boolean) => void;
|
|
90
92
|
call: (id: string, name: Callable) => Promise<void>;
|
|
91
93
|
};
|
|
92
94
|
/**
|
|
@@ -96,7 +98,7 @@ export type PlayerService = {
|
|
|
96
98
|
*/
|
|
97
99
|
export declare const syncEventsFor: (snapshot: PlayerSnapshot) => PlayerEvent[];
|
|
98
100
|
/** A media as a snapshot. A NaN duration, which a bare element answers before it has metadata, is sent as 0. */
|
|
99
|
-
export declare const snapshotOf: (media: PlayerMedia, chapters?: MediaChapter[]) => PlayerSnapshot;
|
|
101
|
+
export declare const snapshotOf: (media: PlayerMedia, chapters?: MediaChapter[], endingOffered?: boolean) => PlayerSnapshot;
|
|
100
102
|
/** The snapshot an embedder holds before the player's document has said anything. */
|
|
101
103
|
export declare const EMPTY_SNAPSHOT: PlayerSnapshot;
|
|
102
104
|
/** Plain pairs back into the structural `TimeRanges` the player reads. */
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"(Default)": "(عادية)",
|
|
3
|
+
"Audio": "الصوت",
|
|
4
|
+
"Copied": "تم النسخ",
|
|
5
|
+
"Copy": "نسخ",
|
|
6
|
+
"Copy the errors": "نسخ الأخطاء",
|
|
7
|
+
"Could not switch. Try again.": "تعذّر التبديل. حاول مرة أخرى.",
|
|
8
|
+
"Disable": "إيقاف",
|
|
9
|
+
"Exit full screen (f)": "الخروج من ملء الشاشة (f)",
|
|
10
|
+
"Exit picture in picture": "الخروج من صورة داخل صورة",
|
|
11
|
+
"Full screen": "ملء الشاشة",
|
|
12
|
+
"Full screen (f)": "ملء الشاشة (f)",
|
|
13
|
+
"Mute": "كتم الصوت",
|
|
14
|
+
"Mute (m)": "كتم الصوت (m)",
|
|
15
|
+
"Normalize volume": "موازنة مستوى الصوت",
|
|
16
|
+
"Now click your browser's pop out button": "انقر الآن على زر النافذة المنبثقة في متصفحك",
|
|
17
|
+
"Pause": "إيقاف مؤقت",
|
|
18
|
+
"Pause (k)": "إيقاف مؤقت (k)",
|
|
19
|
+
"Picture in picture": "صورة داخل صورة",
|
|
20
|
+
"Play": "تشغيل",
|
|
21
|
+
"Play (k)": "تشغيل (k)",
|
|
22
|
+
"Playback errors ({count})": "أخطاء التشغيل ({count})",
|
|
23
|
+
"Playback failed": "فشل التشغيل",
|
|
24
|
+
"Playback speed": "سرعة التشغيل",
|
|
25
|
+
"Put the subtitles in the picture": "دمج الترجمة في الصورة",
|
|
26
|
+
"Put the subtitles in the video": "دمج الترجمة في الفيديو",
|
|
27
|
+
"Quality": "الجودة",
|
|
28
|
+
"Reading the video file failed": "فشلت قراءة ملف الفيديو",
|
|
29
|
+
"Replay": "إعادة التشغيل",
|
|
30
|
+
"Replay (k)": "إعادة التشغيل (k)",
|
|
31
|
+
"Settings": "الإعدادات",
|
|
32
|
+
"Skip Ending": "تخطي النهاية",
|
|
33
|
+
"Skip Opening": "تخطي المقدمة",
|
|
34
|
+
"Subtitles": "الترجمة",
|
|
35
|
+
"Subtitles are in the picture": "الترجمة مدمجة في الصورة",
|
|
36
|
+
"The MediaSource closed before a SourceBuffer could be created": "أُغلق MediaSource قبل إنشاء SourceBuffer",
|
|
37
|
+
"The MediaSource never opened": "لم يُفتح MediaSource",
|
|
38
|
+
"The browser rejected a media segment": "رفض المتصفح مقطعًا من الوسائط",
|
|
39
|
+
"The video codec in this file could not be identified": "تعذّر التعرف على ترميز الفيديو في هذا الملف",
|
|
40
|
+
"This browser cannot play the codecs in this file: {codecs}": "لا يمكن لهذا المتصفح تشغيل الترميزات في هذا الملف: {codecs}",
|
|
41
|
+
"This file has no subtitles": "لا توجد ترجمة في هذا الملف",
|
|
42
|
+
"Track {number}": "المقطع {number}",
|
|
43
|
+
"Unavailable": "غير متاح",
|
|
44
|
+
"Unmute (m)": "إلغاء كتم الصوت (m)",
|
|
45
|
+
"at {time}": "عند {time}",
|
|
46
|
+
"recovered": "استُؤنف التشغيل",
|
|
47
|
+
"{rate}x": "{rate}x",
|
|
48
|
+
"{start} to {end}": "من {start} إلى {end}"
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"(Default)": "(רגילה)",
|
|
3
|
+
"Audio": "שמע",
|
|
4
|
+
"Copied": "הועתק",
|
|
5
|
+
"Copy": "העתקה",
|
|
6
|
+
"Copy the errors": "העתקת השגיאות",
|
|
7
|
+
"Could not switch. Try again.": "ההחלפה נכשלה. נסו שוב.",
|
|
8
|
+
"Disable": "כבוי",
|
|
9
|
+
"Exit full screen (f)": "יציאה ממסך מלא (f)",
|
|
10
|
+
"Exit picture in picture": "יציאה מתמונה בתוך תמונה",
|
|
11
|
+
"Full screen": "מסך מלא",
|
|
12
|
+
"Full screen (f)": "מסך מלא (f)",
|
|
13
|
+
"Mute": "השתקה",
|
|
14
|
+
"Mute (m)": "השתקה (m)",
|
|
15
|
+
"Normalize volume": "איזון עוצמת הקול",
|
|
16
|
+
"Now click your browser's pop out button": "עכשיו לחצו על לחצן החלון הצף בדפדפן",
|
|
17
|
+
"Pause": "השהיה",
|
|
18
|
+
"Pause (k)": "השהיה (k)",
|
|
19
|
+
"Picture in picture": "תמונה בתוך תמונה",
|
|
20
|
+
"Play": "הפעלה",
|
|
21
|
+
"Play (k)": "הפעלה (k)",
|
|
22
|
+
"Playback errors ({count})": "שגיאות הפעלה ({count})",
|
|
23
|
+
"Playback failed": "ההפעלה נכשלה",
|
|
24
|
+
"Playback speed": "מהירות הפעלה",
|
|
25
|
+
"Put the subtitles in the picture": "הטמעת הכתוביות בתמונה",
|
|
26
|
+
"Put the subtitles in the video": "הטמעת הכתוביות בסרטון",
|
|
27
|
+
"Quality": "איכות",
|
|
28
|
+
"Reading the video file failed": "קריאת קובץ הווידאו נכשלה",
|
|
29
|
+
"Replay": "הפעלה מחדש",
|
|
30
|
+
"Replay (k)": "הפעלה מחדש (k)",
|
|
31
|
+
"Settings": "הגדרות",
|
|
32
|
+
"Skip Ending": "דילוג על הסיום",
|
|
33
|
+
"Skip Opening": "דילוג על הפתיח",
|
|
34
|
+
"Subtitles": "כתוביות",
|
|
35
|
+
"Subtitles are in the picture": "הכתוביות מוטמעות בתמונה",
|
|
36
|
+
"The MediaSource closed before a SourceBuffer could be created": "ה-MediaSource נסגר לפני שנוצר SourceBuffer",
|
|
37
|
+
"The MediaSource never opened": "ה-MediaSource לא נפתח",
|
|
38
|
+
"The browser rejected a media segment": "הדפדפן דחה מקטע מדיה",
|
|
39
|
+
"The video codec in this file could not be identified": "לא ניתן לזהות את קודק הווידאו בקובץ הזה",
|
|
40
|
+
"This browser cannot play the codecs in this file: {codecs}": "הדפדפן הזה לא יכול להפעיל את הקודקים בקובץ: {codecs}",
|
|
41
|
+
"This file has no subtitles": "בקובץ הזה אין כתוביות",
|
|
42
|
+
"Track {number}": "רצועה {number}",
|
|
43
|
+
"Unavailable": "לא זמין",
|
|
44
|
+
"Unmute (m)": "ביטול השתקה (m)",
|
|
45
|
+
"at {time}": "ב-{time}",
|
|
46
|
+
"recovered": "ההפעלה התאוששה",
|
|
47
|
+
"{rate}x": "{rate}x",
|
|
48
|
+
"{start} to {end}": "מ-{start} עד {end}"
|
|
49
|
+
}
|
|
@@ -137,10 +137,12 @@ export type ChromeProps = {
|
|
|
137
137
|
shortcuts?: 'window' | 'player'
|
|
138
138
|
/** Fullscreen kept by the host: a press calls its `request` instead of fullscreening the player. */
|
|
139
139
|
fullscreen?: HostFullscreen
|
|
140
|
+
/** False leaves the last ending out of the skip offer. */
|
|
141
|
+
endingOffered: boolean
|
|
140
142
|
children?: ReactNode
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
export const Chrome = ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shortcuts, fullscreen, children }: ChromeProps) => {
|
|
145
|
+
export const Chrome = ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shortcuts, fullscreen, endingOffered, children }: ChromeProps) => {
|
|
144
146
|
const player = usePlayer()
|
|
145
147
|
const hideUI = usePlayer((state) => state.hideUI)
|
|
146
148
|
const setHideUI = usePlayer((state) => state.setHideUI)
|
|
@@ -327,7 +329,7 @@ export const Chrome = ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shor
|
|
|
327
329
|
)}
|
|
328
330
|
{/* Not tied to `hideUI`: it says what to do next, and it is on screen for nine seconds. */}
|
|
329
331
|
<BurnInHint />
|
|
330
|
-
<SkipChapter />
|
|
332
|
+
<SkipChapter endingOffered={endingOffered} />
|
|
331
333
|
{passThrough?.armed && root.current
|
|
332
334
|
? (
|
|
333
335
|
<div
|
|
@@ -138,6 +138,7 @@ export const Overlay = ({ onSubtitleRef }: { onSubtitleRef: (element: HTMLDivEle
|
|
|
138
138
|
? (
|
|
139
139
|
<div
|
|
140
140
|
className="title"
|
|
141
|
+
dir="auto"
|
|
141
142
|
css={titleStyle}
|
|
142
143
|
style={{ ...hideUI ? { opacity: '0', pointerEvents: 'none' } : {} }}
|
|
143
144
|
>
|
|
@@ -153,7 +154,7 @@ export const Overlay = ({ onSubtitleRef }: { onSubtitleRef: (element: HTMLDivEle
|
|
|
153
154
|
? <div css={loadingStyle} />
|
|
154
155
|
: undefined}
|
|
155
156
|
{playbackError
|
|
156
|
-
? <div css={errorStyle}>{errorMessage(playbackError, labels)}</div>
|
|
157
|
+
? <div css={errorStyle} dir="auto">{errorMessage(playbackError, labels)}</div>
|
|
157
158
|
: undefined}
|
|
158
159
|
<div className="subtitles" ref={onSubtitleRef} css={style} />
|
|
159
160
|
</>
|
|
@@ -90,8 +90,10 @@ const style = css`
|
|
|
90
90
|
* of the pair: the classifier reads titles written by whoever muxed the file, so it is sometimes
|
|
91
91
|
* going to be wrong. Making the offer expire, and never acting on its own, is what makes being wrong
|
|
92
92
|
* cheap. See the classifier for what it matches and the sample it was measured against.
|
|
93
|
+
*
|
|
94
|
+
* `endingOffered` false leaves the last ending out, for an embedder that fills this corner itself.
|
|
93
95
|
*/
|
|
94
|
-
export const SkipChapter = () => {
|
|
96
|
+
export const SkipChapter = ({ endingOffered }: { endingOffered: boolean }) => {
|
|
95
97
|
const chapters = usePlayer((state) => state.chapters)
|
|
96
98
|
const currentTime = usePlayer((state) => state.currentTime)
|
|
97
99
|
const requestSeek = usePlayer((state) => state.requestSeek)
|
|
@@ -104,7 +106,11 @@ export const SkipChapter = () => {
|
|
|
104
106
|
const player = usePlayer()
|
|
105
107
|
const { format } = useLabels()
|
|
106
108
|
|
|
107
|
-
const kinds = useMemo(() =>
|
|
109
|
+
const kinds = useMemo(() => {
|
|
110
|
+
const all = classifyChapters(chapters)
|
|
111
|
+
const left = endingOffered ? -1 : all.lastIndexOf('ending')
|
|
112
|
+
return all.map((kind, index) => index === left ? undefined : kind)
|
|
113
|
+
}, [chapters, endingOffered])
|
|
108
114
|
|
|
109
115
|
/**
|
|
110
116
|
* The chapter worth offering to skip, from a second before it starts until it ends.
|
|
@@ -29,7 +29,7 @@ const style = (size: buttonSize) => css`
|
|
|
29
29
|
max-width: min(calc(26 * var(--mp-unit)), calc(100vw - calc(2.4 * var(--mp-unit))));
|
|
30
30
|
white-space: normal;
|
|
31
31
|
overflow-wrap: anywhere;
|
|
32
|
-
text-align:
|
|
32
|
+
text-align: start;
|
|
33
33
|
|
|
34
34
|
/*
|
|
35
35
|
* The radius carries !important for the same reason the paddings below do.
|
|
@@ -46,6 +46,8 @@ const style = (size: buttonSize) => css`
|
|
|
46
46
|
|
|
47
47
|
* {
|
|
48
48
|
${fonts.bMedium.regular}
|
|
49
|
+
/* a label reads in its own direction, though the player around it stays left to right */
|
|
50
|
+
unicode-bidi: plaintext;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
${size === buttonSize.sm && css`
|
|
@@ -194,7 +194,7 @@ export const TrackMenu = (
|
|
|
194
194
|
{onBack ? <ChevronLeft /> : null}
|
|
195
195
|
<span>{title}</span>
|
|
196
196
|
</div>
|
|
197
|
-
{failed ? <div className="no-hover failed">{format(LABELS.switchFailed)}</div> : null}
|
|
197
|
+
{failed ? <div className="no-hover failed" dir="auto">{format(LABELS.switchFailed)}</div> : null}
|
|
198
198
|
{offLabel ? row(null, offLabel) : null}
|
|
199
199
|
{tracks.map(({ id, label }) => row(id, label, 'description'))}
|
|
200
200
|
</div>
|
package/src/lib/react/labels.tsx
CHANGED
|
@@ -10,9 +10,11 @@ type Catalogue = Readonly<Record<string, string>>
|
|
|
10
10
|
|
|
11
11
|
// One chunk per language, fetched with FormatJS by the first player shown in it, so a player in English loads neither.
|
|
12
12
|
const CATALOGUES: Readonly<Record<string, () => Promise<{ default: Catalogue }>>> = {
|
|
13
|
+
'ar': () => import('../locales/ar.json'),
|
|
13
14
|
'de': () => import('../locales/de.json'),
|
|
14
15
|
'es-419': () => import('../locales/es-419.json'),
|
|
15
16
|
'fr': () => import('../locales/fr.json'),
|
|
17
|
+
'he': () => import('../locales/he.json'),
|
|
16
18
|
'it': () => import('../locales/it.json'),
|
|
17
19
|
'ja': () => import('../locales/ja.json'),
|
|
18
20
|
'ko': () => import('../locales/ko.json'),
|
|
@@ -367,8 +367,14 @@ const PlayerRoot = ({ options, children }: { options: MediaPlayerOptions, childr
|
|
|
367
367
|
// What `expose` serves beside the media, the same object for the player's life. Its `onHostFullscreen` is how a
|
|
368
368
|
// mirror made with `fullscreen: true` takes the fullscreen over.
|
|
369
369
|
const [embedderFullscreen, setEmbedderFullscreen] = useState<boolean | null>(null)
|
|
370
|
-
const [
|
|
371
|
-
|
|
370
|
+
const [endingOffered, setEndingOffered] = useState(true)
|
|
371
|
+
const [served] = useState<ServedPlayer & { chapters: MediaChapter[], endingOffered: boolean }>(
|
|
372
|
+
() => Object.assign(new EventTarget(), {
|
|
373
|
+
chapters: [],
|
|
374
|
+
endingOffered: true,
|
|
375
|
+
onHostFullscreen: setEmbedderFullscreen,
|
|
376
|
+
onEndingOffered: setEndingOffered,
|
|
377
|
+
}),
|
|
372
378
|
)
|
|
373
379
|
const exposeOptions = expose === true ? {} : expose || undefined
|
|
374
380
|
const latestExpose = useRef(exposeOptions)
|
|
@@ -392,10 +398,12 @@ const PlayerRoot = ({ options, children }: { options: MediaPlayerOptions, childr
|
|
|
392
398
|
// by value, since a caller's inline `chapters` is a new array on every render
|
|
393
399
|
const playerChapters = usePlayer((state) => state.chapters)
|
|
394
400
|
const chaptersKey = JSON.stringify(playerChapters)
|
|
401
|
+
// after the commit, so a mirror that hears the ending is no longer offered finds the button already gone
|
|
395
402
|
useEffect(() => {
|
|
396
403
|
served.chapters = playerChapters
|
|
404
|
+
served.endingOffered = endingOffered
|
|
397
405
|
served.dispatchEvent(new Event('chapterschange'))
|
|
398
|
-
}, [chaptersKey])
|
|
406
|
+
}, [chaptersKey, endingOffered])
|
|
399
407
|
|
|
400
408
|
const fullscreen = options.fullscreen ?? (embedderFullscreen === null ? undefined : {
|
|
401
409
|
active: embedderFullscreen,
|
|
@@ -581,6 +589,7 @@ const PlayerRoot = ({ options, children }: { options: MediaPlayerOptions, childr
|
|
|
581
589
|
controls={options.controls}
|
|
582
590
|
shortcuts={options.shortcuts}
|
|
583
591
|
fullscreen={fullscreen}
|
|
592
|
+
endingOffered={endingOffered}
|
|
584
593
|
>
|
|
585
594
|
{children}
|
|
586
595
|
</Chrome>
|
package/src/lib/remote/index.ts
CHANGED
|
@@ -83,14 +83,17 @@ export type ExposePlayerOptions = {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* The player around a served media, as `<MediaPlayer expose>` passes it: its chapters
|
|
87
|
-
* announced on its `chapterschange`, and its fullscreen, which a mirror made
|
|
88
|
-
* one has it, `onHostFullscreen` is told the state that mirror sets, and null
|
|
89
|
-
* dispatches `fullscreenrequest` for each press of its fullscreen, which reaches the
|
|
86
|
+
* The player around a served media, as `<MediaPlayer expose>` passes it: its chapters and whether it offers to skip its
|
|
87
|
+
* last ending, sent with every snapshot and announced on its `chapterschange`, and its fullscreen, which a mirror made
|
|
88
|
+
* with `fullscreen: true` takes over. While one has it, `onHostFullscreen` is told the state that mirror sets, and null
|
|
89
|
+
* once none has it; the player then dispatches `fullscreenrequest` for each press of its fullscreen, which reaches the
|
|
90
|
+
* mirror. `onEndingOffered` is told what a mirror sets on `endingOffered`.
|
|
90
91
|
*/
|
|
91
92
|
export type ServedPlayer = EventTarget & {
|
|
92
93
|
readonly chapters: MediaChapter[]
|
|
94
|
+
readonly endingOffered: boolean
|
|
93
95
|
onHostFullscreen: (active: boolean | null) => void
|
|
96
|
+
onEndingOffered: (offered: boolean) => void
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
/**
|
|
@@ -173,7 +176,8 @@ const channelFor = (options: ExposePlayerOptions): Channel => {
|
|
|
173
176
|
}
|
|
174
177
|
const snapshotAt = (id: string) => {
|
|
175
178
|
const media = medias.get(id)
|
|
176
|
-
|
|
179
|
+
const around = players.get(id)
|
|
180
|
+
return media ? snapshotOf(media, around?.chapters, around?.endingOffered) : undefined
|
|
177
181
|
}
|
|
178
182
|
const announce = (id: string, event: PlayerEvent) => {
|
|
179
183
|
// a press of the fullscreen is for the mirrors that took it over: another one toggling too would undo it
|
|
@@ -223,6 +227,10 @@ const channelFor = (options: ExposePlayerOptions): Channel => {
|
|
|
223
227
|
tellHost(id)
|
|
224
228
|
return
|
|
225
229
|
}
|
|
230
|
+
if (name === 'endingOffered') {
|
|
231
|
+
if (typeof value === 'boolean') players.get(id)?.onEndingOffered(value)
|
|
232
|
+
return
|
|
233
|
+
}
|
|
226
234
|
const media = medias.get(id)
|
|
227
235
|
if (!media || !WRITABLE.includes(name)) return
|
|
228
236
|
try { (media as unknown as Record<Writable, unknown>)[name] = value } catch {}
|
|
@@ -333,6 +341,16 @@ export type MediaPlayerHandle =
|
|
|
333
341
|
* shortcuts follow it. Set it on every change. Without the option it stays here.
|
|
334
342
|
*/
|
|
335
343
|
fullscreen: boolean
|
|
344
|
+
/**
|
|
345
|
+
* Whether the far `<MediaPlayer expose>` offers to skip its last ending, as it last said. Set it to false to have
|
|
346
|
+
* that offer taken away, for a page with something of its own in that corner, and to true to have it back; a
|
|
347
|
+
* mirror's `destroy()` leaves it as it is, and a new player starts out offering.
|
|
348
|
+
*
|
|
349
|
+
* Unlike every other write here this one does NOT move the mirror: a read answers what the far player reports,
|
|
350
|
+
* from after its render, with a `chapterschange` event following each change. So a false here means the offer is
|
|
351
|
+
* off the far screen, and a player that cannot take it (a bare element, a version older than this) stays true.
|
|
352
|
+
*/
|
|
353
|
+
endingOffered: boolean
|
|
336
354
|
/**
|
|
337
355
|
* Settles once the far side has first answered with its state; reads before that answer the
|
|
338
356
|
* empty defaults. Stays pending for as long as nobody answers, and rejects with an AbortError on
|
|
@@ -417,7 +435,7 @@ type Subscriber = {
|
|
|
417
435
|
|
|
418
436
|
type Link = {
|
|
419
437
|
attach: (subscriber: Subscriber) => () => void
|
|
420
|
-
set: (id: string, name: Writable | 'fullscreen', value: number | boolean) => Promise<unknown> | undefined
|
|
438
|
+
set: (id: string, name: Writable | 'fullscreen' | 'endingOffered', value: number | boolean) => Promise<unknown> | undefined
|
|
421
439
|
call: (id: string, name: Callable) => Promise<void>
|
|
422
440
|
}
|
|
423
441
|
|
|
@@ -628,6 +646,11 @@ export const mediaPlayer = (
|
|
|
628
646
|
},
|
|
629
647
|
enumerable: true,
|
|
630
648
|
})
|
|
649
|
+
Object.defineProperty(player, 'endingOffered', {
|
|
650
|
+
get: () => state.endingOffered,
|
|
651
|
+
set: (value: boolean) => { void after(() => link.set(playerId, 'endingOffered', value)) },
|
|
652
|
+
enumerable: true,
|
|
653
|
+
})
|
|
631
654
|
|
|
632
655
|
const call = (name: Callable) => ready.then(() => {
|
|
633
656
|
if (signal.aborted) throw abortError()
|
|
@@ -31,6 +31,8 @@ export type PlayerSnapshot = {
|
|
|
31
31
|
videoHeight: number
|
|
32
32
|
/** A `<MediaPlayer expose>`'s chapters, empty for a bare element. */
|
|
33
33
|
chapters: MediaChapter[]
|
|
34
|
+
/** Whether a `<MediaPlayer expose>` offers to skip its last ending. Set after its render, so false means the offer is off the screen. */
|
|
35
|
+
endingOffered: boolean
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
@@ -93,7 +95,7 @@ export type PlayerService = {
|
|
|
93
95
|
/** With `fullscreen`, the mirror takes the player's fullscreen over, in that state, until its port goes. */
|
|
94
96
|
subscribe: (id: string, port: MessagePort, options?: { fullscreen?: boolean }) => void
|
|
95
97
|
/** `fullscreen` is the state shown by a player whose fullscreen a mirror has taken over, and is ignored otherwise. */
|
|
96
|
-
set: (id: string, name: Writable | 'fullscreen', value: number | boolean) => void
|
|
98
|
+
set: (id: string, name: Writable | 'fullscreen' | 'endingOffered', value: number | boolean) => void
|
|
97
99
|
call: (id: string, name: Callable) => Promise<void>
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -124,7 +126,7 @@ const pairs = (ranges: TimeRangesLike | undefined): [number, number][] => {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
/** A media as a snapshot. A NaN duration, which a bare element answers before it has metadata, is sent as 0. */
|
|
127
|
-
export const snapshotOf = (media: PlayerMedia, chapters: MediaChapter[] = []): PlayerSnapshot => ({
|
|
129
|
+
export const snapshotOf = (media: PlayerMedia, chapters: MediaChapter[] = [], endingOffered = true): PlayerSnapshot => ({
|
|
128
130
|
currentTime: finite(media.currentTime),
|
|
129
131
|
duration: finite(media.duration),
|
|
130
132
|
paused: media.paused,
|
|
@@ -142,6 +144,7 @@ export const snapshotOf = (media: PlayerMedia, chapters: MediaChapter[] = []): P
|
|
|
142
144
|
videoWidth: media.videoWidth ?? 0,
|
|
143
145
|
videoHeight: media.videoHeight ?? 0,
|
|
144
146
|
chapters,
|
|
147
|
+
endingOffered,
|
|
145
148
|
})
|
|
146
149
|
|
|
147
150
|
// NaN only. A live media reports `duration: Infinity` and means it, so sending 0 for it would mirror
|
|
@@ -152,7 +155,7 @@ const finite = (value: number): number => Number.isNaN(value) ? 0 : value
|
|
|
152
155
|
export const EMPTY_SNAPSHOT: PlayerSnapshot = {
|
|
153
156
|
currentTime: 0, duration: 0, paused: true, ended: false, seeking: false, readyState: 0,
|
|
154
157
|
volume: 1, muted: false, playbackRate: 1, src: '', currentSrc: '',
|
|
155
|
-
buffered: [], seekable: [], error: null, videoWidth: 0, videoHeight: 0, chapters: [],
|
|
158
|
+
buffered: [], seekable: [], error: null, videoWidth: 0, videoHeight: 0, chapters: [], endingOffered: true,
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
/** Plain pairs back into the structural `TimeRanges` the player reads. */
|