@videojs/html 10.3.0 → 10.4.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 (272) hide show
  1. package/dist/default/define/audio/compat-skin.css +91 -38
  2. package/dist/default/define/audio/compat-skin2.js +1 -1
  3. package/dist/default/define/audio/neutral-skin.css +52 -31
  4. package/dist/default/define/audio/neutral-skin2.js +1 -1
  5. package/dist/default/define/audio/scaffold-skin.css +105 -40
  6. package/dist/default/define/audio/scaffold-skin2.js +1 -1
  7. package/dist/default/define/audio/skin.css +53 -31
  8. package/dist/default/define/audio/skin2.js +1 -1
  9. package/dist/default/define/live-audio/compat-skin.css +91 -38
  10. package/dist/default/define/live-audio/compat-skin2.js +1 -1
  11. package/dist/default/define/live-audio/neutral-skin.css +50 -29
  12. package/dist/default/define/live-audio/neutral-skin2.js +1 -1
  13. package/dist/default/define/live-audio/scaffold-skin.css +105 -40
  14. package/dist/default/define/live-audio/scaffold-skin2.js +1 -1
  15. package/dist/default/define/live-audio/skin.css +51 -29
  16. package/dist/default/define/live-audio/skin2.js +1 -1
  17. package/dist/default/define/live-video/compat-skin.css +142 -61
  18. package/dist/default/define/live-video/compat-skin2.js +1 -1
  19. package/dist/default/define/live-video/neutral-skin.css +241 -55
  20. package/dist/default/define/live-video/neutral-skin2.js +1 -1
  21. package/dist/default/define/live-video/scaffold-skin.css +159 -63
  22. package/dist/default/define/live-video/scaffold-skin2.js +1 -1
  23. package/dist/default/define/live-video/skin.css +245 -60
  24. package/dist/default/define/live-video/skin2.js +1 -1
  25. package/dist/default/define/ui/time-slider-markers.js +5 -0
  26. package/dist/default/define/video/compat-skin.css +150 -61
  27. package/dist/default/define/video/compat-skin2.js +1 -1
  28. package/dist/default/define/video/neutral-skin.css +322 -66
  29. package/dist/default/define/video/neutral-skin2.js +1 -1
  30. package/dist/default/define/video/scaffold-skin.css +168 -63
  31. package/dist/default/define/video/scaffold-skin2.js +1 -1
  32. package/dist/default/define/video/skin.css +348 -66
  33. package/dist/default/define/video/skin2.js +1 -1
  34. package/dist/default/index.js +3 -1
  35. package/dist/default/internal/skins/compat-audio/skin.css +91 -38
  36. package/dist/default/internal/skins/compat-live-audio/skin.css +91 -38
  37. package/dist/default/internal/skins/compat-live-video/skin.css +142 -61
  38. package/dist/default/internal/skins/compat-live-video/template.js +2 -0
  39. package/dist/default/internal/skins/compat-video/skin.css +150 -61
  40. package/dist/default/internal/skins/compat-video/template.js +2 -0
  41. package/dist/default/internal/skins/default-audio/skin.css +53 -31
  42. package/dist/default/internal/skins/default-live-audio/skin.css +51 -29
  43. package/dist/default/internal/skins/default-live-video/skin.css +245 -60
  44. package/dist/default/internal/skins/default-live-video/template.js +14 -0
  45. package/dist/default/internal/skins/default-video/register.js +3 -0
  46. package/dist/default/internal/skins/default-video/skin.css +348 -66
  47. package/dist/default/internal/skins/default-video/template.js +33 -5
  48. package/dist/default/internal/skins/neutral-audio/skin.css +52 -31
  49. package/dist/default/internal/skins/neutral-live-audio/skin.css +50 -29
  50. package/dist/default/internal/skins/neutral-live-video/skin.css +241 -55
  51. package/dist/default/internal/skins/neutral-live-video/template.js +14 -0
  52. package/dist/default/internal/skins/neutral-video/skin.css +322 -66
  53. package/dist/default/internal/skins/neutral-video/template.js +25 -11
  54. package/dist/default/internal/skins/scaffold-audio/skin.css +105 -40
  55. package/dist/default/internal/skins/scaffold-live-audio/skin.css +105 -40
  56. package/dist/default/internal/skins/scaffold-live-video/skin.css +159 -63
  57. package/dist/default/internal/skins/scaffold-live-video/template.js +2 -0
  58. package/dist/default/internal/skins/scaffold-video/skin.css +168 -63
  59. package/dist/default/internal/skins/scaffold-video/template.js +3 -1
  60. package/dist/default/media/background-video/adapter.js +13 -35
  61. package/dist/default/media/background-video/base.js +95 -0
  62. package/dist/default/media/background-video/template.js +13 -20
  63. package/dist/default/media/hls-background-video/adapter.js +16 -35
  64. package/dist/default/ui/captions-radio-group/element.js +14 -1
  65. package/dist/default/ui/controls/element.js +6 -3
  66. package/dist/default/ui/time-slider/markers.js +160 -0
  67. package/dist/default/version.js +1 -1
  68. package/dist/dev/define/audio/compat-skin.css +91 -38
  69. package/dist/dev/define/audio/compat-skin2.js +1 -1
  70. package/dist/dev/define/audio/compat-skin2.js.map +1 -1
  71. package/dist/dev/define/audio/neutral-skin.css +52 -31
  72. package/dist/dev/define/audio/neutral-skin2.js +1 -1
  73. package/dist/dev/define/audio/neutral-skin2.js.map +1 -1
  74. package/dist/dev/define/audio/scaffold-skin.css +105 -40
  75. package/dist/dev/define/audio/scaffold-skin2.js +1 -1
  76. package/dist/dev/define/audio/scaffold-skin2.js.map +1 -1
  77. package/dist/dev/define/audio/skin.css +53 -31
  78. package/dist/dev/define/audio/skin2.js +1 -1
  79. package/dist/dev/define/audio/skin2.js.map +1 -1
  80. package/dist/dev/define/live-audio/compat-skin.css +91 -38
  81. package/dist/dev/define/live-audio/compat-skin2.js +1 -1
  82. package/dist/dev/define/live-audio/compat-skin2.js.map +1 -1
  83. package/dist/dev/define/live-audio/neutral-skin.css +50 -29
  84. package/dist/dev/define/live-audio/neutral-skin2.js +1 -1
  85. package/dist/dev/define/live-audio/neutral-skin2.js.map +1 -1
  86. package/dist/dev/define/live-audio/scaffold-skin.css +105 -40
  87. package/dist/dev/define/live-audio/scaffold-skin2.js +1 -1
  88. package/dist/dev/define/live-audio/scaffold-skin2.js.map +1 -1
  89. package/dist/dev/define/live-audio/skin.css +51 -29
  90. package/dist/dev/define/live-audio/skin2.js +1 -1
  91. package/dist/dev/define/live-audio/skin2.js.map +1 -1
  92. package/dist/dev/define/live-video/compat-skin.css +142 -61
  93. package/dist/dev/define/live-video/compat-skin2.js +1 -1
  94. package/dist/dev/define/live-video/compat-skin2.js.map +1 -1
  95. package/dist/dev/define/live-video/neutral-skin.css +241 -55
  96. package/dist/dev/define/live-video/neutral-skin2.js +1 -1
  97. package/dist/dev/define/live-video/neutral-skin2.js.map +1 -1
  98. package/dist/dev/define/live-video/scaffold-skin.css +159 -63
  99. package/dist/dev/define/live-video/scaffold-skin2.js +1 -1
  100. package/dist/dev/define/live-video/scaffold-skin2.js.map +1 -1
  101. package/dist/dev/define/live-video/skin.css +245 -60
  102. package/dist/dev/define/live-video/skin2.js +1 -1
  103. package/dist/dev/define/live-video/skin2.js.map +1 -1
  104. package/dist/dev/define/ui/time-slider-markers.d.ts +8 -0
  105. package/dist/dev/define/ui/time-slider-markers.js +7 -0
  106. package/dist/dev/define/ui/time-slider-markers.js.map +1 -0
  107. package/dist/dev/define/video/compat-skin.css +150 -61
  108. package/dist/dev/define/video/compat-skin2.js +1 -1
  109. package/dist/dev/define/video/compat-skin2.js.map +1 -1
  110. package/dist/dev/define/video/neutral-skin.css +322 -66
  111. package/dist/dev/define/video/neutral-skin2.js +1 -1
  112. package/dist/dev/define/video/neutral-skin2.js.map +1 -1
  113. package/dist/dev/define/video/scaffold-skin.css +168 -63
  114. package/dist/dev/define/video/scaffold-skin2.js +1 -1
  115. package/dist/dev/define/video/scaffold-skin2.js.map +1 -1
  116. package/dist/dev/define/video/skin.css +348 -66
  117. package/dist/dev/define/video/skin2.js +1 -1
  118. package/dist/dev/define/video/skin2.js.map +1 -1
  119. package/dist/dev/index.d.ts +5 -4
  120. package/dist/dev/index.js +3 -1
  121. package/dist/dev/internal/skins/compat-audio/skin.css +91 -38
  122. package/dist/dev/internal/skins/compat-live-audio/skin.css +91 -38
  123. package/dist/dev/internal/skins/compat-live-video/skin.css +142 -61
  124. package/dist/dev/internal/skins/compat-live-video/template.js +2 -0
  125. package/dist/dev/internal/skins/compat-live-video/template.js.map +1 -1
  126. package/dist/dev/internal/skins/compat-video/skin.css +150 -61
  127. package/dist/dev/internal/skins/compat-video/template.js +2 -0
  128. package/dist/dev/internal/skins/compat-video/template.js.map +1 -1
  129. package/dist/dev/internal/skins/default-audio/skin.css +53 -31
  130. package/dist/dev/internal/skins/default-live-audio/skin.css +51 -29
  131. package/dist/dev/internal/skins/default-live-video/register.js.map +1 -1
  132. package/dist/dev/internal/skins/default-live-video/skin.css +245 -60
  133. package/dist/dev/internal/skins/default-live-video/template.js +14 -0
  134. package/dist/dev/internal/skins/default-live-video/template.js.map +1 -1
  135. package/dist/dev/internal/skins/default-video/register.d.ts +1 -0
  136. package/dist/dev/internal/skins/default-video/register.js +3 -0
  137. package/dist/dev/internal/skins/default-video/register.js.map +1 -1
  138. package/dist/dev/internal/skins/default-video/skin.css +348 -66
  139. package/dist/dev/internal/skins/default-video/template.js +33 -5
  140. package/dist/dev/internal/skins/default-video/template.js.map +1 -1
  141. package/dist/dev/internal/skins/neutral-audio/skin.css +52 -31
  142. package/dist/dev/internal/skins/neutral-live-audio/skin.css +50 -29
  143. package/dist/dev/internal/skins/neutral-live-video/register.js.map +1 -1
  144. package/dist/dev/internal/skins/neutral-live-video/skin.css +241 -55
  145. package/dist/dev/internal/skins/neutral-live-video/template.js +14 -0
  146. package/dist/dev/internal/skins/neutral-live-video/template.js.map +1 -1
  147. package/dist/dev/internal/skins/neutral-video/register.js.map +1 -1
  148. package/dist/dev/internal/skins/neutral-video/skin.css +322 -66
  149. package/dist/dev/internal/skins/neutral-video/template.js +25 -11
  150. package/dist/dev/internal/skins/neutral-video/template.js.map +1 -1
  151. package/dist/dev/internal/skins/scaffold-audio/skin.css +105 -40
  152. package/dist/dev/internal/skins/scaffold-live-audio/skin.css +105 -40
  153. package/dist/dev/internal/skins/scaffold-live-video/skin.css +159 -63
  154. package/dist/dev/internal/skins/scaffold-live-video/template.js +2 -0
  155. package/dist/dev/internal/skins/scaffold-live-video/template.js.map +1 -1
  156. package/dist/dev/internal/skins/scaffold-video/skin.css +168 -63
  157. package/dist/dev/internal/skins/scaffold-video/template.js +3 -1
  158. package/dist/dev/internal/skins/scaffold-video/template.js.map +1 -1
  159. package/dist/dev/media/background-video/adapter.d.ts +7 -13
  160. package/dist/dev/media/background-video/adapter.js +13 -35
  161. package/dist/dev/media/background-video/adapter.js.map +1 -1
  162. package/dist/dev/media/background-video/base.d.ts +44 -0
  163. package/dist/dev/media/background-video/base.js +97 -0
  164. package/dist/dev/media/background-video/base.js.map +1 -0
  165. package/dist/dev/media/background-video/template.d.ts +3 -0
  166. package/dist/dev/media/background-video/template.js +13 -20
  167. package/dist/dev/media/background-video/template.js.map +1 -1
  168. package/dist/dev/media/hls-background-video/adapter.d.ts +8 -18
  169. package/dist/dev/media/hls-background-video/adapter.js +16 -35
  170. package/dist/dev/media/hls-background-video/adapter.js.map +1 -1
  171. package/dist/dev/ui/captions-button/element.d.ts +2 -0
  172. package/dist/dev/ui/captions-radio-group/element.d.ts +2 -1
  173. package/dist/dev/ui/captions-radio-group/element.js +14 -1
  174. package/dist/dev/ui/captions-radio-group/element.js.map +1 -1
  175. package/dist/dev/ui/controls/element.d.ts +2 -2
  176. package/dist/dev/ui/controls/element.js +6 -3
  177. package/dist/dev/ui/controls/element.js.map +1 -1
  178. package/dist/dev/ui/time-slider/markers.d.ts +48 -0
  179. package/dist/dev/ui/time-slider/markers.js +165 -0
  180. package/dist/dev/ui/time-slider/markers.js.map +1 -0
  181. package/dist/dev/version.js +1 -1
  182. package/docs/README.md +1 -1
  183. package/docs/guides/autoplay.md +1 -1
  184. package/docs/guides/background-video.md +2 -4
  185. package/docs/guides/browser-support.md +22 -16
  186. package/docs/guides/cdn.md +9 -9
  187. package/docs/guides/customize-skins.md +3 -0
  188. package/docs/guides/installation-cdn.md +2 -2
  189. package/docs/guides/installation-shadcn.md +1 -1
  190. package/docs/guides/installation-svelte.md +2 -2
  191. package/docs/guides/installation-vue.md +2 -2
  192. package/docs/guides/installation.md +2 -2
  193. package/docs/guides/internationalization.md +5 -5
  194. package/docs/guides/keyboard-shortcuts.md +10 -0
  195. package/docs/guides/llms.txt +2 -1
  196. package/docs/guides/migrate-from-media-chrome.md +4 -4
  197. package/docs/guides/migrate-from-mux-player.md +6 -6
  198. package/docs/guides/migrate-from-plyr.md +7 -7
  199. package/docs/guides/migrate-from-video-js-8.md +6 -6
  200. package/docs/guides/migrate-from-vidstack.md +4 -4
  201. package/docs/guides/presets.md +4 -4
  202. package/docs/guides/self-hosting.md +5 -5
  203. package/docs/guides/skins.md +8 -7
  204. package/docs/guides/timed-metadata.md +318 -0
  205. package/docs/llms.txt +16 -2
  206. package/docs/reference/api/chapters-track.md +71 -0
  207. package/docs/reference/api/define-text-track.md +113 -0
  208. package/docs/reference/api/feature-text-cues.md +133 -0
  209. package/docs/reference/api/feature-text-tracks.md +11 -5
  210. package/docs/reference/api/get-active-text-cues.md +69 -0
  211. package/docs/reference/api/get-text-cues.md +69 -0
  212. package/docs/reference/api/get-text-tracks.md +41 -0
  213. package/docs/reference/api/hls-metadata-track.md +48 -0
  214. package/docs/reference/api/html-create-player.md +2 -2
  215. package/docs/reference/api/llms.txt +13 -1
  216. package/docs/reference/api/media-capabilities.md +4 -4
  217. package/docs/reference/api/player-store.md +9 -4
  218. package/docs/reference/api/preset-audio.md +3 -1
  219. package/docs/reference/api/preset-background.md +1 -1
  220. package/docs/reference/api/preset-live-audio.md +3 -1
  221. package/docs/reference/api/preset-live-video.md +2 -1
  222. package/docs/reference/api/preset-video.md +2 -1
  223. package/docs/reference/components/audio-compat-skin.md +1 -1
  224. package/docs/reference/components/audio-neutral-skin.md +1 -1
  225. package/docs/reference/components/audio-scaffold-skin.md +1 -1
  226. package/docs/reference/components/audio-skin.md +1 -1
  227. package/docs/reference/components/audio.md +19 -1
  228. package/docs/reference/components/background-video-skin.md +1 -1
  229. package/docs/reference/components/background-video.md +26 -11
  230. package/docs/reference/components/captions-radio-group.md +1 -1
  231. package/docs/reference/components/cloudflare-video.md +1 -1
  232. package/docs/reference/components/controls.md +16 -3
  233. package/docs/reference/components/dailymotion-video.md +2 -2
  234. package/docs/reference/components/dash-video.md +20 -3
  235. package/docs/reference/components/google-analytics.md +1 -1
  236. package/docs/reference/components/google-cast.md +1 -1
  237. package/docs/reference/components/hls-audio.md +56 -2
  238. package/docs/reference/components/hls-background-video.md +22 -5
  239. package/docs/reference/components/hls-video.md +99 -7
  240. package/docs/reference/components/hlsjs-video.md +52 -13
  241. package/docs/reference/components/live-audio-compat-skin.md +1 -1
  242. package/docs/reference/components/live-audio-neutral-skin.md +1 -1
  243. package/docs/reference/components/live-audio-scaffold-skin.md +1 -1
  244. package/docs/reference/components/live-audio-skin.md +1 -1
  245. package/docs/reference/components/live-video-compat-skin.md +5 -1
  246. package/docs/reference/components/live-video-neutral-skin.md +5 -1
  247. package/docs/reference/components/live-video-scaffold-skin.md +5 -1
  248. package/docs/reference/components/live-video-skin.md +5 -1
  249. package/docs/reference/components/llms.txt +2 -1
  250. package/docs/reference/components/mixcloud-audio.md +2 -2
  251. package/docs/reference/components/mux-audio.md +34 -3
  252. package/docs/reference/components/mux-background-video.md +1 -1
  253. package/docs/reference/components/mux-data.md +1 -1
  254. package/docs/reference/components/mux-video.md +17 -3
  255. package/docs/reference/components/native-hls-video.md +32 -3
  256. package/docs/reference/components/playerjs-video.md +2 -2
  257. package/docs/reference/components/shaka-video.md +2 -3
  258. package/docs/reference/components/soundcloud-audio.md +2 -2
  259. package/docs/reference/components/spotify-audio.md +2 -2
  260. package/docs/reference/components/tiktok-video.md +2 -2
  261. package/docs/reference/components/time-slider-markers.md +194 -0
  262. package/docs/reference/components/time-slider.md +14 -0
  263. package/docs/reference/components/twitch-video.md +1 -1
  264. package/docs/reference/components/video-compat-skin.md +5 -1
  265. package/docs/reference/components/video-neutral-skin.md +5 -1
  266. package/docs/reference/components/video-scaffold-skin.md +5 -1
  267. package/docs/reference/components/video-skin.md +5 -1
  268. package/docs/reference/components/video.md +19 -1
  269. package/docs/reference/components/vimeo-video.md +1 -2
  270. package/docs/reference/components/wistia-video.md +1 -1
  271. package/docs/reference/components/youtube-video.md +1 -2
  272. package/package.json +48 -48
