@mattebox/player 0.11.0 → 0.12.0

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 (334) hide show
  1. package/dist/announcer.d.ts +6 -3
  2. package/dist/announcer.d.ts.map +1 -1
  3. package/dist/announcer.js +17 -14
  4. package/dist/announcer.js.map +1 -1
  5. package/dist/cdn/mattebox-player.min.js +3 -3
  6. package/dist/controls/airplay.js +1 -2
  7. package/dist/controls/chapters.js +1 -2
  8. package/dist/controls/cues.js +1 -2
  9. package/dist/controls/fullscreen.js +1 -2
  10. package/dist/controls/icons.js +1 -2
  11. package/dist/controls/markers.d.ts +2 -15
  12. package/dist/controls/markers.d.ts.map +1 -1
  13. package/dist/controls/markers.js +1 -2
  14. package/dist/controls/markers.js.map +1 -1
  15. package/dist/controls/menu.js +1 -2
  16. package/dist/controls/native-tracks.js +1 -2
  17. package/dist/controls/pip.js +1 -2
  18. package/dist/controls/quality-names.js +1 -2
  19. package/dist/controls/ranges.js +1 -2
  20. package/dist/controls/session.js +1 -2
  21. package/dist/controls/slider.js +1 -2
  22. package/dist/controls/time.js +1 -2
  23. package/dist/controls/track-names.d.ts +3 -2
  24. package/dist/controls/track-names.d.ts.map +1 -1
  25. package/dist/controls/track-names.js +5 -5
  26. package/dist/controls/track-names.js.map +1 -1
  27. package/dist/dom.js +1 -2
  28. package/dist/element-entry.d.ts +4 -1
  29. package/dist/element-entry.d.ts.map +1 -1
  30. package/dist/element-entry.js +1 -2
  31. package/dist/element-entry.js.map +1 -1
  32. package/dist/element.d.ts +90 -6
  33. package/dist/element.d.ts.map +1 -1
  34. package/dist/element.js +212 -30
  35. package/dist/element.js.map +1 -1
  36. package/dist/elements/airplay-button.js +2 -3
  37. package/dist/elements/airplay-button.js.map +1 -1
  38. package/dist/elements/audio-menu.d.ts +3 -2
  39. package/dist/elements/audio-menu.d.ts.map +1 -1
  40. package/dist/elements/audio-menu.js +18 -12
  41. package/dist/elements/audio-menu.js.map +1 -1
  42. package/dist/elements/chapters-menu.d.ts +2 -1
  43. package/dist/elements/chapters-menu.d.ts.map +1 -1
  44. package/dist/elements/chapters-menu.js +2 -3
  45. package/dist/elements/chapters-menu.js.map +1 -1
  46. package/dist/elements/component.d.ts +9 -0
  47. package/dist/elements/component.d.ts.map +1 -1
  48. package/dist/elements/component.js +16 -2
  49. package/dist/elements/component.js.map +1 -1
  50. package/dist/elements/control-bar.js +1 -2
  51. package/dist/elements/current-time.js +1 -2
  52. package/dist/elements/drm-badge.js +4 -5
  53. package/dist/elements/drm-badge.js.map +1 -1
  54. package/dist/elements/duration.js +1 -2
  55. package/dist/elements/error-screen.d.ts +9 -0
  56. package/dist/elements/error-screen.d.ts.map +1 -1
  57. package/dist/elements/error-screen.js +54 -12
  58. package/dist/elements/error-screen.js.map +1 -1
  59. package/dist/elements/fullscreen-button.js +2 -3
  60. package/dist/elements/fullscreen-button.js.map +1 -1
  61. package/dist/elements/live-button.js +3 -4
  62. package/dist/elements/live-button.js.map +1 -1
  63. package/dist/elements/marker-button.d.ts.map +1 -1
  64. package/dist/elements/marker-button.js +7 -6
  65. package/dist/elements/marker-button.js.map +1 -1
  66. package/dist/elements/menu-element.d.ts +3 -2
  67. package/dist/elements/menu-element.d.ts.map +1 -1
  68. package/dist/elements/menu-element.js +3 -4
  69. package/dist/elements/menu-element.js.map +1 -1
  70. package/dist/elements/mute-button.js +2 -3
  71. package/dist/elements/mute-button.js.map +1 -1
  72. package/dist/elements/pip-button.js +2 -3
  73. package/dist/elements/pip-button.js.map +1 -1
  74. package/dist/elements/play-button.js +2 -3
  75. package/dist/elements/play-button.js.map +1 -1
  76. package/dist/elements/quality-menu.d.ts +2 -1
  77. package/dist/elements/quality-menu.d.ts.map +1 -1
  78. package/dist/elements/quality-menu.js +3 -4
  79. package/dist/elements/quality-menu.js.map +1 -1
  80. package/dist/elements/remaining-time.js +1 -2
  81. package/dist/elements/scan-button.d.ts.map +1 -1
  82. package/dist/elements/scan-button.js +2 -3
  83. package/dist/elements/scan-button.js.map +1 -1
  84. package/dist/elements/seek-bar.d.ts +2 -0
  85. package/dist/elements/seek-bar.d.ts.map +1 -1
  86. package/dist/elements/seek-bar.js +10 -7
  87. package/dist/elements/seek-bar.js.map +1 -1
  88. package/dist/elements/shared.js +1 -2
  89. package/dist/elements/skip-button.d.ts.map +1 -1
  90. package/dist/elements/skip-button.js +2 -3
  91. package/dist/elements/skip-button.js.map +1 -1
  92. package/dist/elements/spacer.js +1 -2
  93. package/dist/elements/speed-menu.d.ts +2 -1
  94. package/dist/elements/speed-menu.d.ts.map +1 -1
  95. package/dist/elements/speed-menu.js +3 -4
  96. package/dist/elements/speed-menu.js.map +1 -1
  97. package/dist/elements/spinner.d.ts +1 -1
  98. package/dist/elements/spinner.js +2 -4
  99. package/dist/elements/spinner.js.map +1 -1
  100. package/dist/elements/start-button.d.ts.map +1 -1
  101. package/dist/elements/start-button.js +2 -4
  102. package/dist/elements/start-button.js.map +1 -1
  103. package/dist/elements/subtitles-menu.d.ts +2 -1
  104. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  105. package/dist/elements/subtitles-menu.js +51 -22
  106. package/dist/elements/subtitles-menu.js.map +1 -1
  107. package/dist/elements/time-element.js +1 -2
  108. package/dist/elements/title.d.ts.map +1 -1
  109. package/dist/elements/title.js +11 -5
  110. package/dist/elements/title.js.map +1 -1
  111. package/dist/elements/video-menu.d.ts +2 -1
  112. package/dist/elements/video-menu.d.ts.map +1 -1
  113. package/dist/elements/video-menu.js +12 -12
  114. package/dist/elements/video-menu.js.map +1 -1
  115. package/dist/elements/volume-slider.js +2 -3
  116. package/dist/elements/volume-slider.js.map +1 -1
  117. package/dist/elements/volume.js +1 -2
  118. package/dist/entries/airplay-button.js +1 -2
  119. package/dist/entries/audio-menu.js +1 -2
  120. package/dist/entries/chapters-menu.js +1 -2
  121. package/dist/entries/control-bar.js +1 -2
  122. package/dist/entries/current-time.js +1 -2
  123. package/dist/entries/drm-badge.js +1 -2
  124. package/dist/entries/duration.js +1 -2
  125. package/dist/entries/error-screen.js +1 -2
  126. package/dist/entries/fullscreen-button.js +1 -2
  127. package/dist/entries/live-button.js +1 -2
  128. package/dist/entries/marker-button.js +1 -2
  129. package/dist/entries/mute-button.js +1 -2
  130. package/dist/entries/pip-button.js +1 -2
  131. package/dist/entries/play-button.js +1 -2
  132. package/dist/entries/quality-menu.js +1 -2
  133. package/dist/entries/remaining-time.js +1 -2
  134. package/dist/entries/scan-button.js +1 -2
  135. package/dist/entries/seek-bar.js +1 -2
  136. package/dist/entries/skip-button.js +1 -2
  137. package/dist/entries/spacer.js +1 -2
  138. package/dist/entries/speed-menu.js +1 -2
  139. package/dist/entries/spinner.js +1 -2
  140. package/dist/entries/start-button.js +1 -2
  141. package/dist/entries/subtitles-menu.js +1 -2
  142. package/dist/entries/title.js +1 -2
  143. package/dist/entries/video-menu.js +1 -2
  144. package/dist/entries/volume-slider.js +1 -2
  145. package/dist/entries/volume.js +1 -2
  146. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/asyncToGenerator.js +1 -2
  147. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/defineProperty.js +1 -2
  148. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/objectSpread2.js +1 -2
  149. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPrimitive.js +1 -2
  150. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPropertyKey.js +1 -2
  151. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/typeof.js +1 -2
  152. package/dist/es2015/announcer.js +18 -15
  153. package/dist/es2015/controls/airplay.js +1 -2
  154. package/dist/es2015/controls/chapters.js +2 -3
  155. package/dist/es2015/controls/cues.js +1 -2
  156. package/dist/es2015/controls/fullscreen.js +1 -2
  157. package/dist/es2015/controls/icons.js +1 -2
  158. package/dist/es2015/controls/markers.js +1 -2
  159. package/dist/es2015/controls/menu.js +2 -3
  160. package/dist/es2015/controls/native-tracks.js +1 -2
  161. package/dist/es2015/controls/pip.js +1 -2
  162. package/dist/es2015/controls/quality-names.js +1 -2
  163. package/dist/es2015/controls/ranges.js +1 -2
  164. package/dist/es2015/controls/session.js +1 -2
  165. package/dist/es2015/controls/slider.js +1 -2
  166. package/dist/es2015/controls/time.js +1 -2
  167. package/dist/es2015/controls/track-names.js +5 -5
  168. package/dist/es2015/dom.js +1 -2
  169. package/dist/es2015/element-entry.js +1 -2
  170. package/dist/es2015/element.js +227 -37
  171. package/dist/es2015/elements/airplay-button.js +2 -4
  172. package/dist/es2015/elements/audio-menu.js +18 -16
  173. package/dist/es2015/elements/chapters-menu.js +2 -3
  174. package/dist/es2015/elements/component.js +18 -2
  175. package/dist/es2015/elements/control-bar.js +1 -2
  176. package/dist/es2015/elements/current-time.js +1 -2
  177. package/dist/es2015/elements/drm-badge.js +5 -7
  178. package/dist/es2015/elements/duration.js +1 -2
  179. package/dist/es2015/elements/error-screen.js +56 -13
  180. package/dist/es2015/elements/fullscreen-button.js +2 -4
  181. package/dist/es2015/elements/live-button.js +3 -5
  182. package/dist/es2015/elements/marker-button.js +8 -7
  183. package/dist/es2015/elements/menu-element.js +3 -8
  184. package/dist/es2015/elements/mute-button.js +3 -4
  185. package/dist/es2015/elements/pip-button.js +2 -4
  186. package/dist/es2015/elements/play-button.js +2 -4
  187. package/dist/es2015/elements/quality-menu.js +4 -5
  188. package/dist/es2015/elements/remaining-time.js +1 -2
  189. package/dist/es2015/elements/scan-button.js +3 -4
  190. package/dist/es2015/elements/seek-bar.js +12 -11
  191. package/dist/es2015/elements/shared.js +1 -2
  192. package/dist/es2015/elements/skip-button.js +2 -4
  193. package/dist/es2015/elements/spacer.js +1 -2
  194. package/dist/es2015/elements/speed-menu.js +4 -5
  195. package/dist/es2015/elements/spinner.js +2 -5
  196. package/dist/es2015/elements/start-button.js +3 -5
  197. package/dist/es2015/elements/subtitles-menu.js +53 -31
  198. package/dist/es2015/elements/time-element.js +1 -2
  199. package/dist/es2015/elements/title.js +12 -6
  200. package/dist/es2015/elements/video-menu.js +12 -12
  201. package/dist/es2015/elements/volume-slider.js +3 -4
  202. package/dist/es2015/elements/volume.js +1 -2
  203. package/dist/es2015/entries/airplay-button.js +1 -2
  204. package/dist/es2015/entries/audio-menu.js +1 -2
  205. package/dist/es2015/entries/chapters-menu.js +1 -2
  206. package/dist/es2015/entries/control-bar.js +1 -2
  207. package/dist/es2015/entries/current-time.js +1 -2
  208. package/dist/es2015/entries/drm-badge.js +1 -2
  209. package/dist/es2015/entries/duration.js +1 -2
  210. package/dist/es2015/entries/error-screen.js +1 -2
  211. package/dist/es2015/entries/fullscreen-button.js +1 -2
  212. package/dist/es2015/entries/live-button.js +1 -2
  213. package/dist/es2015/entries/marker-button.js +1 -2
  214. package/dist/es2015/entries/mute-button.js +1 -2
  215. package/dist/es2015/entries/pip-button.js +1 -2
  216. package/dist/es2015/entries/play-button.js +1 -2
  217. package/dist/es2015/entries/quality-menu.js +1 -2
  218. package/dist/es2015/entries/remaining-time.js +1 -2
  219. package/dist/es2015/entries/scan-button.js +1 -2
  220. package/dist/es2015/entries/seek-bar.js +1 -2
  221. package/dist/es2015/entries/skip-button.js +1 -2
  222. package/dist/es2015/entries/spacer.js +1 -2
  223. package/dist/es2015/entries/speed-menu.js +1 -2
  224. package/dist/es2015/entries/spinner.js +1 -2
  225. package/dist/es2015/entries/start-button.js +1 -2
  226. package/dist/es2015/entries/subtitles-menu.js +1 -2
  227. package/dist/es2015/entries/title.js +1 -2
  228. package/dist/es2015/entries/video-menu.js +1 -2
  229. package/dist/es2015/entries/volume-slider.js +1 -2
  230. package/dist/es2015/entries/volume.js +1 -2
  231. package/dist/es2015/host.js +1 -2
  232. package/dist/es2015/ids.js +33 -0
  233. package/dist/es2015/index.js +2 -1
  234. package/dist/es2015/labels.js +1 -2
  235. package/dist/es2015/locales/ar.js +75 -0
  236. package/dist/es2015/locales/ca.js +75 -0
  237. package/dist/es2015/locales/de.js +75 -0
  238. package/dist/es2015/locales/es.js +75 -0
  239. package/dist/es2015/locales/fr.js +75 -0
  240. package/dist/es2015/locales/hi.js +75 -0
  241. package/dist/es2015/locales/it.js +75 -0
  242. package/dist/es2015/locales/ja.js +75 -0
  243. package/dist/es2015/locales/ko.js +75 -0
  244. package/dist/es2015/locales/pt.js +75 -0
  245. package/dist/es2015/locales/zh.js +75 -0
  246. package/dist/es2015/locales.js +61 -0
  247. package/dist/es2015/namespaces.js +1 -2
  248. package/dist/es2015/presets.js +2 -3
  249. package/dist/es2015/style.js +1 -2
  250. package/dist/es2015/surface.js +12 -4
  251. package/dist/es2015/tags.js +1 -2
  252. package/dist/es2015/text.js +15 -0
  253. package/dist/es2015/trackers.js +43 -0
  254. package/dist/es2015/video-sources.js +2 -3
  255. package/dist/host.d.ts +40 -1
  256. package/dist/host.d.ts.map +1 -1
  257. package/dist/host.js +1 -2
  258. package/dist/host.js.map +1 -1
  259. package/dist/ids.d.ts +19 -0
  260. package/dist/ids.d.ts.map +1 -0
  261. package/dist/ids.js +34 -0
  262. package/dist/ids.js.map +1 -0
  263. package/dist/index.d.ts +8 -1
  264. package/dist/index.d.ts.map +1 -1
  265. package/dist/index.js +2 -1
  266. package/dist/labels.js +1 -2
  267. package/dist/locales/ar.d.ts +75 -0
  268. package/dist/locales/ar.d.ts.map +1 -0
  269. package/dist/locales/ar.js +77 -0
  270. package/dist/locales/ar.js.map +1 -0
  271. package/dist/locales/ca.d.ts +75 -0
  272. package/dist/locales/ca.d.ts.map +1 -0
  273. package/dist/locales/ca.js +77 -0
  274. package/dist/locales/ca.js.map +1 -0
  275. package/dist/locales/de.d.ts +75 -0
  276. package/dist/locales/de.d.ts.map +1 -0
  277. package/dist/locales/de.js +77 -0
  278. package/dist/locales/de.js.map +1 -0
  279. package/dist/locales/es.d.ts +75 -0
  280. package/dist/locales/es.d.ts.map +1 -0
  281. package/dist/locales/es.js +77 -0
  282. package/dist/locales/es.js.map +1 -0
  283. package/dist/locales/fr.d.ts +75 -0
  284. package/dist/locales/fr.d.ts.map +1 -0
  285. package/dist/locales/fr.js +77 -0
  286. package/dist/locales/fr.js.map +1 -0
  287. package/dist/locales/hi.d.ts +75 -0
  288. package/dist/locales/hi.d.ts.map +1 -0
  289. package/dist/locales/hi.js +77 -0
  290. package/dist/locales/hi.js.map +1 -0
  291. package/dist/locales/it.d.ts +75 -0
  292. package/dist/locales/it.d.ts.map +1 -0
  293. package/dist/locales/it.js +77 -0
  294. package/dist/locales/it.js.map +1 -0
  295. package/dist/locales/ja.d.ts +75 -0
  296. package/dist/locales/ja.d.ts.map +1 -0
  297. package/dist/locales/ja.js +77 -0
  298. package/dist/locales/ja.js.map +1 -0
  299. package/dist/locales/ko.d.ts +75 -0
  300. package/dist/locales/ko.d.ts.map +1 -0
  301. package/dist/locales/ko.js +77 -0
  302. package/dist/locales/ko.js.map +1 -0
  303. package/dist/locales/pt.d.ts +75 -0
  304. package/dist/locales/pt.d.ts.map +1 -0
  305. package/dist/locales/pt.js +77 -0
  306. package/dist/locales/pt.js.map +1 -0
  307. package/dist/locales/zh.d.ts +75 -0
  308. package/dist/locales/zh.d.ts.map +1 -0
  309. package/dist/locales/zh.js +77 -0
  310. package/dist/locales/zh.js.map +1 -0
  311. package/dist/locales.d.ts +27 -0
  312. package/dist/locales.d.ts.map +1 -0
  313. package/dist/locales.js +48 -0
  314. package/dist/locales.js.map +1 -0
  315. package/dist/messages.d.ts +167 -0
  316. package/dist/messages.d.ts.map +1 -0
  317. package/dist/namespaces.js +1 -2
  318. package/dist/presets.js +1 -2
  319. package/dist/style.js +1 -2
  320. package/dist/surface.d.ts +4 -1
  321. package/dist/surface.d.ts.map +1 -1
  322. package/dist/surface.js +12 -4
  323. package/dist/surface.js.map +1 -1
  324. package/dist/tags.js +1 -2
  325. package/dist/text.d.ts +14 -0
  326. package/dist/text.d.ts.map +1 -0
  327. package/dist/text.js +16 -0
  328. package/dist/text.js.map +1 -0
  329. package/dist/trackers.d.ts +18 -0
  330. package/dist/trackers.d.ts.map +1 -0
  331. package/dist/trackers.js +45 -0
  332. package/dist/trackers.js.map +1 -0
  333. package/dist/video-sources.js +1 -2
  334. package/package.json +11 -3
