@banou/media-player 0.10.29 → 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.
Files changed (55) hide show
  1. package/README.md +23 -1
  2. package/dist/de-DphEdq0O.js +52 -0
  3. package/dist/engine/index.js +1 -1
  4. package/dist/{engine-DeEY2qao.js → engine-5XbZqrD3.js} +213 -162
  5. package/dist/es-419-D6gsvnn8.js +52 -0
  6. package/dist/fr-BqAzAJX0.js +52 -0
  7. package/dist/index.js +931 -844
  8. package/dist/it-NTcUh3Gr.js +52 -0
  9. package/dist/ja-DSmX_bxj.js +52 -0
  10. package/dist/ko-DyPzWasj.js +52 -0
  11. package/dist/labels.d.ts +71 -0
  12. package/dist/language/index.d.ts +6 -0
  13. package/dist/language/index.js +34 -27
  14. package/dist/pl-C6Ow4ra5.js +52 -0
  15. package/dist/pt-BR-wudK3giz.js +52 -0
  16. package/dist/react/labels.d.ts +28 -0
  17. package/dist/react/video-player.d.ts +9 -0
  18. package/dist/ru-D5kxBkik.js +52 -0
  19. package/dist/tr-CW7R7N9k.js +52 -0
  20. package/dist/utils/track-label.d.ts +9 -8
  21. package/dist/zh-Hans-IhL1Pl78.js +52 -0
  22. package/dist/zh-Hant-C5YyFjEc.js +52 -0
  23. package/package.json +3 -1
  24. package/src/lib/engine/playback.ts +6 -5
  25. package/src/lib/engine/source-buffer.ts +3 -1
  26. package/src/lib/labels.ts +75 -0
  27. package/src/lib/language/index.ts +13 -1
  28. package/src/lib/locales/de.json +49 -0
  29. package/src/lib/locales/es-419.json +49 -0
  30. package/src/lib/locales/fr.json +49 -0
  31. package/src/lib/locales/it.json +49 -0
  32. package/src/lib/locales/ja.json +49 -0
  33. package/src/lib/locales/ko.json +49 -0
  34. package/src/lib/locales/pl.json +49 -0
  35. package/src/lib/locales/pt-BR.json +49 -0
  36. package/src/lib/locales/ru.json +49 -0
  37. package/src/lib/locales/tr.json +49 -0
  38. package/src/lib/locales/zh-Hans.json +49 -0
  39. package/src/lib/locales/zh-Hant.json +49 -0
  40. package/src/lib/react/components/burn-in-hint.tsx +4 -1
  41. package/src/lib/react/components/chrome.tsx +9 -0
  42. package/src/lib/react/components/control-bar.tsx +15 -26
  43. package/src/lib/react/components/errors.tsx +11 -9
  44. package/src/lib/react/components/overlay.tsx +18 -5
  45. package/src/lib/react/components/playback-slider.tsx +4 -1
  46. package/src/lib/react/components/settings.tsx +23 -31
  47. package/src/lib/react/components/skip-chapter.tsx +5 -2
  48. package/src/lib/react/components/sound.tsx +5 -2
  49. package/src/lib/react/components/subtitles.tsx +7 -4
  50. package/src/lib/react/components/track-menu.tsx +8 -4
  51. package/src/lib/react/components/volume-slider.tsx +3 -1
  52. package/src/lib/react/hooks/use-playback.ts +12 -2
  53. package/src/lib/react/labels.tsx +125 -0
  54. package/src/lib/react/video-player.tsx +14 -1
  55. package/src/lib/utils/track-label.ts +16 -11
