@banou/media-player 0.10.30 → 0.10.31
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 +20 -0
- package/dist/de-DphEdq0O.js +52 -0
- package/dist/engine/index.js +1 -1
- package/dist/{engine-DeEY2qao.js → engine-5XbZqrD3.js} +213 -162
- package/dist/es-419-D6gsvnn8.js +52 -0
- package/dist/fr-BqAzAJX0.js +52 -0
- package/dist/index.js +931 -844
- package/dist/it-NTcUh3Gr.js +52 -0
- package/dist/ja-DSmX_bxj.js +52 -0
- package/dist/ko-DyPzWasj.js +52 -0
- package/dist/labels.d.ts +71 -0
- package/dist/pl-C6Ow4ra5.js +52 -0
- package/dist/pt-BR-wudK3giz.js +52 -0
- package/dist/react/labels.d.ts +28 -0
- package/dist/react/video-player.d.ts +9 -0
- package/dist/ru-D5kxBkik.js +52 -0
- package/dist/tr-CW7R7N9k.js +52 -0
- package/dist/utils/track-label.d.ts +9 -8
- package/dist/zh-Hans-IhL1Pl78.js +52 -0
- package/dist/zh-Hant-C5YyFjEc.js +52 -0
- package/package.json +3 -1
- package/src/lib/engine/playback.ts +6 -5
- package/src/lib/engine/source-buffer.ts +3 -1
- package/src/lib/labels.ts +75 -0
- package/src/lib/locales/de.json +49 -0
- package/src/lib/locales/es-419.json +49 -0
- package/src/lib/locales/fr.json +49 -0
- package/src/lib/locales/it.json +49 -0
- package/src/lib/locales/ja.json +49 -0
- package/src/lib/locales/ko.json +49 -0
- package/src/lib/locales/pl.json +49 -0
- package/src/lib/locales/pt-BR.json +49 -0
- package/src/lib/locales/ru.json +49 -0
- package/src/lib/locales/tr.json +49 -0
- package/src/lib/locales/zh-Hans.json +49 -0
- package/src/lib/locales/zh-Hant.json +49 -0
- package/src/lib/react/components/burn-in-hint.tsx +4 -1
- package/src/lib/react/components/chrome.tsx +9 -0
- package/src/lib/react/components/control-bar.tsx +15 -26
- package/src/lib/react/components/errors.tsx +11 -9
- package/src/lib/react/components/overlay.tsx +18 -5
- package/src/lib/react/components/playback-slider.tsx +4 -1
- package/src/lib/react/components/settings.tsx +23 -31
- package/src/lib/react/components/skip-chapter.tsx +5 -2
- package/src/lib/react/components/sound.tsx +5 -2
- package/src/lib/react/components/subtitles.tsx +7 -4
- package/src/lib/react/components/track-menu.tsx +8 -4
- package/src/lib/react/components/volume-slider.tsx +3 -1
- package/src/lib/react/hooks/use-playback.ts +12 -2
- package/src/lib/react/labels.tsx +125 -0
- package/src/lib/react/video-player.tsx +14 -1
- package/src/lib/utils/track-label.ts +16 -11
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"(Default)": "(Normal)",
|
|
3
|
+
"Audio": "Ses",
|
|
4
|
+
"Copied": "Kopyalandı",
|
|
5
|
+
"Copy": "Kopyala",
|
|
6
|
+
"Copy the errors": "Hataları kopyala",
|
|
7
|
+
"Could not switch. Try again.": "Değiştirilemedi. Tekrar deneyin.",
|
|
8
|
+
"Disable": "Kapalı",
|
|
9
|
+
"Exit full screen (f)": "Tam ekrandan çık (f)",
|
|
10
|
+
"Exit picture in picture": "Pencere içinde pencereden çık",
|
|
11
|
+
"Full screen": "Tam ekran",
|
|
12
|
+
"Full screen (f)": "Tam ekran (f)",
|
|
13
|
+
"Mute": "Sesi kapat",
|
|
14
|
+
"Mute (m)": "Sesi kapat (m)",
|
|
15
|
+
"Normalize volume": "Sesi dengele",
|
|
16
|
+
"Now click your browser's pop out button": "Şimdi tarayıcınızın pencere içinde pencere düğmesine tıklayın",
|
|
17
|
+
"Pause": "Duraklat",
|
|
18
|
+
"Pause (k)": "Duraklat (k)",
|
|
19
|
+
"Picture in picture": "Pencere içinde pencere",
|
|
20
|
+
"Play": "Oynat",
|
|
21
|
+
"Play (k)": "Oynat (k)",
|
|
22
|
+
"Playback errors ({count})": "Oynatma hataları ({count})",
|
|
23
|
+
"Playback failed": "Oynatılamadı",
|
|
24
|
+
"Playback speed": "Oynatma hızı",
|
|
25
|
+
"Put the subtitles in the picture": "Altyazıları görüntüye göm",
|
|
26
|
+
"Put the subtitles in the video": "Altyazıları videoya göm",
|
|
27
|
+
"Quality": "Kalite",
|
|
28
|
+
"Reading the video file failed": "Video dosyası okunamadı",
|
|
29
|
+
"Replay": "Tekrar oynat",
|
|
30
|
+
"Replay (k)": "Tekrar oynat (k)",
|
|
31
|
+
"Settings": "Ayarlar",
|
|
32
|
+
"Skip Ending": "Kapanışı atla",
|
|
33
|
+
"Skip Opening": "Açılışı atla",
|
|
34
|
+
"Subtitles": "Altyazılar",
|
|
35
|
+
"Subtitles are in the picture": "Altyazılar görüntüye gömülü",
|
|
36
|
+
"The MediaSource closed before a SourceBuffer could be created": "MediaSource, SourceBuffer oluşturulamadan kapandı",
|
|
37
|
+
"The MediaSource never opened": "MediaSource hiç açılmadı",
|
|
38
|
+
"The browser rejected a media segment": "Tarayıcı bir medya segmentini reddetti",
|
|
39
|
+
"The video codec in this file could not be identified": "Bu dosyanın video kodeki belirlenemedi",
|
|
40
|
+
"This browser cannot play the codecs in this file: {codecs}": "Bu tarayıcı bu dosyadaki kodekleri oynatamıyor: {codecs}",
|
|
41
|
+
"This file has no subtitles": "Bu dosyada altyazı yok",
|
|
42
|
+
"Track {number}": "Parça {number}",
|
|
43
|
+
"Unavailable": "Kullanılamıyor",
|
|
44
|
+
"Unmute (m)": "Sesi aç (m)",
|
|
45
|
+
"at {time}": "{time} konumunda",
|
|
46
|
+
"recovered": "düzeldi",
|
|
47
|
+
"{rate}x": "{rate}x",
|
|
48
|
+
"{start} to {end}": "{start} ile {end} arası"
|
|
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -3,6 +3,8 @@ import { css } from '@emotion/react'
|
|
|
3
3
|
|
|
4
4
|
import { fonts } from '../../utils/fonts'
|
|
5
5
|
import { usePlayer } from '../player'
|
|
6
|
+
import { useLabels } from '../labels'
|
|
7
|
+
import { LABELS } from '../../labels'
|
|
6
8
|
|
|
7
9
|
const VISIBLE_MS = 9000
|
|
8
10
|
|
|
@@ -59,6 +61,7 @@ const style = css`
|
|
|
59
61
|
* control is now the thing to press.
|
|
60
62
|
*/
|
|
61
63
|
export const BurnInHint = () => {
|
|
64
|
+
const { format } = useLabels()
|
|
62
65
|
const burnedInSubtitles = usePlayer((state) => state.burnedInSubtitles)
|
|
63
66
|
const mode = usePlayer((state) => state.pictureInPictureMode)
|
|
64
67
|
const [show, setShow] = useState(false)
|
|
@@ -78,7 +81,7 @@ export const BurnInHint = () => {
|
|
|
78
81
|
return (
|
|
79
82
|
<div css={style} className={show ? 'show' : ''} role='status'>
|
|
80
83
|
<div className='card'>
|
|
81
|
-
<div className='text'>
|
|
84
|
+
<div className='text'>{format(LABELS.burnInHint)}</div>
|
|
82
85
|
<div className='arrow' aria-hidden='true'>→</div>
|
|
83
86
|
</div>
|
|
84
87
|
</div>
|
|
@@ -157,6 +157,15 @@ export const Chrome = ({ ref, onVideoRef, onSubtitleRef, overlay, controls, shor
|
|
|
157
157
|
|
|
158
158
|
useEffect(() => () => clearTimeout(autoHide.current), [])
|
|
159
159
|
|
|
160
|
+
// the player's height, which the menus are capped by (popoverStyle)
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const element = root.current
|
|
163
|
+
if (!element) return
|
|
164
|
+
const observer = new ResizeObserver(([entry]) => element.style.setProperty('--mp-height', `${entry!.contentRect.height}px`))
|
|
165
|
+
observer.observe(element)
|
|
166
|
+
return () => observer.disconnect()
|
|
167
|
+
}, [])
|
|
168
|
+
|
|
160
169
|
/*
|
|
161
170
|
* With nothing loaded the chrome never hides, and anything already hidden comes back.
|
|
162
171
|
*
|
|
@@ -10,6 +10,8 @@ import { linearToLogVolume, logToLinearVolume } from '../../utils/volume-utils'
|
|
|
10
10
|
import { formatMediaTime } from '../../utils/time'
|
|
11
11
|
import { fonts } from '../../utils/fonts'
|
|
12
12
|
import { usePlayer } from '../player'
|
|
13
|
+
import { useLabels } from '../labels'
|
|
14
|
+
import { LABELS } from '../../labels'
|
|
13
15
|
import { TooltipDisplay } from './tooltip-display'
|
|
14
16
|
import { ProgressBar } from './progress-bar'
|
|
15
17
|
import pictureInPicture from '../../assets/picture-in-picture.svg'
|
|
@@ -168,6 +170,7 @@ export const ControlBar = (
|
|
|
168
170
|
},
|
|
169
171
|
) => {
|
|
170
172
|
const player = usePlayer()
|
|
173
|
+
const { format } = useLabels()
|
|
171
174
|
const paused = usePlayer((state) => state.paused)
|
|
172
175
|
const currentTime = usePlayer((state) => state.currentTime)
|
|
173
176
|
const duration = usePlayer((state) => state.duration)
|
|
@@ -345,7 +348,7 @@ export const ControlBar = (
|
|
|
345
348
|
onClick={() => player.togglePaused()}
|
|
346
349
|
// This one genuinely changes what it does, so the name changes with it rather than
|
|
347
350
|
// carrying a pressed state. Replay is a third action, not an on or off.
|
|
348
|
-
aria-label={ended ?
|
|
351
|
+
aria-label={format(ended ? LABELS.replay : paused ? LABELS.play : LABELS.pause)}
|
|
349
352
|
>
|
|
350
353
|
{
|
|
351
354
|
ended
|
|
@@ -357,15 +360,7 @@ export const ControlBar = (
|
|
|
357
360
|
</button>
|
|
358
361
|
}
|
|
359
362
|
toolTipText={
|
|
360
|
-
<span>
|
|
361
|
-
{
|
|
362
|
-
ended
|
|
363
|
-
? 'Replay (k)'
|
|
364
|
-
: paused
|
|
365
|
-
? 'Play (k)'
|
|
366
|
-
: 'Pause (k)'
|
|
367
|
-
}
|
|
368
|
-
</span>
|
|
363
|
+
<span>{format(ended ? LABELS.replayKey : paused ? LABELS.playKey : LABELS.pauseKey)}</span>
|
|
369
364
|
}
|
|
370
365
|
/>
|
|
371
366
|
<Sound ref={setVolumeElement}/>
|
|
@@ -392,14 +387,14 @@ export const ControlBar = (
|
|
|
392
387
|
// Out of picture in picture the click was meant for the host's document, so one
|
|
393
388
|
// that lands here instead (a key press) has nothing it could do.
|
|
394
389
|
onClick={passThrough.active ? passThrough.exit : undefined}
|
|
395
|
-
aria-label=
|
|
390
|
+
aria-label={format(LABELS.pictureInPicture)}
|
|
396
391
|
aria-pressed={passThrough.active}
|
|
397
392
|
>
|
|
398
393
|
<img src={pictureInPicture} alt='' />
|
|
399
394
|
</button>
|
|
400
395
|
}
|
|
401
396
|
toolTipText={
|
|
402
|
-
<span>{passThrough.active ?
|
|
397
|
+
<span>{format(passThrough.active ? LABELS.exitPictureInPicture : LABELS.pictureInPicture)}</span>
|
|
403
398
|
}
|
|
404
399
|
/>
|
|
405
400
|
)
|
|
@@ -417,7 +412,7 @@ export const ControlBar = (
|
|
|
417
412
|
// Static name with the state on `aria-pressed`, rather than a name that changes
|
|
418
413
|
// on activation: one announces the state once, the other announces it twice and
|
|
419
414
|
// renames the control while the pointer is on it.
|
|
420
|
-
aria-label={burnIn ?
|
|
415
|
+
aria-label={format(burnIn ? LABELS.burnIn : LABELS.pictureInPicture)}
|
|
421
416
|
aria-pressed={burnIn ? burnedInSubtitles : undefined}
|
|
422
417
|
>
|
|
423
418
|
{/* The glyph carries the on state, which is what every other toggle in this bar
|
|
@@ -432,13 +427,13 @@ export const ControlBar = (
|
|
|
432
427
|
}
|
|
433
428
|
toolTipText={
|
|
434
429
|
<span>
|
|
435
|
-
{!burnIn
|
|
436
|
-
?
|
|
430
|
+
{format(!burnIn
|
|
431
|
+
? LABELS.pictureInPicture
|
|
437
432
|
: !hasSubtitles
|
|
438
|
-
?
|
|
433
|
+
? LABELS.noSubtitles
|
|
439
434
|
: burnedInSubtitles
|
|
440
|
-
?
|
|
441
|
-
:
|
|
435
|
+
? LABELS.burnedIn
|
|
436
|
+
: LABELS.burnInOffer)}
|
|
442
437
|
</span>
|
|
443
438
|
}
|
|
444
439
|
/>
|
|
@@ -452,7 +447,7 @@ export const ControlBar = (
|
|
|
452
447
|
className='full-screen'
|
|
453
448
|
type='button'
|
|
454
449
|
onClick={toggleFullscreen}
|
|
455
|
-
aria-label=
|
|
450
|
+
aria-label={format(LABELS.fullScreen)}
|
|
456
451
|
aria-pressed={fullscreen}
|
|
457
452
|
>
|
|
458
453
|
{
|
|
@@ -463,13 +458,7 @@ export const ControlBar = (
|
|
|
463
458
|
</button>
|
|
464
459
|
}
|
|
465
460
|
toolTipText={
|
|
466
|
-
<span>
|
|
467
|
-
{
|
|
468
|
-
fullscreen
|
|
469
|
-
? 'Exit full screen (f)'
|
|
470
|
-
: 'Full screen (f)'
|
|
471
|
-
}
|
|
472
|
-
</span>
|
|
461
|
+
<span>{format(fullscreen ? LABELS.exitFullScreenKey : LABELS.fullScreenKey)}</span>
|
|
473
462
|
}
|
|
474
463
|
/>
|
|
475
464
|
</div>
|
|
@@ -8,6 +8,8 @@ import { Check, Copy, TriangleAlert } from 'lucide-react'
|
|
|
8
8
|
import { fonts } from '../../utils/fonts'
|
|
9
9
|
import { formatTime } from '../../utils/time'
|
|
10
10
|
import { usePlayer } from '../player'
|
|
11
|
+
import { useLabels } from '../labels'
|
|
12
|
+
import { LABELS } from '../../labels'
|
|
11
13
|
import { TooltipDisplay } from './tooltip-display'
|
|
12
14
|
import { popoverStyle, useTrackMenu } from './track-menu'
|
|
13
15
|
|
|
@@ -33,7 +35,7 @@ ${popoverStyle}
|
|
|
33
35
|
/* Wider than a track menu and taller, because these rows are sentences rather than labels, and a
|
|
34
36
|
decoder message that has been ellipsized is not worth copying. */
|
|
35
37
|
width: 420px;
|
|
36
|
-
max-height: min(300px, calc(100cqh - 100% - 16px));
|
|
38
|
+
max-height: min(300px, calc(var(--mp-height, 100cqh) - 100% - 16px));
|
|
37
39
|
|
|
38
40
|
/* track-menu's header is a left-aligned label row; here it carries a control too, so the two
|
|
39
41
|
ends go to the two ends */
|
|
@@ -101,7 +103,7 @@ ${popoverStyle}
|
|
|
101
103
|
}
|
|
102
104
|
`
|
|
103
105
|
|
|
104
|
-
const clock = (at: number) => new Date(at).toLocaleTimeString()
|
|
106
|
+
const clock = (at: number, locale: string | undefined) => new Date(at).toLocaleTimeString(locale)
|
|
105
107
|
|
|
106
108
|
// the chrome's own formatter, so a position in the log reads exactly like the one on the seekbar
|
|
107
109
|
const mediaTime = (seconds: number | undefined) =>
|
|
@@ -138,6 +140,7 @@ export const formatErrors = (errors: PlaybackErrorEntry[]) =>
|
|
|
138
140
|
*/
|
|
139
141
|
export const ErrorsAction = () => {
|
|
140
142
|
const errors = usePlayer((state) => state.playbackErrors)
|
|
143
|
+
const { format, locale } = useLabels()
|
|
141
144
|
const { open, toggle, containerRef } = useTrackMenu()
|
|
142
145
|
const [copied, setCopied] = useState(false)
|
|
143
146
|
|
|
@@ -158,7 +161,7 @@ export const ErrorsAction = () => {
|
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
// counted in failures rather than in rows, because a row that says ×40 is forty of them
|
|
161
|
-
const label =
|
|
164
|
+
const label = format(LABELS.errors, { count: countErrors(errors) })
|
|
162
165
|
|
|
163
166
|
return (
|
|
164
167
|
<div css={style} ref={containerRef}>
|
|
@@ -184,19 +187,18 @@ export const ErrorsAction = () => {
|
|
|
184
187
|
{/* `no-hover` because the header is a label with a control in it, not a row to click */}
|
|
185
188
|
<div className='back no-hover'>
|
|
186
189
|
<span>{label}</span>
|
|
187
|
-
<button className='copy' type='button' onClick={copy} aria-label=
|
|
190
|
+
<button className='copy' type='button' onClick={copy} aria-label={format(LABELS.copyErrors)}>
|
|
188
191
|
{copied ? <Check /> : <Copy />}
|
|
189
|
-
<span>{copied ?
|
|
192
|
+
<span>{format(copied ? LABELS.copied : LABELS.copy)}</span>
|
|
190
193
|
</button>
|
|
191
194
|
</div>
|
|
192
195
|
{errors.map((entry, index) => (
|
|
193
196
|
<div className='entry no-hover' key={`${entry.at}-${index}`}>
|
|
194
197
|
<span className='when'>
|
|
195
|
-
{clock(entry.at)}
|
|
196
198
|
{/* the span, so a row that is still growing is distinguishable from one that stopped */}
|
|
197
|
-
{entry.count > 1 ?
|
|
198
|
-
{mediaTime(entry.atMediaTime) ? `
|
|
199
|
-
{entry.recovered ?
|
|
199
|
+
{entry.count > 1 ? format(LABELS.errorSpan, { start: clock(entry.at, locale), end: clock(entry.lastAt, locale) }) : clock(entry.at, locale)}
|
|
200
|
+
{mediaTime(entry.atMediaTime) ? ` ${format(LABELS.errorAt, { time: mediaTime(entry.atMediaTime)! })}` : ''}
|
|
201
|
+
{entry.recovered ? ` ${format(LABELS.recovered)}` : ''}
|
|
200
202
|
{entry.count > 1 ? <span className='count'>{`×${entry.count}`}</span> : null}
|
|
201
203
|
</span>
|
|
202
204
|
<span className='what'>{entry.message}</span>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="@emotion/react/types/css-prop" />
|
|
2
2
|
import type { ReactNode } from 'react'
|
|
3
|
+
import type { Labels } from '../labels'
|
|
4
|
+
import type { LabelledError } from '../../labels'
|
|
3
5
|
|
|
4
6
|
import { css, keyframes } from '@emotion/react'
|
|
5
7
|
|
|
6
8
|
import { usePlayer } from '../player'
|
|
9
|
+
import { useLabels } from '../labels'
|
|
10
|
+
import { LABELS } from '../../labels'
|
|
7
11
|
import { fonts } from '../../utils/fonts'
|
|
8
12
|
|
|
9
13
|
/**
|
|
@@ -102,12 +106,21 @@ const errorStyle = css`
|
|
|
102
106
|
pointer-events: none;
|
|
103
107
|
`
|
|
104
108
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
const KNOWN: ReadonlySet<string> = new Set(Object.values(LABELS))
|
|
110
|
+
|
|
111
|
+
const isLabelled = (error: unknown): error is LabelledError =>
|
|
112
|
+
error instanceof Error && KNOWN.has((error as Partial<LabelledError>).label ?? '')
|
|
113
|
+
|
|
114
|
+
// a failure the engine labelled is shown in the player's language, any other as it was thrown
|
|
115
|
+
const errorMessage = (error: unknown, { format }: Labels) =>
|
|
116
|
+
isLabelled(error)
|
|
117
|
+
? (format as (label: string, values?: LabelledError['values']) => string)(error.label, error.values)
|
|
118
|
+
: error instanceof Error
|
|
119
|
+
? error.message
|
|
120
|
+
: typeof error === 'string' ? error : format(LABELS.failed)
|
|
109
121
|
|
|
110
122
|
export const Overlay = ({ onSubtitleRef }: { onSubtitleRef: (element: HTMLDivElement | null) => void }) => {
|
|
123
|
+
const labels = useLabels()
|
|
111
124
|
const title = usePlayer((state) => state.title)
|
|
112
125
|
const hideUI = usePlayer((state) => state.hideUI)
|
|
113
126
|
const playbackError = usePlayer((state) => state.playbackError)
|
|
@@ -140,7 +153,7 @@ export const Overlay = ({ onSubtitleRef }: { onSubtitleRef: (element: HTMLDivEle
|
|
|
140
153
|
? <div css={loadingStyle} />
|
|
141
154
|
: undefined}
|
|
142
155
|
{playbackError
|
|
143
|
-
? <div css={errorStyle}>{errorMessage(playbackError)}</div>
|
|
156
|
+
? <div css={errorStyle}>{errorMessage(playbackError, labels)}</div>
|
|
144
157
|
: undefined}
|
|
145
158
|
<div className="subtitles" ref={onSubtitleRef} css={style} />
|
|
146
159
|
</>
|
|
@@ -4,6 +4,8 @@ import { css } from '@emotion/react'
|
|
|
4
4
|
|
|
5
5
|
import { usePlayer } from '../player'
|
|
6
6
|
import { useDragValue } from '../hooks/use-drag-value'
|
|
7
|
+
import { useLabels } from '../labels'
|
|
8
|
+
import { LABELS } from '../../labels'
|
|
7
9
|
|
|
8
10
|
const style = css`
|
|
9
11
|
display: flex;
|
|
@@ -62,6 +64,7 @@ width: 100%;
|
|
|
62
64
|
|
|
63
65
|
export const PlaybackSlider = () => {
|
|
64
66
|
const player = usePlayer()
|
|
67
|
+
const { format, number } = useLabels()
|
|
65
68
|
const playbackRate = usePlayer((state) => state.playbackRate)
|
|
66
69
|
const sliderRef = useRef<HTMLDivElement>(null)
|
|
67
70
|
const trackRef = useRef<HTMLDivElement>(null)
|
|
@@ -121,7 +124,7 @@ export const PlaybackSlider = () => {
|
|
|
121
124
|
return (
|
|
122
125
|
<div css={style}>
|
|
123
126
|
<div>
|
|
124
|
-
{
|
|
127
|
+
{format(LABELS.speed, { rate: number(roundedRate, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) })}
|
|
125
128
|
</div>
|
|
126
129
|
<div
|
|
127
130
|
className="playback-slider"
|
|
@@ -4,6 +4,8 @@ import { css } from '@emotion/react'
|
|
|
4
4
|
import { ChevronLeft, ChevronRight, Settings } from 'lucide-react'
|
|
5
5
|
|
|
6
6
|
import { usePlayer } from '../player'
|
|
7
|
+
import { useLabels } from '../labels'
|
|
8
|
+
import { LABELS } from '../../labels'
|
|
7
9
|
import { TooltipDisplay } from './tooltip-display'
|
|
8
10
|
import PlaybackSlider from './playback-slider'
|
|
9
11
|
import { TrackMenu, popoverStyle, useTrackMenu } from './track-menu'
|
|
@@ -104,6 +106,8 @@ ${popoverStyle}
|
|
|
104
106
|
|
|
105
107
|
`
|
|
106
108
|
|
|
109
|
+
const SPEEDS = [0.5, 1, 1.5, 2]
|
|
110
|
+
|
|
107
111
|
enum PopoverContent {
|
|
108
112
|
Default,
|
|
109
113
|
PlaybackRate,
|
|
@@ -113,6 +117,7 @@ enum PopoverContent {
|
|
|
113
117
|
|
|
114
118
|
export const SettingsAction = () => {
|
|
115
119
|
const player = usePlayer()
|
|
120
|
+
const { format, number } = useLabels()
|
|
116
121
|
const playbackRate = usePlayer((state) => state.playbackRate)
|
|
117
122
|
const audioTracks = usePlayer((state) => state.audioTracks)
|
|
118
123
|
const selectedAudioTrack = usePlayer((state) => state.selectedAudioTrack)
|
|
@@ -159,17 +164,13 @@ export const SettingsAction = () => {
|
|
|
159
164
|
className='settings'
|
|
160
165
|
type='button'
|
|
161
166
|
onClick={toggle}
|
|
162
|
-
aria-label=
|
|
167
|
+
aria-label={format(LABELS.settings)}
|
|
163
168
|
aria-expanded={open}
|
|
164
169
|
>
|
|
165
170
|
<Settings />
|
|
166
171
|
</button>
|
|
167
172
|
}
|
|
168
|
-
toolTipText={
|
|
169
|
-
<span>
|
|
170
|
-
Settings
|
|
171
|
-
</span>
|
|
172
|
-
}
|
|
173
|
+
toolTipText={<span>{format(LABELS.settings)}</span>}
|
|
173
174
|
/>
|
|
174
175
|
{
|
|
175
176
|
open && popoverContent === PopoverContent.Default && (
|
|
@@ -183,7 +184,7 @@ export const SettingsAction = () => {
|
|
|
183
184
|
{audioTracks.length > 1
|
|
184
185
|
? (
|
|
185
186
|
<div onClick={changePopoverContent(PopoverContent.Audio)}>
|
|
186
|
-
<div>
|
|
187
|
+
<div>{format(LABELS.audio)}</div>
|
|
187
188
|
<div>
|
|
188
189
|
<ChevronRight />
|
|
189
190
|
</div>
|
|
@@ -193,7 +194,7 @@ export const SettingsAction = () => {
|
|
|
193
194
|
{qualityRows > 1
|
|
194
195
|
? (
|
|
195
196
|
<div onClick={changePopoverContent(PopoverContent.Quality)}>
|
|
196
|
-
<div>
|
|
197
|
+
<div>{format(LABELS.quality)}</div>
|
|
197
198
|
<div>
|
|
198
199
|
{qualityLabel ? <span className='secondary'>{qualityLabel}</span> : null}
|
|
199
200
|
<ChevronRight />
|
|
@@ -202,14 +203,12 @@ export const SettingsAction = () => {
|
|
|
202
203
|
)
|
|
203
204
|
: null}
|
|
204
205
|
<div onClick={changePopoverContent(PopoverContent.PlaybackRate)}>
|
|
205
|
-
<div>
|
|
206
|
+
<div>{format(LABELS.playbackSpeed)}</div>
|
|
206
207
|
<div>
|
|
207
208
|
<span className='secondary'>
|
|
208
|
-
{
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
: playbackRate.toFixed(2)
|
|
212
|
-
}
|
|
209
|
+
{playbackRate === 1
|
|
210
|
+
? format(LABELS.defaultSpeed)
|
|
211
|
+
: number(playbackRate, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
|
|
213
212
|
</span>
|
|
214
213
|
<ChevronRight />
|
|
215
214
|
</div>
|
|
@@ -225,11 +224,11 @@ export const SettingsAction = () => {
|
|
|
225
224
|
if (volumeNormalizer.available) volumeNormalizer.setEnabled(!volumeNormalizer.enabled)
|
|
226
225
|
}}
|
|
227
226
|
>
|
|
228
|
-
<div>
|
|
227
|
+
<div>{format(LABELS.normalizeVolume)}</div>
|
|
229
228
|
<div>
|
|
230
229
|
{volumeNormalizer.available
|
|
231
230
|
? <span className={volumeNormalizer.enabled ? 'switch on' : 'switch'} />
|
|
232
|
-
: <span className='secondary'>
|
|
231
|
+
: <span className='secondary'>{format(LABELS.unavailable)}</span>}
|
|
233
232
|
</div>
|
|
234
233
|
</div>
|
|
235
234
|
)
|
|
@@ -242,24 +241,17 @@ export const SettingsAction = () => {
|
|
|
242
241
|
<div className='popover playback-rate'>
|
|
243
242
|
<div className="back" onClick={changePopoverContent(PopoverContent.Default)}>
|
|
244
243
|
<ChevronLeft />
|
|
245
|
-
<span>
|
|
244
|
+
<span>{format(LABELS.playbackSpeed)}</span>
|
|
246
245
|
</div>
|
|
247
246
|
<div className="slider no-hover">
|
|
248
247
|
<PlaybackSlider />
|
|
249
248
|
</div>
|
|
250
249
|
<div className="options no-hover">
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
</div>
|
|
257
|
-
<div onClick={() => setPlaybackRate(1.5)}>
|
|
258
|
-
1.5x
|
|
259
|
-
</div>
|
|
260
|
-
<div onClick={() => setPlaybackRate(2)}>
|
|
261
|
-
2x
|
|
262
|
-
</div>
|
|
250
|
+
{SPEEDS.map((rate) => (
|
|
251
|
+
<div key={rate} onClick={() => setPlaybackRate(rate)}>
|
|
252
|
+
{format(LABELS.speed, { rate: number(rate) })}
|
|
253
|
+
</div>
|
|
254
|
+
))}
|
|
263
255
|
</div>
|
|
264
256
|
</div>
|
|
265
257
|
)
|
|
@@ -267,7 +259,7 @@ export const SettingsAction = () => {
|
|
|
267
259
|
{
|
|
268
260
|
open && popoverContent === PopoverContent.Audio && (
|
|
269
261
|
<TrackMenu
|
|
270
|
-
title=
|
|
262
|
+
title={format(LABELS.audio)}
|
|
271
263
|
tracks={audioTracks}
|
|
272
264
|
selected={selectedAudioTrack}
|
|
273
265
|
onSelect={chooseAudio}
|
|
@@ -280,7 +272,7 @@ export const SettingsAction = () => {
|
|
|
280
272
|
{
|
|
281
273
|
open && popoverContent === PopoverContent.Quality && quality && (
|
|
282
274
|
<TrackMenu
|
|
283
|
-
title=
|
|
275
|
+
title={format(LABELS.quality)}
|
|
284
276
|
tracks={quality.options}
|
|
285
277
|
selected={quality.selectedId ?? undefined}
|
|
286
278
|
onSelect={chooseQuality}
|
|
@@ -4,6 +4,8 @@ import { css } from '@emotion/react'
|
|
|
4
4
|
import { fonts } from '../../utils/fonts'
|
|
5
5
|
import { classifyChapters } from '../../utils/chapters'
|
|
6
6
|
import { usePlayer } from '../player'
|
|
7
|
+
import { useLabels } from '../labels'
|
|
8
|
+
import { LABELS } from '../../labels'
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* How far AHEAD of the chapter the offer appears, in seconds.
|
|
@@ -26,7 +28,7 @@ const OFFER_MS = 6_000
|
|
|
26
28
|
/** A jump back by more than this is a seek rather than playback, and re-opens the offer. */
|
|
27
29
|
const SEEK_BACK_S = 1
|
|
28
30
|
|
|
29
|
-
const
|
|
31
|
+
const OFFERS = { opening: LABELS.skipOpening, ending: LABELS.skipEnding } as const
|
|
30
32
|
|
|
31
33
|
const style = css`
|
|
32
34
|
position: absolute;
|
|
@@ -100,6 +102,7 @@ export const SkipChapter = () => {
|
|
|
100
102
|
*/
|
|
101
103
|
const seekPreview = usePlayer((state) => state.seekPreview)
|
|
102
104
|
const player = usePlayer()
|
|
105
|
+
const { format } = useLabels()
|
|
103
106
|
|
|
104
107
|
const kinds = useMemo(() => classifyChapters(chapters), [chapters])
|
|
105
108
|
|
|
@@ -163,7 +166,7 @@ export const SkipChapter = () => {
|
|
|
163
166
|
return (
|
|
164
167
|
<div css={style} className={show && !seekPreview ? 'show' : ''}>
|
|
165
168
|
<button type='button' className='skip-chapter' onClick={skip}>
|
|
166
|
-
{
|
|
169
|
+
{format(OFFERS[skippable.kind])}
|
|
167
170
|
</button>
|
|
168
171
|
</div>
|
|
169
172
|
)
|
|
@@ -6,6 +6,8 @@ import { css } from '@emotion/react'
|
|
|
6
6
|
import { Volume1, Volume2, VolumeX } from 'lucide-react'
|
|
7
7
|
|
|
8
8
|
import { usePlayer } from '../player'
|
|
9
|
+
import { useLabels } from '../labels'
|
|
10
|
+
import { LABELS } from '../../labels'
|
|
9
11
|
import { TooltipDisplay } from './tooltip-display'
|
|
10
12
|
import { fonts } from '../../utils/fonts'
|
|
11
13
|
import VolumeSlider from './volume-slider'
|
|
@@ -83,6 +85,7 @@ export type SoundProps = {
|
|
|
83
85
|
|
|
84
86
|
export const Sound = ({ ref }: SoundProps) => {
|
|
85
87
|
const player = usePlayer()
|
|
88
|
+
const { format } = useLabels()
|
|
86
89
|
const volume = usePlayer((state) => state.volume)
|
|
87
90
|
const muted = usePlayer((state) => state.muted)
|
|
88
91
|
|
|
@@ -107,7 +110,7 @@ export const Sound = ({ ref }: SoundProps) => {
|
|
|
107
110
|
ref={ref}
|
|
108
111
|
// A static name with the state on `aria-pressed`. Renaming a control when it is activated
|
|
109
112
|
// announces the state twice and breaks the expectation that a control keeps its name.
|
|
110
|
-
aria-label=
|
|
113
|
+
aria-label={format(LABELS.mute)}
|
|
111
114
|
aria-pressed={muted || volume === 0}
|
|
112
115
|
>
|
|
113
116
|
{muted || volume === 0
|
|
@@ -119,7 +122,7 @@ export const Sound = ({ ref }: SoundProps) => {
|
|
|
119
122
|
</button>
|
|
120
123
|
}
|
|
121
124
|
toolTipText={
|
|
122
|
-
<span>{muted ?
|
|
125
|
+
<span>{format(muted ? LABELS.unmuteKey : LABELS.muteKey)}</span>
|
|
123
126
|
}
|
|
124
127
|
/>
|
|
125
128
|
<div className='volume-slider-container'>
|