@@ -1,16 +1,19 @@
1
1
  import { announcer } from "./announcer.js";
2
2
  import { createMarkers } from "./controls/markers.js";
3
3
  import { languageName } from "./controls/track-names.js";
4
+ import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/asyncToGenerator.js";
5
+ import { addLocale, load, onLocales, registered, wordsNow } from "./locales.js";
4
6
  import { namespaces } from "./namespaces.js";
5
- import _asyncToGenerator from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/asyncToGenerator.js";
6
7
  import { drmGuard, resolvePreset } from "./presets.js";
7
8
  import { STYLE } from "./style.js";
8
9
  import { errorSurface } from "./surface.js";
9
10
  import { PLAYER } from "./tags.js";
10
- import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/objectSpread2.js";
11
+ import { textIn } from "./text.js";
12
+ import { createTrackers } from "./trackers.js";
13
+ import _objectSpread2 from "./_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/objectSpread2.js";
11
14
  import { chosen, holdFrame, markupVideoTracks, onNextFrame, restore, resume, versionSource } from "./video-sources.js";
12
15
  import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
13
- //#region src/element.ts
16
+ // src/element.ts
14
17
  /**
15
18
  * `off` keeps HLS on the engine in Safari. Anything else lets Safari play
16
19
  * HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's
@@ -25,6 +28,8 @@ const FORWARDED = [
25
28
  "crossorigin"
26
29
  ];
27
30
  const LICENSE_URL = "license-url";
31
+ /** The language the page chose, over the nearest `lang`. */
32
+ const LANGUAGE = "language";
28
33
  /** Carried through a switch: the play state from before it, `playing` or `paused`. */