@@ -1,20 +1,14 @@
1
- import { getTemplateHTML } from "./template.js";
1
+ import { BackgroundVideoBase } from "./base.js";
2
2
  import { Media } from "@videojs/media/dom";
3
3
  //#region src/media/background-video/adapter.d.ts
4
- declare const BackgroundVideo_base: {
5
- new (): HTMLElement;
6
- prototype: HTMLElement;
7
- };
8
- export declare class BackgroundVideo extends BackgroundVideo_base {
9
- static shadowRootOptions: {
10
- mode: ShadowRootMode;
11
- };
12
- static getTemplateHTML: typeof getTemplateHTML;
13
- static get observedAttributes(): string[];
4
+ export declare class BackgroundVideo extends BackgroundVideoBase {
14
5
  constructor();
15
6
  getMediaTarget(): Media | null;
16
- attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null): void;
17
- get target(): HTMLVideoElement | null;
7
+ /** URL of a video the browser can play directly. Assigning a new one restarts playback. */
8
+ get src(): string;
9
+ set src(value: string);
10
+ /** The inner video's `MediaError`, or `null`. */
11
+ get error(): MediaError | null;
18
12
  }
19
13
  //#endregion
20
14
  //# sourceMappingURL=adapter.d.ts.map
@@ -1,46 +1,24 @@
1
- import { MediaAttachMixin } from "../../store/media-attach-mixin.js";
2
- import { getTemplateHTML } from "./template.js";
3
- import { namedNodeMapToObject } from "@videojs/utils/dom";
1
+ import { BackgroundVideoBase } from "./base.js";
4
2
  //#region src/media/background-video/adapter.ts