@@ -0,0 +1,49 @@
1
+ {
2
+ "(Default)": "(Normalna)",
3
+ "Audio": "Dźwięk",
4
+ "Copied": "Skopiowano",
5
+ "Copy": "Kopiuj",
6
+ "Copy the errors": "Kopiuj błędy",
7
+ "Could not switch. Try again.": "Nie udało się przełączyć. Spróbuj ponownie.",
8
+ "Disable": "Wyłączone",
9
+ "Exit full screen (f)": "Zamknij pełny ekran (f)",
10
+ "Exit picture in picture": "Zamknij obraz w obrazie",
11
+ "Full screen": "Pełny ekran",
12
+ "Full screen (f)": "Pełny ekran (f)",
13
+ "Mute": "Wycisz",
14
+ "Mute (m)": "Wycisz (m)",
15
+ "Normalize volume": "Wyrównaj głośność",
16
+ "Now click your browser's pop out button": "Teraz kliknij przycisk obrazu w obrazie w przeglądarce",
17
+ "Pause": "Wstrzymaj",
18
+ "Pause (k)": "Wstrzymaj (k)",
19
+ "Picture in picture": "Obraz w obrazie",
20
+ "Play": "Odtwórz",
21
+ "Play (k)": "Odtwórz (k)",
22
+ "Playback errors ({count})": "Błędy odtwarzania ({count})",
23
+ "Playback failed": "Nie udało się odtworzyć",
24
+ "Playback speed": "Szybkość",
25
+ "Put the subtitles in the picture": "Wtop napisy w obraz",
26
+ "Put the subtitles in the video": "Wtop napisy w wideo",
27
+ "Quality": "Jakość",
28
+ "Reading the video file failed": "Nie udało się odczytać pliku wideo",
29
+ "Replay": "Odtwórz ponownie",
30
+ "Replay (k)": "Odtwórz ponownie (k)",
31
+ "Settings": "Ustawienia",
32
+ "Skip Ending": "Pomiń napisy końcowe",
33
+ "Skip Opening": "Pomiń czołówkę",
34
+ "Subtitles": "Napisy",
35
+ "Subtitles are in the picture": "Napisy są w obrazie",
36
+ "The MediaSource closed before a SourceBuffer could be created": "MediaSource zamknął się, zanim udało się utworzyć SourceBuffer",
37
+ "The MediaSource never opened": "MediaSource nigdy się nie otworzył",
38
+ "The browser rejected a media segment": "Przeglądarka odrzuciła segment multimedialny",
39
+ "The video codec in this file could not be identified": "Nie udało się rozpoznać kodeka wideo tego pliku",
40
+ "This browser cannot play the codecs in this file: {codecs}": "Ta przeglądarka nie może odtworzyć kodeków tego pliku: {codecs}",
41
+ "This file has no subtitles": "Ten plik nie ma napisów",
42
+ "Track {number}": "Ścieżka {number}",
43
+ "Unavailable": "Niedostępne",
44
+ "Unmute (m)": "Wyłącz wyciszenie (m)",
45
+ "at {time}": "w {time}",
46
+ "recovered": "naprawiono",
47
+ "{rate}x": "{rate}x",
48
+ "{start} to {end}": "od {start} do {end}"
49
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "(Default)": "(Normal)",
3
+ "Audio": "Áudio",
4
+ "Copied": "Copiado",
5
+ "Copy": "Copiar",
6
+ "Copy the errors": "Copiar os erros",
7
+ "Could not switch. Try again.": "Não foi possível trocar. Tente de novo.",
8
+ "Disable": "Desativadas",
9
+ "Exit full screen (f)": "Sair da tela cheia (f)",
10
+ "Exit picture in picture": "Sair do picture-in-picture",
11
+ "Full screen": "Tela cheia",
12
+ "Full screen (f)": "Tela cheia (f)",
13
+ "Mute": "Desativar som",
14
+ "Mute (m)": "Desativar som (m)",
15
+ "Normalize volume": "Normalizar volume",
16
+ "Now click your browser's pop out button": "Agora clique no botão de picture-in-picture do seu navegador",
17
+ "Pause": "Pausar",
18
+ "Pause (k)": "Pausar (k)",
19
+ "Picture in picture": "Picture-in-picture",
20
+ "Play": "Reproduzir",
21
+ "Play (k)": "Reproduzir (k)",
22
+ "Playback errors ({count})": "Erros de reprodução ({count})",
23
+ "Playback failed": "Falha na reprodução",
24
+ "Playback speed": "Velocidade",
25
+ "Put the subtitles in the picture": "Colocar as legendas na imagem",
26
+ "Put the subtitles in the video": "Colocar as legendas no vídeo",
27
+ "Quality": "Qualidade",
28
+ "Reading the video file failed": "Não foi possível ler o arquivo de vídeo",
29
+ "Replay": "Assistir de novo",
30
+ "Replay (k)": "Assistir de novo (k)",
31
+ "Settings": "Configurações",
32
+ "Skip Ending": "Pular encerramento",
33
+ "Skip Opening": "Pular abertura",
34
+ "Subtitles": "Legendas",
35
+ "Subtitles are in the picture": "As legendas estão na imagem",
36
+ "The MediaSource closed before a SourceBuffer could be created": "O MediaSource fechou antes que um SourceBuffer pudesse ser criado",
37
+ "The MediaSource never opened": "O MediaSource nunca abriu",
38
+ "The browser rejected a media segment": "O navegador rejeitou um segmento de mídia",
39
+ "The video codec in this file could not be identified": "Não foi possível identificar o codec de vídeo deste arquivo",
40
+ "This browser cannot play the codecs in this file: {codecs}": "Este navegador não consegue reproduzir os codecs deste arquivo: {codecs}",
41
+ "This file has no subtitles": "Este arquivo não tem legendas",
42
+ "Track {number}": "Faixa {number}",
43
+ "Unavailable": "Indisponível",
44
+ "Unmute (m)": "Ativar som (m)",
45
+ "at {time}": "em {time}",
46
+ "recovered": "recuperado",
47
+ "{rate}x": "{rate}x",
48
+ "{start} to {end}": "de {start} a {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
+ }
@@ -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'>Now click your browser&apos;s pop out button</div>
84
+ <div className='text'>{format(LABELS.burnInHint)}</div>
82
85
  <div className='arrow' aria-hidden='true'>&rarr;</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 ? 'Replay' : paused ? 'Play' : 'Pause'}
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='Picture in picture'
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 ? 'Exit picture in picture' : 'Picture in picture'}</span>
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 ? 'Put the subtitles in the video' : 'Picture in picture'}
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
- ? 'Picture in picture'
430
+ {format(!burnIn
431
+ ? LABELS.pictureInPicture
437
432
  : !hasSubtitles
438
- ? 'This file has no subtitles'
433
+ ? LABELS.noSubtitles
439
434
  : burnedInSubtitles
440
- ? 'Subtitles are in the picture'
441
- : 'Put the subtitles in the picture'}
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='Full screen'
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 = `Playback errors (${countErrors(errors)})`
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='Copy the errors'>
190
+ <button className='copy' type='button' onClick={copy} aria-label={format(LABELS.copyErrors)}>
188
191
  {copied ? <Check /> : <Copy />}
189
- <span>{copied ? 'Copied' : 'Copy'}</span>
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 ? ` to ${clock(entry.lastAt)}` : ''}
198
- {mediaTime(entry.atMediaTime) ? ` at ${mediaTime(entry.atMediaTime)}` : ''}
199
- {entry.recovered ? ' 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 errorMessage = (error: unknown) =>
106
- error instanceof Error
107
- ? error.message
108
- : typeof error === 'string' ? error : 'Playback failed'
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
- {roundedRate.toFixed(2)}x
127
+ {format(LABELS.speed, { rate: number(roundedRate, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) })}
125
128
  </div>
126
129
  <div
127
130
  className="playback-slider"