29
34
  const SWITCHING = "switching";
30
35
  /** Whether the browser has EME, so a source may bring DRM. */
@@ -103,7 +108,6 @@ const STATE_EVENTS = [
103
108
  "resize",
104
109
  "playing",
105
110
  "waiting",
106
- "stalled",
107
111
  "canplay"
108
112
  ];
109
113
  /**
@@ -111,10 +115,10 @@ const STATE_EVENTS = [
111
115
  * seek within the buffer waits for less, and saying it would only be noise.
112
116
  */
113
117
  const LOADING_MS = 1e3;
114
- /** A track's name for the live region: its name in the stream, else its language's. */
115
- function trackName(name, lang) {
118
+ /** A track's name for the live region: its name in the stream, else its language's in `locale`. */
119
+ function trackName(name, lang, locale) {
116
120
  var _languageName;
117
- return name || lang && ((_languageName = languageName(lang)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
121
+ return name || lang && ((_languageName = languageName(lang, locale || void 0)) !== null && _languageName !== void 0 ? _languageName : lang) || "";
118
122
  }
119
123
  /** The stages that register a key system, which a native session's DRM offers. */
120
124
  const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
@@ -140,10 +144,22 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
140
144
  CONTROLS,
141
145
  CHAPTERS,
142
146
  PLAYSINLINE,
143
- LAYOUT
147
+ LAYOUT,
148
+ LANGUAGE,
149
+ "lang"
144
150
  ];
145
151
  }
146
152
  /**
153
+ * Registers the words of a language for every player on the page. Each
154
+ * source is a set of words or a function that loads one, which runs only
155
+ * when a player shows that language. Later sources go over earlier ones,
156
+ * so a page changes a shipped word by registering its own after it.
157
+ * Players that show the language take the new words at once.
158
+ */
159
+ static addLocale(language, ...sources) {
160
+ addLocale(language, sources);
161
+ }
162
+ /**
147
163
  * Registers the element once, and records the stages markup-only pages
148
164
  * get. The controls register through their own entries, the package's
149
165
  * root entry importing every one; a control connected before its player
@@ -164,6 +180,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
164
180
  this.core = null;
165
181
  this.current = null;
166
182
  this.failure = null;
183
+ this.stop = null;
167
184
  this.reflecting = false;
168
185
  this.sizes = null;
169
186
  this.fixed = false;
@@ -172,11 +189,15 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
172
189
  this.offs = [];
173
190
  this.queue = Promise.resolve();
174
191
  this.pending = false;
175
- this.programme = null;
192
+ this.original = null;
176
193
  this.version = null;
177
194
  this.switching = false;
178
195
  this.switched = null;
179
196
  this.held = null;
197
+ this.words = {};
198
+ this.shown = "";
199
+ this.wordsEpoch = 0;
200
+ this.unwatch = null;
180
201
  this.slow = void 0;
181
202
  this.heardAudio = void 0;
182
203
  this.heardText = void 0;
@@ -196,8 +217,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
196
217
  });
197
218
  this.media.addEventListener("playing", () => {
198
219
  this.failure = null;
220
+ this.reflect();
199
221
  });
200
222
  this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
223
+ this.tracking = createTrackers(this, () => this.emit("trackerschange", this.tracking.list));
201
224
  this.stage = document.createElement("div");
202
225
  this.stage.setAttribute("part", "stage");
203
226
  const slot = document.createElement("slot");
@@ -207,8 +230,11 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
207
230
  this.stage.append(slot);
208
231
  this.surface = errorSurface(() => {
209
232
  this.retry();
233
+ }, () => {
234
+ var _this$words$retry;
235
+ return (_this$words$retry = this.words.retry) !== null && _this$words$retry !== void 0 ? _this$words$retry : "Retry";
210
236
  });
211
- this.voice = announcer(this);
237
+ this.voice = announcer(this, (id) => this.words[id]);
212
238
  const root = this.attachShadow({ mode: "open" });
213
239
  const style = document.createElement("style");
214
240
  style.textContent = STYLE;
@@ -233,9 +259,73 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
233
259
  set sources(value) {
234
260
  this.list = value;
235
261
  if (this.marks.list.length > 0) this.marks.set([]);
262
+ this.unblock();
236
263
  this.reload();
237
264
  }
238
265
  /**
266
+ * The language the page chose for this player, which wins over the
267
+ * nearest `lang` attribute. Empty follows `lang`. Setting it changes the
268
+ * words of every control at once.
269
+ */
270
+ get language() {
271
+ var _this$getAttribute;
272
+ return (_this$getAttribute = this.getAttribute(LANGUAGE)) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "";
273
+ }
274
+ set language(value) {
275
+ if (value === "") this.removeAttribute(LANGUAGE);
276
+ else this.setAttribute(LANGUAGE, value);
277
+ }
278
+ /** The language tag the words come from: `language`, else the nearest `lang`. Empty without either. */
279
+ get locale() {
280
+ return this.shown;
281
+ }
282
+ /** The word of `id` in the player's language, or undefined, where the control's English applies. */
283
+ message(id) {
284
+ return this.words[id];
285
+ }
286
+ /** Follows registrations and the document's `lang` until disconnect. */
287
+ watchLanguage() {
288
+ const off = onLocales(() => {
289
+ this.relocale();
290
+ });
291
+ const watch = new MutationObserver(() => {
292
+ this.relocale();
293
+ });
294
+ watch.observe(document.documentElement, {
295
+ attributes: true,
296
+ attributeFilter: ["lang"]
297
+ });
298
+ this.unwatch = () => {
299
+ off();
300
+ watch.disconnect();
301
+ };
302
+ this.relocale();
303
+ }
304
+ /** Resolves the language, takes its words, and tells the controls with `localechange`. */
305
+ relocale() {
306
+ var _ref, _this$getAttribute2, _this$closest;
307
+ const tag = (_ref = (_this$getAttribute2 = this.getAttribute(LANGUAGE)) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : (_this$closest = this.closest("[lang]")) === null || _this$closest === void 0 ? void 0 : _this$closest.getAttribute("lang")) !== null && _ref !== void 0 ? _ref : "";
308
+ const epoch = ++this.wordsEpoch;
309
+ const take = (words) => {
310
+ if (epoch !== this.wordsEpoch) return;
311
+ this.shown = tag;
312
+ this.words = words;
313
+ this.showBlock();
314
+ this.emit("localechange", tag);
315
+ };
316
+ const key = registered(tag);
317
+ if (key === null) {
318
+ take({});
319
+ return;
320
+ }
321
+ const now = wordsNow(key);
322
+ if (now !== null) {
323
+ take(now);
324
+ return;
325
+ }
326
+ load(key).then(take, () => void 0);
327
+ }
328
+ /**
239
329
  * Loads the sources again, in the order a load reads them: the `src`
240
330
  * attribute, the `sources` property, then the `<source>` children. The
241
331
  * error screens' Retry calls it. On a version of `videoSources`, it
@@ -263,7 +353,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
263
353
  const had = chosen((_this$current$engine = (_this$current = this.current) === null || _this$current === void 0 ? void 0 : _this$current.engine) !== null && _this$current$engine !== void 0 ? _this$current$engine : null);
264
354
  const clean = emeAvailable() ? source : withoutDrm(source);
265
355
  const was = this.version;
266
- this.programme = clean;
356
+ this.original = clean;
267
357
  this.switched = clean;
268
358
  this.version = null;
269
359
  if (was !== null) this.emit("videosourcechange", null);
@@ -271,8 +361,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
271
361
  }
272
362
  /** The other versions of the picture the source names at their own URLs, for the video menu. */
273
363
  get videoSources() {
274
- var _this$programme$video, _this$programme;
275
- return (_this$programme$video = (_this$programme = this.programme) === null || _this$programme === void 0 ? void 0 : _this$programme.videoTracks) !== null && _this$programme$video !== void 0 ? _this$programme$video : [];
364
+ var _this$original$videoT, _this$original;
365
+ return (_this$original$videoT = (_this$original = this.original) === null || _this$original === void 0 ? void 0 : _this$original.videoTracks) !== null && _this$original$videoT !== void 0 ? _this$original$videoT : [];
276
366
  }
277
367
  /** The version of `videoSources` that plays, or null for the source itself. */
278
368
  get videoSource() {
@@ -286,7 +376,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
286
376
  */
287
377
  selectVideoSource(track) {
288
378
  var _programme$videoTrack, _this$current$engine2, _this$current2;
289
- const programme = this.programme;
379
+ const programme = this.original;
290
380
  if (programme === null || track === this.version) return;
291
381
  if (track !== null && ((_programme$videoTrack = programme.videoTracks) === null || _programme$videoTrack === void 0 ? void 0 : _programme$videoTrack.includes(track)) !== true) return;
292
382
  const media = this.media;
@@ -357,6 +447,83 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
357
447
  get error() {
358
448
  return this.failure;
359
449
  }
450
+ /**
451
+ * Shows why the programme does not play, in place of the video, and
452
+ * stops the load: the reason the page's content API gave, such as a
453
+ * geographic or an age restriction. The error screen shows the title,
454
+ * else "Not available", and the message, with no retry. Each text can
455
+ * be given by language tag, and follows the player's language. A new
456
+ * `src` or `sources` clears it. Fires `blockchange`.
457
+ */
458
+ block(block) {
459
+ this.refuse(block);
460
+ this.enqueue(() => this.teardown());
461
+ }
462
+ /** Shows the block, for `block()` and for a programme a connector blocked, which loaded nothing. */
463
+ refuse(block) {
464
+ this.stop = block;
465
+ this.media.pause();
466
+ clearTimeout(this.slow);
467
+ const [title, message] = this.blockWords(block);
468
+ if (this.querySelector("mbx-error-screen") === null) this.voice.tell(message === "" ? title : `${title}. ${message}`);
469
+ this.showBlock();
470
+ this.reflect();
471
+ this.emit("blockchange", block);
472
+ }
473
+ /** Removes the block. Nothing plays until a source loads: set one, or call `retry()`. */
474
+ unblock() {
475
+ if (this.stop === null) return;
476
+ this.stop = null;
477
+ this.surface.clear();
478
+ this.reflect();
479
+ this.emit("blockchange", null);
480
+ }
481
+ /** What `block()` set, or null. */
482
+ get blocked() {
483
+ return this.stop;
484
+ }
485
+ /**
486
+ * What the current load resolved to: the sources, and what a connector
487
+ * said of the programme. Null before a load and after an unload.
488
+ */
489
+ get programme() {
490
+ var _this$core$programme, _this$core;
491
+ return (_this$core$programme = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.programme) !== null && _this$core$programme !== void 0 ? _this$core$programme : null;
492
+ }
493
+ /**
494
+ * The page's trackers. Each starts at every programme and stops at its
495
+ * end; one added or removed during a programme starts or stops at once.
496
+ */
497
+ get trackers() {
498
+ return this.tracking;
499
+ }
500
+ /**
501
+ * Applies what the load resolved, before any session: the markers, the
502
+ * poster, the block. The page's own `poster` and markers set after the
503
+ * source win. Then the trackers start on the programme.
504
+ */
505
+ programmed(programme) {
506
+ const metadata = programme === null || programme === void 0 ? void 0 : programme.metadata;
507
+ if ((metadata === null || metadata === void 0 ? void 0 : metadata.markers) !== void 0) this.marks.set(metadata.markers);
508
+ if (!this.hasAttribute("poster")) {
509
+ if ((metadata === null || metadata === void 0 ? void 0 : metadata.poster) === void 0) this.media.removeAttribute("poster");
510
+ else this.media.poster = metadata.poster;
511
+ }
512
+ if ((programme === null || programme === void 0 ? void 0 : programme.block) !== void 0) this.refuse(programme.block);
513
+ this.emit("programmechange", programme);
514
+ this.tracking.begin(programme);
515
+ }
516
+ /** A block's title and message in the player's language: the title defaults to the `blocked` word. */
517
+ blockWords(block) {
518
+ var _this$words$blocked;
519
+ return [block.title === void 0 ? (_this$words$blocked = this.words.blocked) !== null && _this$words$blocked !== void 0 ? _this$words$blocked : "Not available" : textIn(block.title, this.shown), block.message === void 0 ? "" : textIn(block.message, this.shown)];
520
+ }
521
+ /** Puts the block on the row under the video, under native controls. */
522
+ showBlock() {
523
+ if (this.stop === null || this.getAttribute(CONTROLS) === "custom") return;
524
+ const [title, message] = this.blockWords(this.stop);
525
+ this.surface.inform(title, message);
526
+ }
360
527
  connectedCallback() {
361
528
  if (this.media.parentNode !== this) this.append(this.media);
362
529
  for (const name of FORWARDED) this.forward(name);
@@ -368,6 +535,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
368
535
  this.sizes.observe(this);
369
536
  }
370
537
  this.measure();
538
+ this.watchLanguage();
371
539
  this.reload();
372
540
  }
373
541
  /** Sets `layout` from the element's box, unless the page fixed it. */
@@ -389,7 +557,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
389
557
  if (!this.started) this.tracks();
390
558
  this.started = true;
391
559
  this.waiting = false;
392
- } else if (event === "waiting" || event === "stalled") this.waiting = true;
560
+ } else if (event === "waiting") this.waiting = true;
393
561
  else if (event === "canplay") this.waiting = false;