5
- const HTMLElementBase = globalThis.HTMLElement ?? class {};
6
- var BackgroundVideo = class extends MediaAttachMixin(HTMLElementBase) {
7
- static {
8
- this.shadowRootOptions = { mode: "open" };
9
- }
10
- static {
11
- this.getTemplateHTML = getTemplateHTML;
12
- }
13
- static get observedAttributes() {
14
- return ["src"];
15
- }
3
+ var BackgroundVideo = class extends BackgroundVideoBase {
16
4
  constructor() {
17
5
  super();
18
- if (!this.shadowRoot) {
19
- this.attachShadow(this.constructor.shadowRootOptions);
20
- const attrs = {
21
- ...namedNodeMapToObject(this.attributes),
22
- ...!this.hasAttribute("nomuted") && { muted: "" },
23
- ...!this.hasAttribute("noloop") && { loop: "" },
24
- ...!this.hasAttribute("noautoplay") && { autoplay: "" },
25
- playsinline: "",
26
- disableremoteplayback: "",
27
- disablepictureinpicture: ""
28
- };
29
- this.shadowRoot.innerHTML = getTemplateHTML(attrs);
30
- }
31
- this.target.muted = !this.hasAttribute("nomuted");
6
+ this.target?.addEventListener("error", () => this.dispatchEvent(new Event("error")));
32
7
  }
33
8
  getMediaTarget() {
34
9
  return this.target;
35
10
  }
36
- attributeChangedCallback(attrName, oldValue, newValue) {
37
- if (attrName === "src" && oldValue !== newValue) this.target.src = newValue ?? "";
11
+ /** URL of a video the browser can play directly. Assigning a new one restarts playback. */
12
+ get src() {
13
+ return this.target?.src ?? "";
14
+ }
15
+ set src(value) {
16
+ const target = this.target;
17
+ if (target) target.src = value;
38
18
  }
39
- get target() {
40
- const slotted = this.querySelector(":scope > [slot=media]");
41
- if (slotted instanceof HTMLVideoElement) return slotted;
42
- const video = this.querySelector("video") ?? this.shadowRoot?.querySelector("video");
43
- return video instanceof HTMLVideoElement ? video : null;
19
+ /** The inner video's `MediaError`, or `null`. */
20
+ get error() {
21
+ return this.target?.error ?? null;
44
22
  }
45
23
  };
46
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","names":[],"sources":["../../../../src/media/background-video/adapter.ts"],"sourcesContent":["import type { Media } from '@videojs/media/dom';\nimport { namedNodeMapToObject } from '@videojs/utils/dom';\n\nimport { MediaAttachMixin } from '../../store/media-attach-mixin';\nimport { getTemplateHTML } from './template';\n\nconst HTMLElementBase = globalThis.HTMLElement ?? class {};\n\n// Don't extend CustomMediaMixin to save some bytes, background videos don't need the full Media API.\nexport class BackgroundVideo extends MediaAttachMixin(HTMLElementBase) {\n static shadowRootOptions = { mode: 'open' as ShadowRootMode };\n static getTemplateHTML = getTemplateHTML;\n static get observedAttributes() {\n return ['src'];\n }\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow((this.constructor as typeof BackgroundVideo).shadowRootOptions);\n\n const attrs = {\n ...namedNodeMapToObject(this.attributes),\n ...(!this.hasAttribute('nomuted') && { muted: '' }),\n ...(!this.hasAttribute('noloop') && { loop: '' }),\n ...(!this.hasAttribute('noautoplay') && { autoplay: '' }),\n playsinline: '',\n disableremoteplayback: '',\n disablepictureinpicture: '',\n };\n\n this.shadowRoot!.innerHTML = getTemplateHTML(attrs);\n }\n\n // Neither Chrome or Firefox support setting the muted attribute\n // after using document.createElement.\n // Get around this by setting the muted property manually.\n this.target!.muted = !this.hasAttribute('nomuted');\n }\n\n // Register the inner <video> (not `this`) with the provider.\n getMediaTarget(): Media | null {\n return this.target;\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null): void {\n if (attrName === 'src' && oldValue !== newValue) {\n this.target!.src = newValue ?? '';\n }\n }\n\n get target(): HTMLVideoElement | null {\n const slotted = this.querySelector(':scope > [slot=media]');\n if (slotted instanceof HTMLVideoElement) return slotted;\n\n const video = this.querySelector('video') ?? this.shadowRoot?.querySelector('video');\n\n return video instanceof HTMLVideoElement ? video : null;\n }\n}\n"],"mappings":";;;;AAMA,MAAM,kBAAkB,WAAW,eAAe,MAAM,CAAC;AAGzD,IAAa,kBAAb,cAAqC,iBAAiB,eAAe,CAAC,CAAC;;EAC1C,KAAA,oBAAA,EAAE,MAAM,OAAyB;;;EACnC,KAAA,kBAAA;;CACzB,WAAW,qBAAqB;EAC9B,OAAO,CAAC,KAAK;CACf;CAEA,cAAc;EACZ,MAAM;EAEN,IAAI,CAAC,KAAK,YAAY;GACpB,KAAK,aAAc,KAAK,YAAuC,iBAAiB;GAEhF,MAAM,QAAQ;IACZ,GAAG,qBAAqB,KAAK,UAAU;IACvC,GAAI,CAAC,KAAK,aAAa,SAAS,KAAK,EAAE,OAAO,GAAG;IACjD,GAAI,CAAC,KAAK,aAAa,QAAQ,KAAK,EAAE,MAAM,GAAG;IAC/C,GAAI,CAAC,KAAK,aAAa,YAAY,KAAK,EAAE,UAAU,GAAG;IACvD,aAAa;IACb,uBAAuB;IACvB,yBAAyB;GAC3B;GAEA,KAAK,WAAY,YAAY,gBAAgB,KAAK;EACpD;EAKA,KAAK,OAAQ,QAAQ,CAAC,KAAK,aAAa,SAAS;CACnD;CAGA,iBAA+B;EAC7B,OAAO,KAAK;CACd;CAEA,yBAAyB,UAAkB,UAAyB,UAA+B;EACjG,IAAI,aAAa,SAAS,aAAa,UACrC,KAAK,OAAQ,MAAM,YAAY;CAEnC;CAEA,IAAI,SAAkC;EACpC,MAAM,UAAU,KAAK,cAAc,uBAAuB;EAC1D,IAAI,mBAAmB,kBAAkB,OAAO;EAEhD,MAAM,QAAQ,KAAK,cAAc,OAAO,KAAK,KAAK,YAAY,cAAc,OAAO;EAEnF,OAAO,iBAAiB,mBAAmB,QAAQ;CACrD;AACF"}
1
+ {"version":3,"file":"adapter.js","names":[],"sources":["../../../../src/media/background-video/adapter.ts"],"sourcesContent":["import type { Media } from '@videojs/media/dom';\n\nimport { BackgroundVideoBase } from './base';\n\n// Don't extend CustomMediaMixin to save some bytes, background videos don't need the full Media API.\nexport class BackgroundVideo extends BackgroundVideoBase {\n constructor() {\n super();\n\n // `error` doesn't cross the shadow boundary, so re-fire it from the host,\n // matching `<hls-background-video>`.\n this.target?.addEventListener('error', () => this.dispatchEvent(new Event('error')));\n }\n\n // Register the inner <video> (not `this`) with the provider.\n getMediaTarget(): Media | null {\n return this.target;\n }\n\n /** URL of a video the browser can play directly. Assigning a new one restarts playback. */\n override get src(): string {\n return this.target?.src ?? '';\n }\n\n override set src(value: string) {\n const target = this.target;\n\n if (target) target.src = value;\n }\n\n /** The inner video's `MediaError`, or `null`. */\n get error(): MediaError | null {\n return this.target?.error ?? null;\n }\n}\n"],"mappings":";;AAKA,IAAa,kBAAb,cAAqC,oBAAoB;CACvD,cAAc;EACZ,MAAM;EAIN,KAAK,QAAQ,iBAAiB,eAAe,KAAK,cAAc,IAAI,MAAM,OAAO,CAAC,CAAC;CACrF;CAGA,iBAA+B;EAC7B,OAAO,KAAK;CACd;;CAGA,IAAa,MAAc;EACzB,OAAO,KAAK,QAAQ,OAAO;CAC7B;CAEA,IAAa,IAAI,OAAe;EAC9B,MAAM,SAAS,KAAK;EAEpB,IAAI,QAAQ,OAAO,MAAM;CAC3B;;CAGA,IAAI,QAA2B;EAC7B,OAAO,KAAK,QAAQ,SAAS;CAC/B;AACF"}
@@ -0,0 +1,44 @@
1
+ import { getTemplateHTML } from "./template.js";
2
+ //#region src/media/background-video/base.d.ts
3
+ interface LifecycleElement extends HTMLElement {
4
+ connectedCallback?(): void;
5
+ disconnectedCallback?(): void;
6
+ adoptedCallback?(): void;
7
+ attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;
8
+ }
9
+ declare const MediaAttachBase: new () => LifecycleElement;
10
+ declare const PLAYBACK_DEFAULTS: readonly ['muted', 'loop', 'autoplay'];
11
+ /** A playback default an element can let authors turn off with a `no*` attribute. */
12
+ export type BackgroundVideoOptOut = (typeof PLAYBACK_DEFAULTS)[number];
13
+ /**
14
+ * The shadow setup, `src` wiring, and `target` that `<background-video>` and `<hls-background-video>` share. Each
15
+ * subclass supplies its own `src` and declares which playback defaults authors may opt out of.
16
+ *
17
+ * @internal
18
+ */
19
+ export declare abstract class BackgroundVideoBase extends MediaAttachBase {
20
+ #private;
21
+ static shadowRootOptions: {
22
+ mode: ShadowRootMode;
23
+ };
24
+ static getTemplateHTML: typeof getTemplateHTML;
25
+ /** Defaults that a matching `no*` attribute turns off. Every other default is fixed on. */
26
+ static optOuts: readonly BackgroundVideoOptOut[];
27
+ /** Host attributes copied onto the inner video at creation and mirrored as they change. */
28
+ static passthroughAttributes: readonly string[];
29
+ static get observedAttributes(): string[];
30
+ constructor();
31
+ /**
32
+ * Writes muted, loop, and autoplay onto the inner video as properties. The template's attributes only cover markup
33
+ * parsed with its attributes in place; an element created by script gets its `no*` attributes afterwards, and neither
34
+ * Chrome nor Firefox honor a `muted` attribute set after `document.createElement`.
35
+ */
36
+ protected syncPlaybackDefaults(): void;
37
+ abstract get src(): string;
38
+ abstract set src(value: string);
39
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
40
+ /** The inner `<video>` in the shadow root: what plays, and what `play()` / `pause()` belong on. */
41
+ get target(): HTMLVideoElement | null;
42
+ }
43
+ //#endregion
44
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1,97 @@
1
+ import { MediaAttachMixin } from "../../store/media-attach-mixin.js";
2
+ import { getTemplateHTML, getTemplateVideo } from "./template.js";
3
+ import { namedNodeMapToObject } from "@videojs/utils/dom";
4
+ import { pick } from "@videojs/utils/object";
5
+ //#region src/media/background-video/base.ts
6
+ const HTMLElementBase = globalThis.HTMLElement ?? class {};
7
+ const MediaAttachBase = MediaAttachMixin(HTMLElementBase);
8
+ const PLAYBACK_DEFAULTS = [
9
+ "muted",
10
+ "loop",
11
+ "autoplay"
12
+ ];
13
+ /**
14
+ * The shadow setup, `src` wiring, and `target` that `<background-video>` and `<hls-background-video>` share. Each
15
+ * subclass supplies its own `src` and declares which playback defaults authors may opt out of.
16
+ *
17
+ * @internal
18
+ */
19
+ var BackgroundVideoBase = class extends MediaAttachBase {
20
+ static {
21
+ this.shadowRootOptions = { mode: "open" };
22
+ }
23
+ static {
24
+ this.getTemplateHTML = getTemplateHTML;
25
+ }
26
+ static {
27
+ this.optOuts = [
28
+ "muted",
29
+ "loop",
30
+ "autoplay"
31
+ ];
32
+ }
33
+ static {
34
+ this.passthroughAttributes = [
35
+ "controls",
36
+ "controlslist",
37
+ "crossorigin",
38
+ "preload"
39
+ ];
40
+ }
41
+ static get observedAttributes() {
42
+ return [
43
+ "src",
44
+ ...this.optOuts,
45
+ ...this.optOuts.map((name) => `no${name}`),
46
+ ...this.passthroughAttributes
47
+ ];
48
+ }
49
+ constructor() {
50
+ super();
51
+ const ctor = this.constructor;
52
+ if (!this.shadowRoot) {
53
+ const attrs = {
54
+ ...pick(namedNodeMapToObject(this.attributes), ctor.passthroughAttributes),
55
+ playsinline: "",
56
+ disableremoteplayback: "",
57
+ disablepictureinpicture: ""
58
+ };
59
+ for (const name of PLAYBACK_DEFAULTS) if (this.#isDefaultOn(name)) attrs[name] = "";
60
+ this.attachShadow(ctor.shadowRootOptions);
61
+ this.shadowRoot.innerHTML = ctor.getTemplateHTML(attrs);
62
+ }
63
+ this.syncPlaybackDefaults();
64
+ }
65
+ /**
66
+ * Writes muted, loop, and autoplay onto the inner video as properties. The template's attributes only cover markup
67
+ * parsed with its attributes in place; an element created by script gets its `no*` attributes afterwards, and neither
68
+ * Chrome nor Firefox honor a `muted` attribute set after `document.createElement`.
69
+ */
70
+ syncPlaybackDefaults() {
71
+ const target = this.target;
72
+ if (!target) return;
73
+ for (const name of PLAYBACK_DEFAULTS) target[name] = this.#isDefaultOn(name);
74
+ }
75
+ /** On unless its `no*` attribute is set and allowed; an explicit attribute such as `muted` wins over its opt-out. */
76
+ #isDefaultOn(name) {
77
+ const { optOuts } = this.constructor;
78
+ return this.hasAttribute(name) || !optOuts.includes(name) || !this.hasAttribute(`no${name}`);
79
+ }
80
+ attributeChangedCallback(name, oldValue, newValue) {
81
+ if (oldValue === newValue) return;
82
+ const { passthroughAttributes } = this.constructor;
83
+ if (name === "src") this.src = newValue ?? "";
84
+ else if (passthroughAttributes.includes(name)) {
85
+ if (newValue === null) this.target?.removeAttribute(name);
86
+ else this.target?.setAttribute(name, newValue);
87
+ } else this.syncPlaybackDefaults();
88
+ }
89
+ /** The inner `<video>` in the shadow root: what plays, and what `play()` / `pause()` belong on. */
90
+ get target() {
91
+ return getTemplateVideo(this.shadowRoot);
92
+ }
93
+ };
94
+ //#endregion
95
+ export { BackgroundVideoBase };
96
+
97
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","names":[],"sources":["../../../../src/media/background-video/base.ts"],"sourcesContent":["import { namedNodeMapToObject } from '@videojs/utils/dom';\nimport { pick } from '@videojs/utils/object';\n\nimport { MediaAttachMixin } from '../../store/media-attach-mixin';\nimport { getTemplateHTML, getTemplateVideo } from './template';\n\nconst HTMLElementBase = globalThis.HTMLElement ?? class {};\n\n// `MediaAttachMixin` is typed as returning its base, so its lifecycle callbacks\n// aren't visible for `super` to reach. Method syntax lets subclasses override them.\ninterface LifecycleElement extends HTMLElement {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n adoptedCallback?(): void;\n attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;\n}\n\nconst MediaAttachBase = MediaAttachMixin(HTMLElementBase) as unknown as new () => LifecycleElement;\n\nconst PLAYBACK_DEFAULTS = ['muted', 'loop', 'autoplay'] as const;\n\n/** A playback default an element can let authors turn off with a `no*` attribute. */\nexport type BackgroundVideoOptOut = (typeof PLAYBACK_DEFAULTS)[number];\n\n/**\n * The shadow setup, `src` wiring, and `target` that `<background-video>` and `<hls-background-video>` share. Each\n * subclass supplies its own `src` and declares which playback defaults authors may opt out of.\n *\n * @internal\n */\nexport abstract class BackgroundVideoBase extends MediaAttachBase {\n static shadowRootOptions = { mode: 'open' as ShadowRootMode };\n static getTemplateHTML = getTemplateHTML;\n /** Defaults that a matching `no*` attribute turns off. Every other default is fixed on. */\n static optOuts: readonly BackgroundVideoOptOut[] = ['muted', 'loop', 'autoplay'];\n /** Host attributes copied onto the inner video at creation and mirrored as they change. */\n static passthroughAttributes: readonly string[] = ['controls', 'controlslist', 'crossorigin', 'preload'];\n\n static get observedAttributes(): string[] {\n return ['src', ...this.optOuts, ...this.optOuts.map((name) => `no${name}`), ...this.passthroughAttributes];\n }\n\n constructor() {\n super();\n\n const ctor = this.constructor as typeof BackgroundVideoBase;\n\n if (!this.shadowRoot) {\n const attrs: Record<string, string> = {\n ...pick(namedNodeMapToObject(this.attributes), ctor.passthroughAttributes),\n playsinline: '',\n disableremoteplayback: '',\n disablepictureinpicture: '',\n };\n\n for (const name of PLAYBACK_DEFAULTS) {\n if (this.#isDefaultOn(name)) attrs[name] = '';\n }\n\n this.attachShadow(ctor.shadowRootOptions);\n this.shadowRoot!.innerHTML = ctor.getTemplateHTML(attrs);\n }\n\n this.syncPlaybackDefaults();\n }\n\n /**\n * Writes muted, loop, and autoplay onto the inner video as properties. The template's attributes only cover markup\n * parsed with its attributes in place; an element created by script gets its `no*` attributes afterwards, and neither\n * Chrome nor Firefox honor a `muted` attribute set after `document.createElement`.\n */\n protected syncPlaybackDefaults(): void {\n const target = this.target;\n if (!target) return;\n\n for (const name of PLAYBACK_DEFAULTS) target[name] = this.#isDefaultOn(name);\n }\n\n /** On unless its `no*` attribute is set and allowed; an explicit attribute such as `muted` wins over its opt-out. */\n #isDefaultOn(name: BackgroundVideoOptOut): boolean {\n const { optOuts } = this.constructor as typeof BackgroundVideoBase;\n\n return this.hasAttribute(name) || !optOuts.includes(name) || !this.hasAttribute(`no${name}`);\n }\n\n abstract get src(): string;\n abstract set src(value: string);\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n\n const { passthroughAttributes } = this.constructor as typeof BackgroundVideoBase;\n\n if (name === 'src') {\n this.src = newValue ?? '';\n } else if (passthroughAttributes.includes(name)) {\n if (newValue === null) this.target?.removeAttribute(name);\n else this.target?.setAttribute(name, newValue);\n } else {\n this.syncPlaybackDefaults();\n }\n }\n\n /** The inner `<video>` in the shadow root: what plays, and what `play()` / `pause()` belong on. */\n get target(): HTMLVideoElement | null {\n return getTemplateVideo(this.shadowRoot);\n }\n}\n"],"mappings":";;;;;AAMA,MAAM,kBAAkB,WAAW,eAAe,MAAM,CAAC;AAWzD,MAAM,kBAAkB,iBAAiB,eAAe;AAExD,MAAM,oBAAoB;CAAC;CAAS;CAAQ;AAAU;;;;;;;AAWtD,IAAsB,sBAAtB,cAAkD,gBAAgB;;EACrC,KAAA,oBAAA,EAAE,MAAM,OAAyB;;;EACnC,KAAA,kBAAA;;;EAE0B,KAAA,UAAA;GAAC;GAAS;GAAQ;EAAU;;;EAE7B,KAAA,wBAAA;GAAC;GAAY;GAAgB;GAAe;EAAS;;CAEvG,WAAW,qBAA+B;EACxC,OAAO;GAAC;GAAO,GAAG,KAAK;GAAS,GAAG,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM;GAAG,GAAG,KAAK;EAAqB;CAC3G;CAEA,cAAc;EACZ,MAAM;EAEN,MAAM,OAAO,KAAK;EAElB,IAAI,CAAC,KAAK,YAAY;GACpB,MAAM,QAAgC;IACpC,GAAG,KAAK,qBAAqB,KAAK,UAAU,GAAG,KAAK,qBAAqB;IACzE,aAAa;IACb,uBAAuB;IACvB,yBAAyB;GAC3B;GAEA,KAAK,MAAM,QAAQ,mBACjB,IAAI,KAAK,aAAa,IAAI,GAAG,MAAM,QAAQ;GAG7C,KAAK,aAAa,KAAK,iBAAiB;GACxC,KAAK,WAAY,YAAY,KAAK,gBAAgB,KAAK;EACzD;EAEA,KAAK,qBAAqB;CAC5B;;;;;;CAOA,uBAAuC;EACrC,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ;EAEb,KAAK,MAAM,QAAQ,mBAAmB,OAAO,QAAQ,KAAK,aAAa,IAAI;CAC7E;;CAGA,aAAa,MAAsC;EACjD,MAAM,EAAE,YAAY,KAAK;EAEzB,OAAO,KAAK,aAAa,IAAI,KAAK,CAAC,QAAQ,SAAS,IAAI,KAAK,CAAC,KAAK,aAAa,KAAK,MAAM;CAC7F;CAKA,yBAAkC,MAAc,UAAyB,UAA+B;EACtG,IAAI,aAAa,UAAU;EAE3B,MAAM,EAAE,0BAA0B,KAAK;EAEvC,IAAI,SAAS,OACX,KAAK,MAAM,YAAY;OAClB,IAAI,sBAAsB,SAAS,IAAI,GAAG;GAC/C,IAAI,aAAa,MAAM,KAAK,QAAQ,gBAAgB,IAAI;QACnD,KAAK,QAAQ,aAAa,MAAM,QAAQ;EAC/C,OACE,KAAK,qBAAqB;CAE9B;;CAGA,IAAI,SAAkC;EACpC,OAAO,iBAAiB,KAAK,UAAU;CACzC;AACF"}
@@ -3,6 +3,9 @@
3
3
  * The shadow template both background-video elements render: a `<slot>` for a placeholder image, and a `<video>`
4
4
  * stretched over the host.
5
5
  *
6
+ * `attrs` go onto the `<video>` as given; each element decides which of its own attributes to forward. `src` is never
7
+ * among them, since serializing it would start a native load before an engine could take it.
8
+ *
6
9
  * Shared so the two can't drift in presentation. `object-fit` and `object-position` are the only styling hooks — a
7
10
  * background video has no controls to theme.
8
11
  */
@@ -1,27 +1,12 @@
1
1
  import { serializeAttributes } from "@videojs/utils/dom";
2
- import { pick } from "@videojs/utils/object";
3
2
  //#region src/media/background-video/template.ts
4
3
  /**
5
- * Attributes forwarded to the inner `<video>`. `src` is deliberately not one of them: each element decides what to do
6
- * with it, whether that is assigning the inner video or handing it to a playback engine, and serializing it into the
7
- * template would start a native load either way.
8
- */
9
- const VideoAttributes = [
10
- "autoplay",
11
- "controls",
12
- "controlslist",
13
- "crossorigin",
14
- "disablepictureinpicture",
15
- "disableremoteplayback",
16
- "loop",
17
- "muted",
18
- "playsinline",
19
- "preload"
20
- ];
21
- /**
22
4
  * The shadow template both background-video elements render: a `<slot>` for a placeholder image, and a `<video>`
23
5
  * stretched over the host.
24
6
  *
7
+ * `attrs` go onto the `<video>` as given; each element decides which of its own attributes to forward. `src` is never
8
+ * among them, since serializing it would start a native load before an engine could take it.
9
+ *
25
10
  * Shared so the two can't drift in presentation. `object-fit` and `object-position` are the only styling hooks — a
26
11
  * background video has no controls to theme.
27
12
  */
@@ -42,10 +27,18 @@ function getTemplateHTML(attrs) {
42
27
  }
43
28
  </style>
44
29
  <slot></slot>
45
- <video${serializeAttributes(pick(attrs, [...VideoAttributes]))}></video>
30
+ <video${serializeAttributes(attrs)}></video>
46
31
  `;
47
32
  }
33
+ /**
34
+ * The `<video>` from `getTemplateHTML`. Always the shadow one: the template has no slot that would render a light-DOM
35
+ * `<video>`, so anything found there is either the placeholder or not displayed at all.
36
+ */
37
+ function getTemplateVideo(shadowRoot) {
38
+ const video = shadowRoot?.querySelector("video");
39
+ return video instanceof HTMLVideoElement ? video : null;
40
+ }
48
41
  //#endregion
49
- export { VideoAttributes, getTemplateHTML };
42
+ export { getTemplateHTML, getTemplateVideo };
50
43
 
51
44
  //# sourceMappingURL=template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"template.js","names":[],"sources":["../../../../src/media/background-video/template.ts"],"sourcesContent":["import { serializeAttributes } from '@videojs/utils/dom';\nimport { pick } from '@videojs/utils/object';\n\n/**\n * Attributes forwarded to the inner `<video>`. `src` is deliberately not one of them: each element decides what to do\n * with it, whether that is assigning the inner video or handing it to a playback engine, and serializing it into the\n * template would start a native load either way.\n */\nexport const VideoAttributes = [\n 'autoplay',\n 'controls',\n 'controlslist',\n 'crossorigin',\n 'disablepictureinpicture',\n 'disableremoteplayback',\n 'loop',\n 'muted',\n 'playsinline',\n 'preload',\n] as const;\n\n/**\n * The shadow template both background-video elements render: a `<slot>` for a placeholder image, and a `<video>`\n * stretched over the host.\n *\n * Shared so the two can't drift in presentation. `object-fit` and `object-position` are the only styling hooks — a\n * background video has no controls to theme.\n */\nexport function getTemplateHTML(attrs: Record<string, string>) {\n return /*html*/ `\n <style>\n :host {\n position: relative;\n }\n\n video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: var(--media-object-fit, inherit);\n object-position: var(--media-object-position, 50% 50%);\n }\n </style>\n <slot></slot>\n <video${serializeAttributes(pick(attrs, [...VideoAttributes]))}></video>\n `;\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,gBAAgB,OAA+B;CAC7D,OAAgB;;;;;;;;;;;;;;;;YAgBN,oBAAoB,KAAK,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE;;AAEnE"}
1
+ {"version":3,"file":"template.js","names":[],"sources":["../../../../src/media/background-video/template.ts"],"sourcesContent":["import { serializeAttributes } from '@videojs/utils/dom';\n\n/**\n * The shadow template both background-video elements render: a `<slot>` for a placeholder image, and a `<video>`\n * stretched over the host.\n *\n * `attrs` go onto the `<video>` as given; each element decides which of its own attributes to forward. `src` is never\n * among them, since serializing it would start a native load before an engine could take it.\n *\n * Shared so the two can't drift in presentation. `object-fit` and `object-position` are the only styling hooks — a\n * background video has no controls to theme.\n */\nexport function getTemplateHTML(attrs: Record<string, string>) {\n return /*html*/ `\n <style>\n :host {\n position: relative;\n }\n\n video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: var(--media-object-fit, inherit);\n object-position: var(--media-object-position, 50% 50%);\n }\n </style>\n <slot></slot>\n <video${serializeAttributes(attrs)}></video>\n `;\n}\n\n/**\n * The `<video>` from `getTemplateHTML`. Always the shadow one: the template has no slot that would render a light-DOM\n * `<video>`, so anything found there is either the placeholder or not displayed at all.\n */\nexport function getTemplateVideo(shadowRoot: ShadowRoot | null): HTMLVideoElement | null {\n const video = shadowRoot?.querySelector('video');\n\n return video instanceof HTMLVideoElement ? video : null;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,gBAAgB,OAA+B;CAC7D,OAAgB;;;;;;;;;;;;;;;;YAgBN,oBAAoB,KAAK,EAAE;;AAEvC;;;;;AAMA,SAAgB,iBAAiB,YAAwD;CACvF,MAAM,QAAQ,YAAY,cAAc,OAAO;CAE/C,OAAO,iBAAiB,mBAAmB,QAAQ;AACrD"}
@@ -1,14 +1,7 @@
1
- import { getTemplateHTML } from "../background-video/template.js";
1
+ import { BackgroundVideoBase, BackgroundVideoOptOut } from "../background-video/base.js";
2
2
  import { Media } from "@videojs/media/dom";
3
3
  import { HlsBackgroundVideoAdapter, HlsVideoMediaError } from "@videojs/spf/adapters/hls-background-video";
4
4
  //#region src/media/hls-background-video/adapter.d.ts
5
- interface LifecycleElement extends HTMLElement {
6
- connectedCallback?(): void;
7
- disconnectedCallback?(): void;
8
- adoptedCallback?(): void;
9
- attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;
10
- }
11
- declare const HlsBackgroundVideoBase: new () => LifecycleElement;
12
5
  /**
13
6
  * A muted, looping, chrome-less video over the SPF background-video engine.
14
7
  *
@@ -20,8 +13,9 @@ declare const HlsBackgroundVideoBase: new () => LifecycleElement;
20
13
  * package, whose `audio`, `debug`, `preload`, and `max-resolution` attributes are all deliberately absent. Capping
21
14
  * which rendition is fetched is a delivery param on the URL — `?max_resolution=720p` on a Mux stream, for one — which
22
15
  * keeps the renditions it excludes out of the manifest rather than merely unpicked; `preload` would have nothing to
23
- * say, since the engine loads from the moment it has a source. And unlike `<background-video>` there are no `nomuted` /
24
- * `noloop` / `noautoplay` opt-outs: those three are what this element is for, so the adapter fixes them on at attach.
16
+ * say, since the engine loads from the moment it has a source. Muted is fixed on: the engine drops audio, so there is
17
+ * nothing to unmute. `noloop` and `noautoplay` opt out as on `<background-video>`, so a page can play the video once,
18
+ * or hold it until it has checked the motion preference.
25
19
  *
26
20
  * Takes no structured `source` — `src` is an HLS URL, as the package it replaces required. Mux playback-ID identity,
27
21
  * poster, and storyboard belong to `<mux-video>`; none of them mean anything without controls to hang them on.
@@ -43,13 +37,10 @@ declare const HlsBackgroundVideoBase: new () => LifecycleElement;
43
37
  * `<mux-background-video>` is this element under the name the package it replaces used. Same class, so the tag is a
44
38
  * naming choice and nothing more.
45
39
  */
46
- export declare class HlsBackgroundVideo extends HlsBackgroundVideoBase {
40
+ export declare class HlsBackgroundVideo extends BackgroundVideoBase {
47
41
  #private;
48
- static shadowRootOptions: {
49
- mode: ShadowRootMode;
50
- };
51
- static getTemplateHTML: typeof getTemplateHTML;
52
- static get observedAttributes(): string[];
42
+ static optOuts: readonly BackgroundVideoOptOut[];
43
+ static passthroughAttributes: readonly string[];
53
44
  constructor();
54
45
  /** Register the Media (not the inner `<video>`) with the provider. */
55
46
  getMediaTarget(): Media | null;
@@ -59,8 +50,7 @@ export declare class HlsBackgroundVideo extends HlsBackgroundVideoBase {
59
50
  */
60
51
  get adapter(): HlsBackgroundVideoAdapter;
61
52
  disconnectedCallback(): void;
62
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
63
- /** The inner `<video>` the engine renders into. */
53
+ /** Same element as `target`. */
64
54
  get video(): HTMLVideoElement | null;
65
55
  /**
66
56
  * What made the current source unplayable, or `null`. An SVTA code rather than a `MediaError` one — 99001 where this
@@ -1,10 +1,6 @@
1
- import { MediaAttachMixin } from "../../store/media-attach-mixin.js";
2
- import { getTemplateHTML } from "../background-video/template.js";
3
- import { namedNodeMapToObject } from "@videojs/utils/dom";
1
+ import { BackgroundVideoBase } from "../background-video/base.js";
4
2
  import { HlsBackgroundVideoAdapter } from "@videojs/spf/adapters/hls-background-video";
5
3
  //#region src/media/hls-background-video/adapter.ts
6
- const HTMLElementBase = globalThis.HTMLElement ?? class {};
7
- const HlsBackgroundVideoBase = MediaAttachMixin(HTMLElementBase);
8
4
  /**
9
5
  * A muted, looping, chrome-less video over the SPF background-video engine.
10
6
  *
@@ -16,8 +12,9 @@ const HlsBackgroundVideoBase = MediaAttachMixin(HTMLElementBase);
16
12
  * package, whose `audio`, `debug`, `preload`, and `max-resolution` attributes are all deliberately absent. Capping
17
13
  * which rendition is fetched is a delivery param on the URL — `?max_resolution=720p` on a Mux stream, for one — which
18
14
  * keeps the renditions it excludes out of the manifest rather than merely unpicked; `preload` would have nothing to
19
- * say, since the engine loads from the moment it has a source. And unlike `<background-video>` there are no `nomuted` /
20
- * `noloop` / `noautoplay` opt-outs: those three are what this element is for, so the adapter fixes them on at attach.
15
+ * say, since the engine loads from the moment it has a source. Muted is fixed on: the engine drops audio, so there is
16
+ * nothing to unmute. `noloop` and `noautoplay` opt out as on `<background-video>`, so a page can play the video once,
17
+ * or hold it until it has checked the motion preference.
21
18
  *
22
19
  * Takes no structured `source` — `src` is an HLS URL, as the package it replaces required. Mux playback-ID identity,
23
20
  * poster, and storyboard belong to `<mux-video>`; none of them mean anything without controls to hang them on.
@@ -39,34 +36,23 @@ const HlsBackgroundVideoBase = MediaAttachMixin(HTMLElementBase);
39
36
  * `<mux-background-video>` is this element under the name the package it replaces used. Same class, so the tag is a
40
37
  * naming choice and nothing more.
41
38
  */
42
- var HlsBackgroundVideo = class extends HlsBackgroundVideoBase {
39
+ var HlsBackgroundVideo = class extends BackgroundVideoBase {
43
40
  static {
44
- this.shadowRootOptions = { mode: "open" };
41
+ this.optOuts = ["loop", "autoplay"];
45
42
  }
46
43
  static {
47
- this.getTemplateHTML = getTemplateHTML;
48
- }
49
- static get observedAttributes() {
50
- return ["src"];
44
+ this.passthroughAttributes = [
45
+ "controls",
46
+ "controlslist",
47
+ "crossorigin"
48
+ ];
51
49
  }
52
50
  #media = new HlsBackgroundVideoAdapter();
53
51
  constructor() {
54
52
  super();
55
- if (!this.shadowRoot) {
56
- this.attachShadow(this.constructor.shadowRootOptions);
57
- const attrs = {
58
- ...namedNodeMapToObject(this.attributes),
59
- muted: "",
60
- loop: "",
61
- autoplay: "",
62
- playsinline: "",
63
- disableremoteplayback: "",
64
- disablepictureinpicture: ""
65
- };
66
- this.shadowRoot.innerHTML = getTemplateHTML(attrs);
67
- }
68
- const video = this.video;
69
- if (video) this.#media.attach(video);
53
+ const target = this.target;
54
+ if (target) this.#media.attach(target);
55
+ this.syncPlaybackDefaults();
70
56
  this.#media.addEventListener("error", () => this.dispatchEvent(new Event("error")));
71
57
  }
72
58
  /** Register the Media (not the inner `<video>`) with the provider. */
@@ -87,14 +73,9 @@ var HlsBackgroundVideo = class extends HlsBackgroundVideoBase {
87
73
  if (!this.isConnected) this.#media.destroy();
88
74
  });
89
75
  }
90
- attributeChangedCallback(name, oldValue, newValue) {
91
- if (oldValue === newValue) return;
92
- if (name === "src") this.src = newValue ?? "";
93
- }
94
- /** The inner `<video>` the engine renders into. */
76
+ /** Same element as `target`. */
95
77
  get video() {
96
- const video = this.shadowRoot?.querySelector("video");
97
- return video instanceof HTMLVideoElement ? video : null;
78
+ return this.target;
98
79
  }
99
80
  /**
100
81
  * What made the current source unplayable, or `null`. An SVTA code rather than a `MediaError` one — 99001 where this
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","names":[],"sources":["../../../../src/media/hls-background-video/adapter.ts"],"sourcesContent":["import type { Media } from '@videojs/media/dom';\nimport { HlsBackgroundVideoAdapter, type HlsVideoMediaError } from '@videojs/spf/adapters/hls-background-video';\nimport { namedNodeMapToObject } from '@videojs/utils/dom';\n\nimport { MediaAttachMixin } from '../../store/media-attach-mixin';\nimport { getTemplateHTML } from '../background-video/template';\n\nconst HTMLElementBase = globalThis.HTMLElement ?? class {};\n\n// `MediaAttachMixin` is typed as returning its base, so its `disconnectedCallback`\n// isn't visible for `super` to reach. `LifecycleElement` declares the lifecycle\n// callbacks this element overrides; method syntax lets a subclass override them.\ninterface LifecycleElement extends HTMLElement {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n adoptedCallback?(): void;\n attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;\n}\n\nconst HlsBackgroundVideoBase = MediaAttachMixin(HTMLElementBase) as unknown as new () => LifecycleElement;\n\n/**\n * A muted, looping, chrome-less video over the SPF background-video engine.\n *\n * The SPF-backed counterpart to `<background-video>`, which plays its source natively. This one streams HLS through the\n * engine, which pins a single rendition for the session rather than adapting, and drops audio and text handling\n * entirely — the shape an ambient hero video actually wants.\n *\n * Nearer an image than a player, and `src` is the whole surface. Replaces the standalone `mux-background-video`\n * package, whose `audio`, `debug`, `preload`, and `max-resolution` attributes are all deliberately absent. Capping\n * which rendition is fetched is a delivery param on the URL — `?max_resolution=720p` on a Mux stream, for one — which\n * keeps the renditions it excludes out of the manifest rather than merely unpicked; `preload` would have nothing to\n * say, since the engine loads from the moment it has a source. And unlike `<background-video>` there are no `nomuted` /\n * `noloop` / `noautoplay` opt-outs: those three are what this element is for, so the adapter fixes them on at attach.\n *\n * Takes no structured `source` — `src` is an HLS URL, as the package it replaces required. Mux playback-ID identity,\n * poster, and storyboard belong to `<mux-video>`; none of them mean anything without controls to hang them on.\n *\n * Nothing about an unplayable source reaches the inner `<video>` on its own, so `error` on it stays null and the\n * element sits at `readyState 0`. The engine reports each condition and logs it, the Media promotes the fatal one, and\n * this element re-fires it as its own `error` / `'error'` — the one place a consumer holding the element can see a\n * source that never appears.\n *\n * @example\n * ```html\n * <hls-background-video src=\"https://stream.mux.com/PLAYBACK_ID.m3u8?max_resolution=720p\">\n * <img src=\"https://image.mux.com/PLAYBACK_ID/thumbnail.webp?time=0\" alt=\"\" />\n * </hls-background-video>\n * ```;\n *\n * @fires error - Fired when a fatal condition is reported. Read `error` for it.\n *\n * `<mux-background-video>` is this element under the name the package it replaces used. Same class, so the tag is a\n * naming choice and nothing more.\n */\n// Deliberately not `CustomMediaElement`, matching `<background-video>`: a\n// background video needs one property, not the full WHATWG media API.\nexport class HlsBackgroundVideo extends HlsBackgroundVideoBase {\n static shadowRootOptions = { mode: 'open' as ShadowRootMode };\n static getTemplateHTML = getTemplateHTML;\n\n static get observedAttributes(): string[] {\n return ['src'];\n }\n\n #media = new HlsBackgroundVideoAdapter();\n\n constructor() {\n super();\n\n if (!this.shadowRoot) {\n this.attachShadow((this.constructor as typeof HlsBackgroundVideo).shadowRootOptions);\n\n const attrs = {\n ...namedNodeMapToObject(this.attributes),\n muted: '',\n loop: '',\n autoplay: '',\n playsinline: '',\n disableremoteplayback: '',\n disablepictureinpicture: '',\n };\n\n this.shadowRoot!.innerHTML = getTemplateHTML(attrs);\n }\n\n // Neither Chrome nor Firefox honor a `muted` attribute set after\n // `document.createElement`, and autoplay is refused without it. Attaching is\n // what sets the property — along with the rest of the fixed behavior — so\n // nothing here needs to repeat it.\n const video = this.video;\n\n if (video) this.#media.attach(video);\n\n // Re-fired rather than bridged on demand the way `CustomMediaElement` does\n // it: one listener for the one event this element has, on a Media it owns\n // for its whole life, is less than the machinery to defer it would cost.\n this.#media.addEventListener('error', () => this.dispatchEvent(new Event('error')));\n }\n\n /** Register the Media (not the inner `<video>`) with the provider. */\n getMediaTarget(): Media | null {\n return this.#media as unknown as Media;\n }\n\n /**\n * The Media driving the inner `<video>`, matching `adapter` on `CustomMediaElement`. Call `adapter.destroy()` to\n * release the engine after `keep-alive` kept it running past removal.\n */\n get adapter(): HlsBackgroundVideoAdapter {\n return this.#media;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback?.();\n\n // Only the element's own `keep-alive` counts: an ancestor's `destroy()` can't reach this engine, so inheriting it\n // would leave the engine running with nothing to release it.\n if (this.hasAttribute('keep-alive')) return;\n\n // Deferred so a synchronous reparent (remove then insert) doesn't tear down\n // the engine, matching `CustomMediaElement`.\n queueMicrotask(() => {\n if (!this.isConnected) this.#media.destroy();\n });\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n\n if (name === 'src') this.src = newValue ?? '';\n }\n\n /** The inner `<video>` the engine renders into. */\n get video(): HTMLVideoElement | null {\n const video = this.shadowRoot?.querySelector('video');\n\n return video instanceof HTMLVideoElement ? video : null;\n }\n\n /**\n * What made the current source unplayable, or `null`. An SVTA code rather than a `MediaError` one — 99001 where this\n * player has no pipeline for what the source needs, with the specifics logged. Reset by a new source, and not on the\n * inner `<video>`, which never learns of it.\n */\n get error(): HlsVideoMediaError | null {\n return this.#media.error;\n }\n\n /** HLS manifest URL. Assigning a new one restarts playback from scratch. */\n get src(): string {\n return this.#media.src;\n }\n\n set src(value: string) {\n this.#media.src = value;\n }\n}\n"],"mappings":";;;;;AAOA,MAAM,kBAAkB,WAAW,eAAe,MAAM,CAAC;AAYzD,MAAM,yBAAyB,iBAAiB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsC/D,IAAa,qBAAb,cAAwC,uBAAuB;;EAClC,KAAA,oBAAA,EAAE,MAAM,OAAyB;;;EACnC,KAAA,kBAAA;;CAEzB,WAAW,qBAA+B;EACxC,OAAO,CAAC,KAAK;CACf;CAEA,SAAS,IAAI,0BAA0B;CAEvC,cAAc;EACZ,MAAM;EAEN,IAAI,CAAC,KAAK,YAAY;GACpB,KAAK,aAAc,KAAK,YAA0C,iBAAiB;GAEnF,MAAM,QAAQ;IACZ,GAAG,qBAAqB,KAAK,UAAU;IACvC,OAAO;IACP,MAAM;IACN,UAAU;IACV,aAAa;IACb,uBAAuB;IACvB,yBAAyB;GAC3B;GAEA,KAAK,WAAY,YAAY,gBAAgB,KAAK;EACpD;EAMA,MAAM,QAAQ,KAAK;EAEnB,IAAI,OAAO,KAAK,OAAO,OAAO,KAAK;EAKnC,KAAK,OAAO,iBAAiB,eAAe,KAAK,cAAc,IAAI,MAAM,OAAO,CAAC,CAAC;CACpF;;CAGA,iBAA+B;EAC7B,OAAO,KAAK;CACd;;;;;CAMA,IAAI,UAAqC;EACvC,OAAO,KAAK;CACd;CAEA,uBAAsC;EACpC,MAAM,uBAAuB;EAI7B,IAAI,KAAK,aAAa,YAAY,GAAG;EAIrC,qBAAqB;GACnB,IAAI,CAAC,KAAK,aAAa,KAAK,OAAO,QAAQ;EAC7C,CAAC;CACH;CAEA,yBAAyB,MAAc,UAAyB,UAA+B;EAC7F,IAAI,aAAa,UAAU;EAE3B,IAAI,SAAS,OAAO,KAAK,MAAM,YAAY;CAC7C;;CAGA,IAAI,QAAiC;EACnC,MAAM,QAAQ,KAAK,YAAY,cAAc,OAAO;EAEpD,OAAO,iBAAiB,mBAAmB,QAAQ;CACrD;;;;;;CAOA,IAAI,QAAmC;EACrC,OAAO,KAAK,OAAO;CACrB;;CAGA,IAAI,MAAc;EAChB,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,IAAI,OAAe;EACrB,KAAK,OAAO,MAAM;CACpB;AACF"}
1
+ {"version":3,"file":"adapter.js","names":[],"sources":["../../../../src/media/hls-background-video/adapter.ts"],"sourcesContent":["import type { Media } from '@videojs/media/dom';\nimport { HlsBackgroundVideoAdapter, type HlsVideoMediaError } from '@videojs/spf/adapters/hls-background-video';\n\nimport { BackgroundVideoBase, type BackgroundVideoOptOut } from '../background-video/base';\n\n/**\n * A muted, looping, chrome-less video over the SPF background-video engine.\n *\n * The SPF-backed counterpart to `<background-video>`, which plays its source natively. This one streams HLS through the\n * engine, which pins a single rendition for the session rather than adapting, and drops audio and text handling\n * entirely — the shape an ambient hero video actually wants.\n *\n * Nearer an image than a player, and `src` is the whole surface. Replaces the standalone `mux-background-video`\n * package, whose `audio`, `debug`, `preload`, and `max-resolution` attributes are all deliberately absent. Capping\n * which rendition is fetched is a delivery param on the URL — `?max_resolution=720p` on a Mux stream, for one — which\n * keeps the renditions it excludes out of the manifest rather than merely unpicked; `preload` would have nothing to\n * say, since the engine loads from the moment it has a source. Muted is fixed on: the engine drops audio, so there is\n * nothing to unmute. `noloop` and `noautoplay` opt out as on `<background-video>`, so a page can play the video once,\n * or hold it until it has checked the motion preference.\n *\n * Takes no structured `source` — `src` is an HLS URL, as the package it replaces required. Mux playback-ID identity,\n * poster, and storyboard belong to `<mux-video>`; none of them mean anything without controls to hang them on.\n *\n * Nothing about an unplayable source reaches the inner `<video>` on its own, so `error` on it stays null and the\n * element sits at `readyState 0`. The engine reports each condition and logs it, the Media promotes the fatal one, and\n * this element re-fires it as its own `error` / `'error'` — the one place a consumer holding the element can see a\n * source that never appears.\n *\n * @example\n * ```html\n * <hls-background-video src=\"https://stream.mux.com/PLAYBACK_ID.m3u8?max_resolution=720p\">\n * <img src=\"https://image.mux.com/PLAYBACK_ID/thumbnail.webp?time=0\" alt=\"\" />\n * </hls-background-video>\n * ```;\n *\n * @fires error - Fired when a fatal condition is reported. Read `error` for it.\n *\n * `<mux-background-video>` is this element under the name the package it replaces used. Same class, so the tag is a\n * naming choice and nothing more.\n */\n// Deliberately not `CustomMediaElement`, matching `<background-video>`: a\n// background video needs one property, not the full WHATWG media API.\nexport class HlsBackgroundVideo extends BackgroundVideoBase {\n static override optOuts: readonly BackgroundVideoOptOut[] = ['loop', 'autoplay'];\n // No `preload`: the engine loads as soon as it has a source, and attaching fixes `preload=\"auto\"`.\n static override passthroughAttributes: readonly string[] = ['controls', 'controlslist', 'crossorigin'];\n\n #media = new HlsBackgroundVideoAdapter();\n\n constructor() {\n super();\n\n const target = this.target;\n\n if (target) this.#media.attach(target);\n\n // Attaching fixes loop and autoplay on, so their opt-outs have to be reapplied after it.\n this.syncPlaybackDefaults();\n\n // Re-fired rather than bridged on demand the way `CustomMediaElement` does\n // it: one listener for the one event this element has, on a Media it owns\n // for its whole life, is less than the machinery to defer it would cost.\n this.#media.addEventListener('error', () => this.dispatchEvent(new Event('error')));\n }\n\n /** Register the Media (not the inner `<video>`) with the provider. */\n getMediaTarget(): Media | null {\n return this.#media as unknown as Media;\n }\n\n /**\n * The Media driving the inner `<video>`, matching `adapter` on `CustomMediaElement`. Call `adapter.destroy()` to\n * release the engine after `keep-alive` kept it running past removal.\n */\n get adapter(): HlsBackgroundVideoAdapter {\n return this.#media;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback?.();\n\n // Only the element's own `keep-alive` counts: an ancestor's `destroy()` can't reach this engine, so inheriting it\n // would leave the engine running with nothing to release it.\n if (this.hasAttribute('keep-alive')) return;\n\n // Deferred so a synchronous reparent (remove then insert) doesn't tear down\n // the engine, matching `CustomMediaElement`.\n queueMicrotask(() => {\n if (!this.isConnected) this.#media.destroy();\n });\n }\n\n /** Same element as `target`. */\n get video(): HTMLVideoElement | null {\n return this.target;\n }\n\n /**\n * What made the current source unplayable, or `null`. An SVTA code rather than a `MediaError` one — 99001 where this\n * player has no pipeline for what the source needs, with the specifics logged. Reset by a new source, and not on the\n * inner `<video>`, which never learns of it.\n */\n get error(): HlsVideoMediaError | null {\n return this.#media.error;\n }\n\n /** HLS manifest URL. Assigning a new one restarts playback from scratch. */\n override get src(): string {\n return this.#media.src;\n }\n\n override set src(value: string) {\n this.#media.src = value;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAa,qBAAb,cAAwC,oBAAoB;;EACE,KAAA,UAAA,CAAC,QAAQ,UAAU;;;EAEpB,KAAA,wBAAA;GAAC;GAAY;GAAgB;EAAa;;CAErG,SAAS,IAAI,0BAA0B;CAEvC,cAAc;EACZ,MAAM;EAEN,MAAM,SAAS,KAAK;EAEpB,IAAI,QAAQ,KAAK,OAAO,OAAO,MAAM;EAGrC,KAAK,qBAAqB;EAK1B,KAAK,OAAO,iBAAiB,eAAe,KAAK,cAAc,IAAI,MAAM,OAAO,CAAC,CAAC;CACpF;;CAGA,iBAA+B;EAC7B,OAAO,KAAK;CACd;;;;;CAMA,IAAI,UAAqC;EACvC,OAAO,KAAK;CACd;CAEA,uBAAsC;EACpC,MAAM,uBAAuB;EAI7B,IAAI,KAAK,aAAa,YAAY,GAAG;EAIrC,qBAAqB;GACnB,IAAI,CAAC,KAAK,aAAa,KAAK,OAAO,QAAQ;EAC7C,CAAC;CACH;;CAGA,IAAI,QAAiC;EACnC,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,QAAmC;EACrC,OAAO,KAAK,OAAO;CACrB;;CAGA,IAAa,MAAc;EACzB,OAAO,KAAK,OAAO;CACrB;CAEA,IAAa,IAAI,OAAe;EAC9B,KAAK,OAAO,MAAM;CACpB;AACF"}
@@ -40,6 +40,8 @@ export declare class CaptionsButtonElement extends MediaButtonElement<CaptionsBu
40
40
  selectSubtitlesTrack: (id: string | null) => void;
41
41
  chaptersCues: import("@videojs/media").MediaTextCue[];
42
42
  thumbnailsTrack: import("@videojs/media").MediaThumbnailsTrack | null;
43
+ addTextTrack: import("@videojs/core").AddTextTrack;
44
+ removeTextTrack: (id: string) => void;
43
45
  } | undefined>;