394
562
  else if (event === "emptied") {
395
563
  if (this.held === null) this.started = false;
@@ -400,12 +568,12 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
400
568
  }
401
569
  /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */
402
570
  tell(event, was) {
403
- if (event === "play" && this.held === null) this.voice.say("playing", "Playing");
404
- if (event === "pause" && !this.media.ended && this.held === null) this.voice.say("paused", "Paused");
571
+ if (event === "play" && this.held === null) this.voice.say("playing", "saidPlaying", "Playing");
572
+ if (event === "pause" && !this.media.ended && this.held === null) this.voice.say("paused", "saidPaused", "Paused");
405
573
  if (this.waiting === was) return;
406
574
  clearTimeout(this.slow);
407
575
  if (this.waiting) this.slow = setTimeout(() => {
408
- this.voice.say("loading", "Loading");
576
+ this.voice.say("loading", "loading", "Loading");
409
577
  }, LOADING_MS);
410
578
  }
411
579
  /**
@@ -421,24 +589,24 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
421
589
  if (engine !== null) {
422
590
  const sound = engine.tracks.active("audio");
423
591
  const words = engine.tracks.active("text");
424
- audio = sound === null ? "" : trackName(sound.name, sound.lang);
425
- text = words === null || words.forced === true ? null : trackName(words.name, words.lang);
592
+ audio = sound === null ? "" : trackName(sound.name, sound.lang, this.locale);
593
+ text = words === null || words.forced === true ? null : trackName(words.name, words.lang, this.locale);
426
594
  } else {
427
595
  var _video$audioTracks;
428
596
  const video = this.media;
429
597
  const sound = Array.from((_video$audioTracks = video.audioTracks) !== null && _video$audioTracks !== void 0 ? _video$audioTracks : []).find((track) => track.enabled);
430
598
  const words = Array.from(this.media.textTracks).find((track) => (track.kind === "subtitles" || track.kind === "captions") && track.mode === "showing");
431
- audio = sound === void 0 ? "" : trackName(sound.label, sound.language);
432
- text = words === void 0 ? null : trackName(words.label, words.language);
599
+ audio = sound === void 0 ? "" : trackName(sound.label, sound.language, this.locale);
600
+ text = words === void 0 ? null : trackName(words.label, words.language, this.locale);
433
601
  }
434
602
  const { heardAudio, heardText } = this;
435
603
  this.heardAudio = audio;
436
604
  this.heardText = text;
437
605
  if (!this.started) return;
438
- if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "Audio: {track}", audio);
606
+ if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "saidAudio", "Audio: {track}", audio);
439
607
  if (heardText !== void 0 && text !== heardText) {
440
- if (text === null) this.voice.say("subtitles-off", "Subtitles off");
441
- else this.voice.say("subtitles", "Subtitles: {track}", text);
608
+ if (text === null) this.voice.say("subtitles-off", "saidSubtitlesOff", "Subtitles off");
609
+ else this.voice.say("subtitles", "saidSubtitles", "Subtitles: {track}", text);
442
610
  }
443
611
  }
444
612
  /** The video's state on the element, for `mattebox-player[paused]` and the like. */