44
46
  protected readonly hotkeyAction = "toggleSubtitles";
45
47
  connectedCallback(): void;
@@ -6,7 +6,8 @@ import { Text } from "@videojs/core/i18n";
6
6
  /**
7
7
  * Menu radio group that generates an Off `<media-menu-radio-item>` plus one per captions and subtitles track, and
8
8
  * shares the selected label and availability with an enclosing menu. An optional `<template>` holding one
9
- * `<media-menu-radio-item>` customizes each generated item.
9
+ * `<media-menu-radio-item>` customizes each generated item; its `data-part` `label` and `badge` descendants receive the
10
+ * track's text.
10
11
  */
11
12
  export declare class CaptionsRadioGroupElement extends MenuRadioGroupElement {
12
13
  #private;
@@ -11,7 +11,8 @@ import { translateText } from "@videojs/core/i18n";
11
11
  /**
12
12
  * Menu radio group that generates an Off `<media-menu-radio-item>` plus one per captions and subtitles track, and
13
13
  * shares the selected label and availability with an enclosing menu. An optional `<template>` holding one
14
- * `<media-menu-radio-item>` customizes each generated item.
14
+ * `<media-menu-radio-item>` customizes each generated item; its `data-part` `label` and `badge` descendants receive the
15
+ * track's text.
15
16
  */
16
17
  var CaptionsRadioGroupElement = class extends MenuRadioGroupElement {
17
18
  constructor(..._args) {
@@ -23,6 +24,8 @@ var CaptionsRadioGroupElement = class extends MenuRadioGroupElement {
23
24
  this.#i18n = new I18nController(this, i18nContext);
24
25
  this.#mediaState = new PlayerController(this, playerContext, selectTextTrack);
25
26
  this.#options = new RadioOptionsController(this, {
27
+ renderItem: (item, label, option) => this.#setContent(item, label, option.badge),
28
+ getOptionCacheKey: (option) => option.badge ?? "",
26
29
  setItemAttributes: (item, option) => item.setAttribute("data-track", option.value),
27
30
  onValueChange: (value) => {
28
31
  const media = this.#mediaState.value;
@@ -67,6 +70,16 @@ var CaptionsRadioGroupElement = class extends MenuRadioGroupElement {
67
70
  super.update(changed);
68
71
  if (state) applyStateDataAttrs(this, state, CaptionsRadioGroupDataAttrs);
69
72
  }
73
+ #setContent(item, label, badge) {
74
+ const labelPart = item.querySelector("[data-part~=\"label\"]");
75
+ const badgePart = item.querySelector("[data-part~=\"badge\"]");
76
+ if (labelPart) labelPart.textContent = label;
77
+ if (badgePart) {
78
+ badgePart.textContent = badge ?? "";
79
+ badgePart.hidden = !badge;
80
+ }
81
+ if (!labelPart && !badgePart) item.textContent = [label, badge].filter(Boolean).join(" ");
82
+ }
70
83
  };
71
84
  //#endregion
72
85
  export { CaptionsRadioGroupElement };
@@ -1 +1 @@
1
- {"version":3,"file":"element.js","names":[],"sources":["../../../../src/ui/captions-radio-group/element.ts"],"sourcesContent":["import {\n CaptionsRadioGroupCore,\n CaptionsRadioGroupDataAttrs,\n type CaptionsRadioGroupOption,\n type CaptionsRadioGroupState,\n} from '@videojs/core';\nimport { applyStateDataAttrs, logMissingFeature, selectTextTrack } from '@videojs/core/dom';\nimport { type Text, translateText } from '@videojs/core/i18n';\nimport type { PropertyDeclarationMap, PropertyValues } from '@videojs/element';\n\nimport { i18nContext } from '../../i18n/context';\nimport { I18nController } from '../../i18n/controller';\nimport { playerContext } from '../../player/context';\nimport { PlayerController } from '../../player/controller';\nimport { MenuRadioGroupElement } from '../menu/radio-group';\nimport { RadioOptionsController } from '../radio-options/controller';\n\n/**\n * Menu radio group that generates an Off `<media-menu-radio-item>` plus one per captions and subtitles track, and\n * shares the selected label and availability with an enclosing menu. An optional `<template>` holding one\n * `<media-menu-radio-item>` customizes each generated item.\n */\nexport class CaptionsRadioGroupElement extends MenuRadioGroupElement {\n static override readonly tagName = 'media-captions-radio-group';\n\n static override properties = {\n ...MenuRadioGroupElement.properties,\n disabled: { type: Boolean },\n label: { type: String },\n } satisfies PropertyDeclarationMap<'value' | 'label' | 'disabled'>;\n\n disabled = false;\n label: Text | string = '';\n formatTrack = CaptionsRadioGroupCore.defaultProps.formatTrack;\n\n readonly #core = new CaptionsRadioGroupCore();\n readonly #i18n = new I18nController(this, i18nContext);\n readonly #mediaState = new PlayerController(this, playerContext, selectTextTrack);\n readonly #options = new RadioOptionsController<CaptionsRadioGroupOption>(this, {\n setItemAttributes: (item, option) => item.setAttribute('data-track', option.value),\n onValueChange: (value) => {\n const media = this.#mediaState.value;\n\n if (media) this.#core.selectValue(media, value);\n },\n });\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n if (this.destroyed) return;\n\n if (__DEV__ && !this.#mediaState.value && this.#mediaState.displayName) {\n logMissingFeature(this.localName, this.#mediaState.displayName);\n }\n }\n\n protected override update(changed: PropertyValues): void {\n const media = this.#mediaState.value;\n let state: CaptionsRadioGroupState | null = null;\n\n if (media) {\n this.#core.setProps({ formatTrack: this.formatTrack, disabled: this.disabled, label: this.label });\n this.#core.setMedia(media);\n state = this.#core.getState();\n\n this.applyDefaultAriaLabel(translateText(this.#core.getLabel(state), this.#i18n.value));\n this.#options.sync(state, this.#i18n.value, this.#i18n.locale);\n this.publishMenuOptionState(state.disabled, state.hidden, state.availability);\n } else {\n this.publishMenuOptionState(true, true, 'unsupported');\n }\n\n super.update(changed);\n\n if (state) applyStateDataAttrs(this, state, CaptionsRadioGroupDataAttrs);\n }\n}\n\nexport namespace CaptionsRadioGroupElement {\n export type State = CaptionsRadioGroupState;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,IAAa,4BAAb,cAA+C,sBAAsB;;;EASxD,KAAA,WAAA;EACY,KAAA,QAAA;EACT,KAAA,cAAA,uBAAuB,aAAa;EAEjC,KAAA,QAAA,IAAI,uBAAuB;EAC3B,KAAA,QAAA,IAAI,eAAe,MAAM,WAAW;EAC9B,KAAA,cAAA,IAAI,iBAAiB,MAAM,eAAe,eAAe;EAC5D,KAAA,WAAA,IAAI,uBAAiD,MAAM;GAC7E,oBAAoB,MAAM,WAAW,KAAK,aAAa,cAAc,OAAO,KAAK;GACjF,gBAAgB,UAAU;IACxB,MAAM,QAAQ,KAAK,YAAY;IAE/B,IAAI,OAAO,KAAK,MAAM,YAAY,OAAO,KAAK;GAChD;EACF,CAAC;;;EAtBkC,KAAA,UAAA;;;EAEN,KAAA,aAAA;GAC3B,GAAG,sBAAsB;GACzB,UAAU,EAAE,MAAM,QAAQ;GAC1B,OAAO,EAAE,MAAM,OAAO;EACxB;;CAMA;CACA;CACA;CACA;CASA,oBAAmC;EACjC,MAAM,kBAAkB;EAExB,IAAI,KAAK,WAAW;EAEpB,IAAe,CAAC,KAAK,YAAY,SAAS,KAAK,YAAY,aACzD,kBAAkB,KAAK,WAAW,KAAK,YAAY,WAAW;CAElE;CAEA,OAA0B,SAA+B;EACvD,MAAM,QAAQ,KAAK,YAAY;EAC/B,IAAI,QAAwC;EAE5C,IAAI,OAAO;GACT,KAAK,MAAM,SAAS;IAAE,aAAa,KAAK;IAAa,UAAU,KAAK;IAAU,OAAO,KAAK;GAAM,CAAC;GACjG,KAAK,MAAM,SAAS,KAAK;GACzB,QAAQ,KAAK,MAAM,SAAS;GAE5B,KAAK,sBAAsB,cAAc,KAAK,MAAM,SAAS,KAAK,GAAG,KAAK,MAAM,KAAK,CAAC;GACtF,KAAK,SAAS,KAAK,OAAO,KAAK,MAAM,OAAO,KAAK,MAAM,MAAM;GAC7D,KAAK,uBAAuB,MAAM,UAAU,MAAM,QAAQ,MAAM,YAAY;EAC9E,OACE,KAAK,uBAAuB,MAAM,MAAM,aAAa;EAGvD,MAAM,OAAO,OAAO;EAEpB,IAAI,OAAO,oBAAoB,MAAM,OAAO,2BAA2B;CACzE;AACF"}
1
+ {"version":3,"file":"element.js","names":[],"sources":["../../../../src/ui/captions-radio-group/element.ts"],"sourcesContent":["import {\n CaptionsRadioGroupCore,\n CaptionsRadioGroupDataAttrs,\n type CaptionsRadioGroupOption,\n type CaptionsRadioGroupState,\n} from '@videojs/core';\nimport { applyStateDataAttrs, logMissingFeature, selectTextTrack } from '@videojs/core/dom';\nimport { type Text, translateText } from '@videojs/core/i18n';\nimport type { PropertyDeclarationMap, PropertyValues } from '@videojs/element';\n\nimport { i18nContext } from '../../i18n/context';\nimport { I18nController } from '../../i18n/controller';\nimport { playerContext } from '../../player/context';\nimport { PlayerController } from '../../player/controller';\nimport { MenuRadioGroupElement } from '../menu/radio-group';\nimport type { MenuRadioItemElement } from '../menu/radio-item';\nimport { RadioOptionsController } from '../radio-options/controller';\n\n/**\n * Menu radio group that generates an Off `<media-menu-radio-item>` plus one per captions and subtitles track, and\n * shares the selected label and availability with an enclosing menu. An optional `<template>` holding one\n * `<media-menu-radio-item>` customizes each generated item; its `data-part` `label` and `badge` descendants receive the\n * track's text.\n */\nexport class CaptionsRadioGroupElement extends MenuRadioGroupElement {\n static override readonly tagName = 'media-captions-radio-group';\n\n static override properties = {\n ...MenuRadioGroupElement.properties,\n disabled: { type: Boolean },\n label: { type: String },\n } satisfies PropertyDeclarationMap<'value' | 'label' | 'disabled'>;\n\n disabled = false;\n label: Text | string = '';\n formatTrack = CaptionsRadioGroupCore.defaultProps.formatTrack;\n\n readonly #core = new CaptionsRadioGroupCore();\n readonly #i18n = new I18nController(this, i18nContext);\n readonly #mediaState = new PlayerController(this, playerContext, selectTextTrack);\n readonly #options = new RadioOptionsController<CaptionsRadioGroupOption>(this, {\n renderItem: (item, label, option) => this.#setContent(item, label, option.badge),\n getOptionCacheKey: (option) => option.badge ?? '',\n setItemAttributes: (item, option) => item.setAttribute('data-track', option.value),\n onValueChange: (value) => {\n const media = this.#mediaState.value;\n\n if (media) this.#core.selectValue(media, value);\n },\n });\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n if (this.destroyed) return;\n\n if (__DEV__ && !this.#mediaState.value && this.#mediaState.displayName) {\n logMissingFeature(this.localName, this.#mediaState.displayName);\n }\n }\n\n protected override update(changed: PropertyValues): void {\n const media = this.#mediaState.value;\n let state: CaptionsRadioGroupState | null = null;\n\n if (media) {\n this.#core.setProps({ formatTrack: this.formatTrack, disabled: this.disabled, label: this.label });\n this.#core.setMedia(media);\n state = this.#core.getState();\n\n this.applyDefaultAriaLabel(translateText(this.#core.getLabel(state), this.#i18n.value));\n this.#options.sync(state, this.#i18n.value, this.#i18n.locale);\n this.publishMenuOptionState(state.disabled, state.hidden, state.availability);\n } else {\n this.publishMenuOptionState(true, true, 'unsupported');\n }\n\n super.update(changed);\n\n if (state) applyStateDataAttrs(this, state, CaptionsRadioGroupDataAttrs);\n }\n\n #setContent(item: MenuRadioItemElement, label: string, badge: string | undefined): void {\n const labelPart = item.querySelector<HTMLElement>('[data-part~=\"label\"]');\n const badgePart = item.querySelector<HTMLElement>('[data-part~=\"badge\"]');\n\n if (labelPart) {\n labelPart.textContent = label;\n }\n\n if (badgePart) {\n badgePart.textContent = badge ?? '';\n badgePart.hidden = !badge;\n }\n\n if (!labelPart && !badgePart) {\n item.textContent = [label, badge].filter(Boolean).join(' ');\n }\n }\n}\n\nexport namespace CaptionsRadioGroupElement {\n export type State = CaptionsRadioGroupState;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAa,4BAAb,cAA+C,sBAAsB;;;EASxD,KAAA,WAAA;EACY,KAAA,QAAA;EACT,KAAA,cAAA,uBAAuB,aAAa;EAEjC,KAAA,QAAA,IAAI,uBAAuB;EAC3B,KAAA,QAAA,IAAI,eAAe,MAAM,WAAW;EAC9B,KAAA,cAAA,IAAI,iBAAiB,MAAM,eAAe,eAAe;EAC5D,KAAA,WAAA,IAAI,uBAAiD,MAAM;GAC7E,aAAa,MAAM,OAAO,WAAW,KAAK,YAAY,MAAM,OAAO,OAAO,KAAK;GAC/E,oBAAoB,WAAW,OAAO,SAAS;GAC/C,oBAAoB,MAAM,WAAW,KAAK,aAAa,cAAc,OAAO,KAAK;GACjF,gBAAgB,UAAU;IACxB,MAAM,QAAQ,KAAK,YAAY;IAE/B,IAAI,OAAO,KAAK,MAAM,YAAY,OAAO,KAAK;GAChD;EACF,CAAC;;;EAxBkC,KAAA,UAAA;;;EAEN,KAAA,aAAA;GAC3B,GAAG,sBAAsB;GACzB,UAAU,EAAE,MAAM,QAAQ;GAC1B,OAAO,EAAE,MAAM,OAAO;EACxB;;CAMA;CACA;CACA;CACA;CAWA,oBAAmC;EACjC,MAAM,kBAAkB;EAExB,IAAI,KAAK,WAAW;EAEpB,IAAe,CAAC,KAAK,YAAY,SAAS,KAAK,YAAY,aACzD,kBAAkB,KAAK,WAAW,KAAK,YAAY,WAAW;CAElE;CAEA,OAA0B,SAA+B;EACvD,MAAM,QAAQ,KAAK,YAAY;EAC/B,IAAI,QAAwC;EAE5C,IAAI,OAAO;GACT,KAAK,MAAM,SAAS;IAAE,aAAa,KAAK;IAAa,UAAU,KAAK;IAAU,OAAO,KAAK;GAAM,CAAC;GACjG,KAAK,MAAM,SAAS,KAAK;GACzB,QAAQ,KAAK,MAAM,SAAS;GAE5B,KAAK,sBAAsB,cAAc,KAAK,MAAM,SAAS,KAAK,GAAG,KAAK,MAAM,KAAK,CAAC;GACtF,KAAK,SAAS,KAAK,OAAO,KAAK,MAAM,OAAO,KAAK,MAAM,MAAM;GAC7D,KAAK,uBAAuB,MAAM,UAAU,MAAM,QAAQ,MAAM,YAAY;EAC9E,OACE,KAAK,uBAAuB,MAAM,MAAM,aAAa;EAGvD,MAAM,OAAO,OAAO;EAEpB,IAAI,OAAO,oBAAoB,MAAM,OAAO,2BAA2B;CACzE;CAEA,YAAY,MAA4B,OAAe,OAAiC;EACtF,MAAM,YAAY,KAAK,cAA2B,wBAAsB;EACxE,MAAM,YAAY,KAAK,cAA2B,wBAAsB;EAExE,IAAI,WACF,UAAU,cAAc;EAG1B,IAAI,WAAW;GACb,UAAU,cAAc,SAAS;GACjC,UAAU,SAAS,CAAC;EACtB;EAEA,IAAI,CAAC,aAAa,CAAC,WACjB,KAAK,cAAc,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAE9D;AACF"}
@@ -3,8 +3,8 @@ import { ControlsVisibility } from "@videojs/core";
3
3
  import { PropertyValues } from "@videojs/element";
4
4
  //#region src/ui/controls/element.d.ts
5
5
  /**
6
- * Tracks controls visibility, reflects it as data attributes, and shares it with its descendant controls parts. Hiding
7
- * the controls closes any popup open inside it.
6
+ * Tracks controls visibility and whether playback has started, reflects them as data attributes, and shares them with
7
+ * its descendant controls parts. Hiding the controls closes any popup open inside it.
8
8
  */
9
9
  export declare class ControlsElement extends UIElement {
10
10
  #private;