@@ -454,6 +622,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
454
622
  this.toggleAttribute("audio", this.audio());
455
623
  this.toggleAttribute("started", this.started);
456
624
  this.toggleAttribute("waiting", this.waiting);
625
+ this.toggleAttribute("error", this.failure !== null);
626
+ this.toggleAttribute("blocked", this.stop !== null);
457
627
  this.reflecting = false;
458
628
  }
459
629
  /**
@@ -464,20 +634,28 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
464
634
  * the start rather than from its metadata.
465
635
  */
466
636
  audio() {
467
- var _this$getAttribute;
637
+ var _this$getAttribute3;
468
638
  const video = this.media;
469
639
  if (video.readyState >= HTMLMediaElement.HAVE_METADATA) return video.videoWidth === 0 && video.videoHeight === 0;
470
640
  const src = this.getAttribute("src");
471
- const type = (_this$getAttribute = this.getAttribute("type")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : src === null ? void 0 : inferType(src);
641
+ const type = (_this$getAttribute3 = this.getAttribute("type")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : src === null ? void 0 : inferType(src);
472
642
  return (type === null || type === void 0 ? void 0 : type.startsWith("audio/")) === true;
473
643
  }
474
644
  disconnectedCallback() {
475
- var _this$sizes;
645
+ var _this$sizes, _this$unwatch;
476
646
  (_this$sizes = this.sizes) === null || _this$sizes === void 0 || _this$sizes.disconnect();
477
647
  this.sizes = null;
478
- this.enqueue(() => this.teardown());
648
+ (_this$unwatch = this.unwatch) === null || _this$unwatch === void 0 || _this$unwatch.call(this);
649
+ this.unwatch = null;
650
+ queueMicrotask(() => {
651
+ if (!this.isConnected) this.enqueue(() => this.teardown());
652
+ });
479
653
  }
480
654
  attributeChangedCallback(name) {
655
+ if (name === LANGUAGE || name === "lang") {
656
+ this.relocale();
657
+ return;
658
+ }
481
659
  if (FORWARDED.includes(name)) {
482
660
  if (!this.reflecting) this.forward(name);
483
661
  return;
@@ -505,6 +683,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
505
683
  if (name === "preset") this.enqueue(() => this.discard());
506
684
  if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
507
685
  if (name === "src" && this.marks.list.length > 0) this.marks.set([]);
686
+ if (name === "src") this.unblock();
508
687
  this.reload();
509
688
  }
510
689
  /**
@@ -517,6 +696,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
517
696
  const custom = value === "custom";
518
697
  this.media.controls = !custom && value !== "none";
519
698
  if (custom) this.surface.clear();
699
+ else this.showBlock();
520
700
  if (!custom) {
521
701
  if (this.focusable) this.removeAttribute("tabindex");
522
702
  this.focusable = false;
@@ -590,8 +770,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
590
770
  if (error.fatal) {
591
771
  this.failure = error;
592
772
  clearTimeout(this.slow);
593
- if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "Playback failed");
773
+ if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "playbackFailed", "Playback failed");
594
774
  if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
775
+ this.reflect();
595
776
  }
596
777
  this.emit("error", error);
597
778
  }
@@ -606,6 +787,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
606
787
  const core = yield _this2.ensure();
607
788
  _this2.failure = null;
608
789
  _this2.surface.clear();
790
+ _this2.reflect();
609
791
  try {
610
792
  yield core.load(sources);
611
793
  } catch (_unused2) {
@@ -628,7 +810,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
628
810
  return [_objectSpread2(_objectSpread2({ url }, type === null ? {} : { type }), withVersions)];
629
811
  }
630
812
  const eme = emeAvailable();
631
- if (this.list !== null) return eme ? this.list : this.list.map(withoutDrm);
813
+ if (this.list !== null) return eme ? this.list : this.list.map((source) => "url" in source ? withoutDrm(source) : source);
632
814
  const found = [];
633
815
  for (const child of Array.from(this.children)) {
634
816
  const src = child.localName === "source" ? child.getAttribute("src") : null;
@@ -642,22 +824,31 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
642
824
  }
643
825
  /** Sets a session up. It runs for every session, the one that replaces a failed source included. */
644
826
  adopt(session) {
827
+ var _this$core2;
645
828
  this.given = null;
646
829
  this.configure(session);
830
+ const chapters = (_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.programme) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.metadata) === null || _this$core2 === void 0 ? void 0 : _this$core2.chapters;
831
+ if (chapters !== void 0 && session.engine !== null && this.getAttribute(CHAPTERS) === null) {
832
+ var _namespaces$chapters;
833
+ (_namespaces$chapters = namespaces(session.engine).chapters) === null || _namespaces$chapters === void 0 || _namespaces$chapters.set(chapters);
834
+ }
647
835
  this.chapters();
648
836
  }
649
837
  ensure() {
650
838
  var _this3 = this;
651
839
  return _asyncToGenerator(function* () {
652
840
  if (_this3.core !== null) return _this3.core;
653
- const core = createPlayer(_this3.media, { handlers: yield _this3.chain() });
654
- _this3.offs.push(core.on("sourcechange", (session) => {
841
+ const connectors = _this3.options.connectors;
842
+ const core = createPlayer(_this3.media, _objectSpread2({ handlers: yield _this3.chain() }, connectors === void 0 ? {} : { connectors }));
843
+ _this3.offs.push(core.on("programme", (programme) => {
844
+ _this3.programmed(programme);
845
+ }), core.on("sourcechange", (session) => {
655
846
  var _this$offTracks, _session$engine$on, _session$engine;
656
847
  _this3.current = session;
657
848
  if (!_this3.switching) {
658
849
  var _session$source, _this$held2;
659
850
  const was = _this3.version;
660
- _this3.programme = (_session$source = session === null || session === void 0 ? void 0 : session.source) !== null && _session$source !== void 0 ? _session$source : null;
851
+ _this3.original = (_session$source = session === null || session === void 0 ? void 0 : session.source) !== null && _session$source !== void 0 ? _session$source : null;
661
852
  _this3.switched = null;
662
853
  _this3.version = null;
663
854
  (_this$held2 = _this3.held) === null || _this$held2 === void 0 || _this$held2.call(_this3);
@@ -686,7 +877,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
686
877
  chain() {
687
878
  var _this4 = this;
688
879
  return _asyncToGenerator(function* () {
689
- var _this$getAttribute2;
880
+ var _this$getAttribute4;
690
881
  if (_this4.options.handlers !== void 0) return _this4.options.handlers;
691
882
  const config = _this4.options.config === void 0 ? {} : { config: _this4.options.config };
692
883
  const native = (stages) => nativeHandler({
@@ -697,7 +888,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
697
888
  var _this$options$stages;
698
889
  return (_this$options$stages = _this4.options.stages) !== null && _this$options$stages !== void 0 ? _this$options$stages : [];
699
890
  })];
700
- const name = (_this$getAttribute2 = _this4.getAttribute("preset")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : DEFAULT_PRESET;
891
+ const name = (_this$getAttribute4 = _this4.getAttribute("preset")) !== null && _this$getAttribute4 !== void 0 ? _this$getAttribute4 : DEFAULT_PRESET;
701
892
  const preset = yield resolvePreset(name);
702
893
  if (preset === null) {
703
894
  _this4.report({
@@ -765,5 +956,4 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
765
956
  })();
766
957
  }
767
958
  };
768
- //#endregion
769
959
  export { MatteboxPlayerElement };
@@ -2,7 +2,7 @@ import { airplay } from "../controls/airplay.js";
2
2
  import { icon } from "../controls/icons.js";
3
3
  import { Component } from "./component.js";
4
4
  import { BUTTON_STYLE, iconSlots, show, style } from "./shared.js";
5
- //#region src/elements/airplay-button.ts
5
+ // src/elements/airplay-button.ts
6
6
  const STATES = ["default", "active"];
7
7
  var MbxAirplayButton = class extends Component {
8
8
  static get observedAttributes() {
@@ -38,15 +38,13 @@ var MbxAirplayButton = class extends Component {
38
38
  player.removeAttribute("airplay");
39
39
  }
40
40
  render() {
41
- var _this$getAttribute, _this$getAttribute2;
42
41
  const player = this.player;
43
42
  if (player === null || this.api === null) return;
44
43
  const active = this.api.active();
45
44
  this.hidden = !this.api.supported || !this.api.offered();
46
45
  show(this.slots, active ? "active" : "default");
47
- this.button.setAttribute("aria-label", active ? (_this$getAttribute = this.getAttribute("label-active")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "Stop AirPlay" : (_this$getAttribute2 = this.getAttribute("label")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : "AirPlay");
46
+ this.button.setAttribute("aria-label", active ? this.word("label-active", "stopAirplay", "Stop AirPlay") : this.word("label", "airplay", "AirPlay"));
48
47
  player.toggleAttribute("airplay", active);
49
48
  }
50
49
  };
51
- //#endregion
52
50
  export { MbxAirplayButton };
@@ -4,11 +4,11 @@ import { show } from "./shared.js";
4
4
  import { nativeTracks, onNativeTracks } from "../controls/native-tracks.js";
5
5
  import { MenuElement, single } from "./menu-element.js";
6
6
  import { isAudioDescription, isOriginal } from "mattebox";
7
- //#region src/elements/audio-menu.ts
7
+ // src/elements/audio-menu.ts
8
8
  /** A track's channel layout, from its first rendition: `audioObjects` `JOC` is Dolby Atmos. */
9
- function channels(track) {
9
+ function channels(track, words) {
10
10
  const first = track.renditions[0];
11
- return (first === null || first === void 0 ? void 0 : first.channels) === void 0 ? void 0 : layout(`${first.channels}${first.audioObjects ? `/${first.audioObjects}` : ""}`);
11
+ return (first === null || first === void 0 ? void 0 : first.channels) === void 0 ? void 0 : layout(`${first.channels}${first.audioObjects ? `/${first.audioObjects}` : ""}`, words);
12
12
  }
13
13
  /**
14
14
  * The tracks of one content type that the engine can play and `listed`
@@ -16,7 +16,7 @@ function channels(track) {
16
16
  * is listed. A track the browser cannot decode, or that no stage plays,
17
17
  * stays out (guide chapter 06).
18
18
  */
19
- function trackItems(engine, contentType, badges = () => [], listed = () => true) {
19
+ function trackItems(engine, contentType, badges = () => [], listed = () => true, words = {}) {
20
20
  var _tracks$active;
21
21
  const tracks = engine.tracks;
22
22
  const available = tracks.available.filter((track) => track.contentType === contentType && tracks.selectable(track.id) && listed(track));
@@ -25,7 +25,7 @@ function trackItems(engine, contentType, badges = () => [], listed = () => true)
25
25
  track.name,
26
26
  track.lang,
27
27
  badges(track),
28
- [channels(track), track.role === "main" ? void 0 : track.role]
28
+ [channels(track, words), track.role === "main" ? void 0 : track.role]
29
29
  ]);
30
30
  const active = (_tracks$active = tracks.active(contentType)) === null || _tracks$active === void 0 ? void 0 : _tracks$active.id;
31
31
  return [entries, available.some((track) => track.id === active) ? active : null];
@@ -44,7 +44,9 @@ var MbxAudioMenu = class extends MenuElement {
44
44
  "label-back",
45
45
  "label-ad",
46
46
  "label-original",
47
- "label-track"
47
+ "label-track",
48
+ "label-mono",
49
+ "label-stereo"
48
50
  ];
49
51
  }
50
52
  constructor() {
@@ -53,7 +55,7 @@ var MbxAudioMenu = class extends MenuElement {
53
55
  show(this.slots, "default");
54
56
  }
55
57
  name() {
56
- return "Audio";
58
+ return ["audio", "Audio"];
57
59
  }
58
60
  attach(player) {
59
61
  this.follow(player, (engine) => {
@@ -67,8 +69,7 @@ var MbxAudioMenu = class extends MenuElement {
67
69
  }
68
70
  /** The native session's audio tracks as entries, and the enabled one's. */
69
71
  native(tracks) {
70
- var _this$getAttribute;
71
- const ad = (_this$getAttribute = this.getAttribute("label-ad")) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : "AD";
72
+ const ad = this.word("label-ad", "audioDescription", "AD");
72
73
  const entries = tracks.map((track, index) => [
73
74
  String(index),
74
75
  track.label,
@@ -80,7 +81,7 @@ var MbxAudioMenu = class extends MenuElement {
80
81
  return [entries, on === -1 ? null : String(on)];
81
82
  }
82
83
  render() {
83
- var _this$getAttribute4;
84
+ var _this$player;
84
85
  super.render();
85
86
  const engine = this.engine;
86
87
  const player = this.player;
@@ -89,15 +90,17 @@ var MbxAudioMenu = class extends MenuElement {
89
90
  this.hidden = true;
90
91
  return;
91
92
  }
92
- const [entries, active] = tracks !== void 0 ? this.native(tracks) : trackItems(engine, "audio", (track) => {
93
- var _this$getAttribute2, _this$getAttribute3;
94
- return [...isAudioDescription(track) ? [(_this$getAttribute2 = this.getAttribute("label-ad")) !== null && _this$getAttribute2 !== void 0 ? _this$getAttribute2 : "AD"] : [], ...isOriginal(track) ? [(_this$getAttribute3 = this.getAttribute("label-original")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : "Original"] : []];
93
+ const ad = this.word("label-ad", "audioDescription", "AD");
94
+ const original = this.word("label-original", "original", "Original");
95
+ const [entries, active] = tracks !== void 0 ? this.native(tracks) : trackItems(engine, "audio", (track) => [...isAudioDescription(track) ? [ad] : [], ...isOriginal(track) ? [original] : []], void 0, {
96
+ 1: this.word("label-mono", "mono", "Mono"),
97
+ 2: this.word("label-stereo", "stereo", "Stereo")
95
98
  });
96
- const items = trackNames(entries, this.getAttribute("label-track"));
99
+ const items = trackNames(entries, this.word("label-track", "track", "Track"), ((_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.locale) || void 0);
97
100
  this.menu.fill([{
98
101
  name: "track",
99
102
  items,
100
- badgeGlyphs: { [(_this$getAttribute4 = this.getAttribute("label-ad")) !== null && _this$getAttribute4 !== void 0 ? _this$getAttribute4 : "AD"]: () => icon("audio-description") },
103
+ badgeGlyphs: { [ad]: () => icon("audio-description") },
101
104
  value: active !== null && active !== void 0 ? active : "",
102
105
  onSelect: (value) => {
103
106
  if (tracks !== void 0) tracks.forEach((track, index) => {
@@ -110,5 +113,4 @@ var MbxAudioMenu = class extends MenuElement {
110
113
  this.hidden = items.length < 2;
111
114
  }
112
115
  };
113
- //#endregion
114
116
  export { MbxAudioMenu, onTracks, trackItems };
@@ -2,7 +2,7 @@ import { show } from "./shared.js";
2
2
  import { MenuElement, single } from "./menu-element.js";
3
3
  import { format } from "../controls/time.js";
4
4
  import { chapterAt, chapters, followChapters } from "../controls/chapters.js";
5
- //#region src/elements/chapters-menu.ts
5
+ // src/elements/chapters-menu.ts
6
6
  /**
7
7
  * <mbx-chapters-menu>: the chapters of the video as a list, each with its
8
8
  * start time, the one the playhead is in checked; choosing one seeks to its
@@ -23,7 +23,7 @@ var MbxChaptersMenu = class extends MenuElement {
23
23
  show(this.slots, "default");
24
24
  }
25
25
  name() {
26
- return "Chapters";
26
+ return ["chapters", "Chapters"];
27
27
  }
28
28
  attach(player) {
29
29
  const tick = () => {
@@ -72,5 +72,4 @@ var MbxChaptersMenu = class extends MenuElement {
72
72
  }]);
73
73
  }
74
74
  };
75
- //#endregion
76
75
  export { MbxChaptersMenu };