@mattebox/player 0.9.1 → 0.11.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 (95) hide show
  1. package/dist/announcer.d.ts +7 -0
  2. package/dist/announcer.d.ts.map +1 -0
  3. package/dist/announcer.js +44 -0
  4. package/dist/announcer.js.map +1 -0
  5. package/dist/cdn/mattebox-player.min.js +3 -3
  6. package/dist/controls/icons.d.ts +1 -1
  7. package/dist/controls/icons.d.ts.map +1 -1
  8. package/dist/controls/icons.js +1 -0
  9. package/dist/controls/icons.js.map +1 -1
  10. package/dist/controls/native-tracks.d.ts +8 -7
  11. package/dist/controls/native-tracks.d.ts.map +1 -1
  12. package/dist/controls/native-tracks.js.map +1 -1
  13. package/dist/element.d.ts +63 -1
  14. package/dist/element.d.ts.map +1 -1
  15. package/dist/element.js +211 -12
  16. package/dist/element.js.map +1 -1
  17. package/dist/elements/audio-menu.js +1 -1
  18. package/dist/elements/control-bar.d.ts.map +1 -1
  19. package/dist/elements/control-bar.js +8 -6
  20. package/dist/elements/control-bar.js.map +1 -1
  21. package/dist/elements/drm-badge.js +2 -2
  22. package/dist/elements/error-screen.d.ts.map +1 -1
  23. package/dist/elements/error-screen.js +1 -3
  24. package/dist/elements/error-screen.js.map +1 -1
  25. package/dist/elements/menu-element.js +1 -1
  26. package/dist/elements/play-button.d.ts.map +1 -1
  27. package/dist/elements/play-button.js +7 -9
  28. package/dist/elements/play-button.js.map +1 -1
  29. package/dist/elements/seek-bar.js +1 -1
  30. package/dist/elements/shared.d.ts +18 -0
  31. package/dist/elements/shared.d.ts.map +1 -1
  32. package/dist/elements/shared.js +16 -9
  33. package/dist/elements/shared.js.map +1 -1
  34. package/dist/elements/skip-button.js +1 -1
  35. package/dist/elements/start-button.d.ts.map +1 -1
  36. package/dist/elements/start-button.js +3 -3
  37. package/dist/elements/start-button.js.map +1 -1
  38. package/dist/elements/subtitles-menu.js +1 -1
  39. package/dist/elements/title.d.ts.map +1 -1
  40. package/dist/elements/title.js +5 -2
  41. package/dist/elements/title.js.map +1 -1
  42. package/dist/elements/video-menu.d.ts +23 -0
  43. package/dist/elements/video-menu.d.ts.map +1 -0
  44. package/dist/elements/video-menu.js +146 -0
  45. package/dist/elements/video-menu.js.map +1 -0
  46. package/dist/entries/video-menu.d.ts +5 -0
  47. package/dist/entries/video-menu.d.ts.map +1 -0
  48. package/dist/entries/video-menu.js +9 -0
  49. package/dist/entries/video-menu.js.map +1 -0
  50. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/asyncToGenerator.js +1 -1
  51. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +1 -1
  52. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectSpread2.js +1 -1
  53. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +1 -1
  54. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +1 -1
  55. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/typeof.js +1 -1
  56. package/dist/es2015/announcer.js +43 -0
  57. package/dist/es2015/controls/chapters.js +1 -1
  58. package/dist/es2015/controls/icons.js +1 -0
  59. package/dist/es2015/controls/menu.js +1 -1
  60. package/dist/es2015/element.js +258 -57
  61. package/dist/es2015/elements/audio-menu.js +1 -1
  62. package/dist/es2015/elements/control-bar.js +8 -6
  63. package/dist/es2015/elements/drm-badge.js +2 -2
  64. package/dist/es2015/elements/error-screen.js +2 -3
  65. package/dist/es2015/elements/menu-element.js +1 -1
  66. package/dist/es2015/elements/play-button.js +8 -10
  67. package/dist/es2015/elements/seek-bar.js +1 -1
  68. package/dist/es2015/elements/shared.js +16 -9
  69. package/dist/es2015/elements/skip-button.js +1 -1
  70. package/dist/es2015/elements/start-button.js +3 -3
  71. package/dist/es2015/elements/subtitles-menu.js +1 -1
  72. package/dist/es2015/elements/title.js +5 -2
  73. package/dist/es2015/elements/video-menu.js +152 -0
  74. package/dist/es2015/entries/video-menu.js +7 -0
  75. package/dist/es2015/index.js +3 -1
  76. package/dist/es2015/presets.js +1 -1
  77. package/dist/es2015/style.js +1 -1
  78. package/dist/es2015/tags.js +2 -1
  79. package/dist/es2015/video-sources.js +128 -0
  80. package/dist/host.d.ts +10 -1
  81. package/dist/host.d.ts.map +1 -1
  82. package/dist/host.js.map +1 -1
  83. package/dist/index.d.ts +3 -0
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +3 -1
  86. package/dist/style.js +1 -1
  87. package/dist/tags.d.ts +1 -0
  88. package/dist/tags.d.ts.map +1 -1
  89. package/dist/tags.js +2 -1
  90. package/dist/tags.js.map +1 -1
  91. package/dist/video-sources.d.ts +48 -0
  92. package/dist/video-sources.d.ts.map +1 -0
  93. package/dist/video-sources.js +134 -0
  94. package/dist/video-sources.js.map +1 -0
  95. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"icons.js","names":[],"sources":["../../src/controls/icons.ts"],"sourcesContent":["/**\n * The glyphs, Mattebox's own drawings: filled paths on a 32-unit viewBox,\n * one visual weight across the set, with hard corners and 45 degree cuts\n * like the panels of the mark. Each is one path, so a glyph scales to any\n * size and takes the text colour.\n */\n\nexport type IconName =\n | 'play'\n | 'pause'\n | 'replay'\n | 'mute'\n | 'volume-low'\n | 'volume-high'\n | 'fullscreen'\n | 'fullscreen-exit'\n | 'quality'\n | 'audio'\n | 'subtitles'\n | 'subtitles-on'\n | 'lock-closed'\n | 'seek-backward'\n | 'seek-forward'\n | 'seek-backward-5'\n | 'seek-forward-5'\n | 'seek-backward-10'\n | 'seek-forward-10'\n | 'seek-backward-15'\n | 'seek-forward-15'\n | 'seek-backward-30'\n | 'seek-forward-30'\n | 'playback-speed'\n | 'picture-in-picture'\n | 'picture-in-picture-exit'\n | 'airplay'\n | 'airplay-active'\n | 'chapters'\n | 'fast-forward'\n | 'fast-backward'\n | 'audio-description'\n | 'sdh'\n | 'closed-captions'\n | 'text-size'\n | 'text-background';\n\n/**\n * Each glyph's subpaths joined into one `d`. The path is drawn even-odd:\n * a frame, a ring or a letter cuts its hole with a nested subpath, and no\n * two filled subpaths overlap.\n */\nconst PATHS: Readonly<Record<IconName, string>> = {\n play: 'M9 5L26 16L9 27z',\n pause: 'M8 6h5.5v20h-5.5zM18.5 6h5.5v20h-5.5z',\n replay:\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n mute: 'M4 12L9 12L16 6L16 26L9 20L4 20zM24 17.77L20.99 20.77L19.23 19.01L22.23 16L19.23 12.99L20.99 11.23L24 14.23L27.01 11.23L28.77 12.99L25.77 16L28.77 19.01L27.01 20.77z',\n 'volume-low':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64z',\n 'volume-high':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64zM24.31 7.69A11.75 11.75 0 0 1 24.31 24.31L22.54 22.54A9.25 9.25 0 0 0 22.54 9.46z',\n fullscreen:\n 'M5 5L14 5L11 8L8 8L8 11L5 14zM18 5L27 5L27 14L24 11L24 8L21 8zM5 18L8 21L8 24L11 24L14 27L5 27zM27 18L27 27L18 27L21 24L24 24L24 21z',\n 'fullscreen-exit':\n 'M13 4L13 13L4 13L7 10L10 10L10 7zM19 4L22 7L22 10L25 10L28 13L19 13zM4 19L13 19L13 28L10 25L10 22L7 22zM19 19L28 19L25 22L22 22L22 25L19 28z',\n quality:\n 'M5 22L10 18.1L10 27L5 27zM13.5 15.4L18.5 11.6L18.5 27L13.5 27zM22 8.9L27 5L27 27L22 27z',\n audio:\n 'M4.75 13h2.5v6h-2.5zM9.75 9h2.5v14h-2.5zM14.75 5h2.5v22h-2.5zM19.75 10.5h2.5v11h-2.5zM24.75 13.5h2.5v5h-2.5z',\n subtitles:\n 'M4 6h20l4 4v16H4zM6.5 8.5H22.96L25.5 11.04V23.5H6.5zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'subtitles-on':\n 'M4 6h20l4 4v16H4zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'lock-closed':\n 'M7 14h18v13H7zM14.75 18.5v4.5h2.5v-4.5zM9.75 14V11A6.25 6.25 0 0 1 22.25 11V14H19.75V11A3.75 3.75 0 0 0 12.25 11V14z',\n 'seek-backward':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n 'seek-forward':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5z',\n 'seek-backward-5':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-forward-5':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-backward-10':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-10':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-backward-15':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-forward-15':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-backward-30':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-30':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'playback-speed':\n 'M7.69 26.31A11.75 11.75 0 1 1 24.31 26.31L22.54 24.54A9.25 9.25 0 1 0 9.46 24.54zM16.41 20.31L21.14 11.87L13.66 17.99z',\n 'picture-in-picture': 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM15 15h8v6h-8z',\n 'picture-in-picture-exit':\n 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z',\n airplay: 'M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z',\n 'airplay-active': 'M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z',\n chapters:\n 'M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z',\n 'fast-forward': 'M4 7L15 16L4 25zM16 7L27 16L16 25z',\n 'fast-backward': 'M28 7L17 16L28 25zM16 7L5 16L16 25z',\n 'audio-description':\n 'M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z',\n sdh: 'M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z',\n 'closed-captions':\n 'M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z',\n 'text-size':\n 'M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z',\n 'text-background':\n 'M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z',\n};\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/** A glyph, hidden from the accessibility tree: the button it sits in carries the name. */\nexport function icon(name: IconName): SVGSVGElement {\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('viewBox', '0 0 32 32');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('part', 'icon');\n const path = document.createElementNS(SVG, 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('d', PATHS[name]);\n svg.append(path);\n return svg;\n}\n"],"mappings":";;;;;;AAkDA,MAAM,QAA4C;CAChD,MAAM;CACN,OAAO;CACP,QACE;CACF,MAAM;CACN,cACE;CACF,eACE;CACF,YACE;CACF,mBACE;CACF,SACE;CACF,OACE;CACF,WACE;CACF,gBACE;CACF,eACE;CACF,iBACE;CACF,gBACE;CACF,mBACE;CACF,kBACE;CACF,oBACE;CACF,mBACE;CACF,oBACE;CACF,mBACE;CACF,oBACE;CACF,mBACE;CACF,kBACE;CACF,sBAAsB;CACtB,2BACE;CACF,SAAS;CACT,kBAAkB;CAClB,UACE;CACF,gBAAgB;CAChB,iBAAiB;CACjB,qBACE;CACF,KAAK;CACL,mBACE;CACF,aACE;CACF,mBACE;AACJ;AAEA,MAAM,MAAM;;AAGZ,SAAgB,KAAK,MAA+B;CAClD,MAAM,MAAM,SAAS,gBAAgB,KAAK,KAAK;CAC/C,IAAI,aAAa,WAAW,WAAW;CACvC,IAAI,aAAa,eAAe,MAAM;CACtC,IAAI,aAAa,QAAQ,MAAM;CAC/B,MAAM,OAAO,SAAS,gBAAgB,KAAK,MAAM;CACjD,KAAK,aAAa,aAAa,SAAS;CACxC,KAAK,aAAa,KAAK,MAAM,KAAK;CAClC,IAAI,OAAO,IAAI;CACf,OAAO;AACT"}
1
+ {"version":3,"file":"icons.js","names":[],"sources":["../../src/controls/icons.ts"],"sourcesContent":["/**\n * The glyphs, Mattebox's own drawings: filled paths on a 32-unit viewBox,\n * one visual weight across the set, with hard corners and 45 degree cuts\n * like the panels of the mark. Each is one path, so a glyph scales to any\n * size and takes the text colour.\n */\n\nexport type IconName =\n | 'play'\n | 'pause'\n | 'replay'\n | 'mute'\n | 'volume-low'\n | 'volume-high'\n | 'fullscreen'\n | 'fullscreen-exit'\n | 'quality'\n | 'audio'\n | 'video'\n | 'subtitles'\n | 'subtitles-on'\n | 'lock-closed'\n | 'seek-backward'\n | 'seek-forward'\n | 'seek-backward-5'\n | 'seek-forward-5'\n | 'seek-backward-10'\n | 'seek-forward-10'\n | 'seek-backward-15'\n | 'seek-forward-15'\n | 'seek-backward-30'\n | 'seek-forward-30'\n | 'playback-speed'\n | 'picture-in-picture'\n | 'picture-in-picture-exit'\n | 'airplay'\n | 'airplay-active'\n | 'chapters'\n | 'fast-forward'\n | 'fast-backward'\n | 'audio-description'\n | 'sdh'\n | 'closed-captions'\n | 'text-size'\n | 'text-background';\n\n/**\n * Each glyph's subpaths joined into one `d`. The path is drawn even-odd:\n * a frame, a ring or a letter cuts its hole with a nested subpath, and no\n * two filled subpaths overlap.\n */\nconst PATHS: Readonly<Record<IconName, string>> = {\n play: 'M9 5L26 16L9 27z',\n pause: 'M8 6h5.5v20h-5.5zM18.5 6h5.5v20h-5.5z',\n replay:\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n mute: 'M4 12L9 12L16 6L16 26L9 20L4 20zM24 17.77L20.99 20.77L19.23 19.01L22.23 16L19.23 12.99L20.99 11.23L24 14.23L27.01 11.23L28.77 12.99L25.77 16L28.77 19.01L27.01 20.77z',\n 'volume-low':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64z',\n 'volume-high':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64zM24.31 7.69A11.75 11.75 0 0 1 24.31 24.31L22.54 22.54A9.25 9.25 0 0 0 22.54 9.46z',\n fullscreen:\n 'M5 5L14 5L11 8L8 8L8 11L5 14zM18 5L27 5L27 14L24 11L24 8L21 8zM5 18L8 21L8 24L11 24L14 27L5 27zM27 18L27 27L18 27L21 24L24 24L24 21z',\n 'fullscreen-exit':\n 'M13 4L13 13L4 13L7 10L10 10L10 7zM19 4L22 7L22 10L25 10L28 13L19 13zM4 19L13 19L13 28L10 25L10 22L7 22zM19 19L28 19L25 22L22 22L22 25L19 28z',\n quality:\n 'M5 22L10 18.1L10 27L5 27zM13.5 15.4L18.5 11.6L18.5 27L13.5 27zM22 8.9L27 5L27 27L22 27z',\n audio:\n 'M4.75 13h2.5v6h-2.5zM9.75 9h2.5v14h-2.5zM14.75 5h2.5v22h-2.5zM19.75 10.5h2.5v11h-2.5zM24.75 13.5h2.5v5h-2.5z',\n // A camera: the body as a frame, the lens solid.\n video: 'M4 9h16v14H4zM6.5 11.5h11v9h-11zM21 14l7-4v12l-7-4z',\n subtitles:\n 'M4 6h20l4 4v16H4zM6.5 8.5H22.96L25.5 11.04V23.5H6.5zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'subtitles-on':\n 'M4 6h20l4 4v16H4zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'lock-closed':\n 'M7 14h18v13H7zM14.75 18.5v4.5h2.5v-4.5zM9.75 14V11A6.25 6.25 0 0 1 22.25 11V14H19.75V11A3.75 3.75 0 0 0 12.25 11V14z',\n 'seek-backward':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n 'seek-forward':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5z',\n 'seek-backward-5':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-forward-5':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-backward-10':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-10':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-backward-15':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-forward-15':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-backward-30':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-30':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'playback-speed':\n 'M7.69 26.31A11.75 11.75 0 1 1 24.31 26.31L22.54 24.54A9.25 9.25 0 1 0 9.46 24.54zM16.41 20.31L21.14 11.87L13.66 17.99z',\n 'picture-in-picture': 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM15 15h8v6h-8z',\n 'picture-in-picture-exit':\n 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z',\n airplay: 'M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z',\n 'airplay-active': 'M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z',\n chapters:\n 'M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z',\n 'fast-forward': 'M4 7L15 16L4 25zM16 7L27 16L16 25z',\n 'fast-backward': 'M28 7L17 16L28 25zM16 7L5 16L16 25z',\n 'audio-description':\n 'M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z',\n sdh: 'M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z',\n 'closed-captions':\n 'M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z',\n 'text-size':\n 'M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z',\n 'text-background':\n 'M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z',\n};\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/** A glyph, hidden from the accessibility tree: the button it sits in carries the name. */\nexport function icon(name: IconName): SVGSVGElement {\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('viewBox', '0 0 32 32');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('part', 'icon');\n const path = document.createElementNS(SVG, 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('d', PATHS[name]);\n svg.append(path);\n return svg;\n}\n"],"mappings":";;;;;;AAmDA,MAAM,QAA4C;CAChD,MAAM;CACN,OAAO;CACP,QACE;CACF,MAAM;CACN,cACE;CACF,eACE;CACF,YACE;CACF,mBACE;CACF,SACE;CACF,OACE;CAEF,OAAO;CACP,WACE;CACF,gBACE;CACF,eACE;CACF,iBACE;CACF,gBACE;CACF,mBACE;CACF,kBACE;CACF,oBACE;CACF,mBACE;CACF,oBACE;CACF,mBACE;CACF,oBACE;CACF,mBACE;CACF,kBACE;CACF,sBAAsB;CACtB,2BACE;CACF,SAAS;CACT,kBAAkB;CAClB,UACE;CACF,gBAAgB;CAChB,iBAAiB;CACjB,qBACE;CACF,KAAK;CACL,mBACE;CACF,aACE;CACF,mBACE;AACJ;AAEA,MAAM,MAAM;;AAGZ,SAAgB,KAAK,MAA+B;CAClD,MAAM,MAAM,SAAS,gBAAgB,KAAK,KAAK;CAC/C,IAAI,aAAa,WAAW,WAAW;CACvC,IAAI,aAAa,eAAe,MAAM;CACtC,IAAI,aAAa,QAAQ,MAAM;CAC/B,MAAM,OAAO,SAAS,gBAAgB,KAAK,MAAM;CACjD,KAAK,aAAa,aAAa,SAAS;CACxC,KAAK,aAAa,KAAK,MAAM,KAAK;CAClC,IAAI,OAAO,IAAI;CACf,OAAO;AACT"}
@@ -1,12 +1,13 @@
1
1
  /**
2
- * The element's own track lists, for the audio and subtitles menus of a
3
- * native session. Safari lists the renditions of an HLS stream it plays
4
- * itself in `audioTracks` and `textTracks`. No engine-shaped object goes
5
- * over them: the menus read the lists and write `enabled` and `mode`.
2
+ * The element's own track lists, for the audio, subtitles and video menus
3
+ * of a native session. Safari lists the renditions of an HLS stream it
4
+ * plays itself in `audioTracks`, `textTracks` and `videoTracks`. No
5
+ * engine-shaped object goes over them: the menus read the lists and write
6
+ * `enabled`, `mode` and `selected`.
6
7
  * Each list is feature-tested, so a browser without it keeps the menu hidden.
7
8
  */
8
9
  import type { PlayerHost } from '../host.js';
9
- /** What the menus read of an `AudioTrack` or a `TextTrack`. */
10
+ /** What the menus read of an `AudioTrack`, a `TextTrack` or a `VideoTrack`. */
10
11
  export interface NativeTrack {
11
12
  readonly kind: string;
12
13
  readonly label: string;
@@ -22,7 +23,7 @@ export interface NativeTrackList<T extends NativeTrack> extends EventTarget {
22
23
  * undefined: an engine session has its own tracks, and Chromium has no
23
24
  * `audioTracks` without a flag.
24
25
  */
25
- export declare function nativeTracks<T extends NativeTrack>(player: PlayerHost, name: 'audioTracks' | 'textTracks'): T[] | undefined;
26
+ export declare function nativeTracks<T extends NativeTrack>(player: PlayerHost, name: 'audioTracks' | 'textTracks' | 'videoTracks'): T[] | undefined;
26
27
  /** Calls `tick` when the video's list of `name` changes, and answers the unsubscribe. */
27
- export declare function onNativeTracks(video: HTMLVideoElement, name: 'audioTracks' | 'textTracks', tick: () => void): (() => void) | undefined;
28
+ export declare function onNativeTracks(video: HTMLVideoElement, name: 'audioTracks' | 'textTracks' | 'videoTracks', tick: () => void): (() => void) | undefined;
28
29
  //# sourceMappingURL=native-tracks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-tracks.d.ts","sourceRoot":"","sources":["../../src/controls/native-tracks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,iFAAiF;AACjF,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,WAAW,CAAE,SAAQ,WAAW;IACzE,Q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D,IAAI,EAAE,MAAM,IAAI,GACf,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAQ1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"native-tracks.js","names":[],"sources":["../../src/controls/native-tracks.ts"],"sourcesContent":["/**\n * The element's own track lists, for the audio and subtitles menus of a\n * native session. Safari lists the renditions of an HLS stream it plays\n * itself in `audioTracks` and `textTracks`. No engine-shaped object goes\n * over them: the menus read the lists and write `enabled` and `mode`.\n * Each list is feature-tested, so a browser without it keeps the menu hidden.\n */\nimport type { PlayerHost } from '../host.js';\n\n/** What the menus read of an `AudioTrack` or a `TextTrack`. */\nexport interface NativeTrack {\n readonly kind: string;\n readonly label: string;\n readonly language: string;\n}\n\n/** An `AudioTrackList` or a `TextTrackList`. lib.dom has no `AudioTrackList`. */\nexport interface NativeTrackList<T extends NativeTrack> extends EventTarget {\n readonly length: number;\n readonly [index: number]: T;\n}\n\n/**\n * The video's `audioTracks` or `textTracks` during a native session, or\n * undefined: an engine session has its own tracks, and Chromium has no\n * `audioTracks` without a flag.\n */\nexport function nativeTracks<T extends NativeTrack>(\n player: PlayerHost,\n name: 'audioTracks' | 'textTracks',\n): T[] | undefined {\n const session = player.player?.session;\n if (session == null || session.engine !== null) return undefined;\n const list = (player.video as unknown as Record<string, NativeTrackList<T> | undefined>)[name];\n return list === undefined ? undefined : Array.from(list);\n}\n\n/** Calls `tick` when the video's list of `name` changes, and answers the unsubscribe. */\nexport function onNativeTracks(\n video: HTMLVideoElement,\n name: 'audioTracks' | 'textTracks',\n tick: () => void,\n): (() => void) | undefined {\n const list = (video as unknown as Record<string, EventTarget | undefined>)[name];\n if (list === undefined) return undefined;\n const events = ['change', 'addtrack', 'removetrack'];\n for (const event of events) list.addEventListener(event, tick);\n return () => {\n for (const event of events) list.removeEventListener(event, tick);\n };\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,aACd,QACA,MACiB;CACjB,MAAM,UAAU,OAAO,QAAQ;CAC/B,IAAI,WAAW,QAAQ,QAAQ,WAAW,MAAM,OAAO,KAAA;CACvD,MAAM,OAAQ,OAAO,MAAoE;CACzF,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,MAAM,KAAK,IAAI;AACzD;;AAGA,SAAgB,eACd,OACA,MACA,MAC0B;CAC1B,MAAM,OAAQ,MAA6D;CAC3E,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,MAAM,SAAS;EAAC;EAAU;EAAY;CAAa;CACnD,KAAK,MAAM,SAAS,QAAQ,KAAK,iBAAiB,OAAO,IAAI;CAC7D,aAAa;EACX,KAAK,MAAM,SAAS,QAAQ,KAAK,oBAAoB,OAAO,IAAI;CAClE;AACF"}
1
+ {"version":3,"file":"native-tracks.js","names":[],"sources":["../../src/controls/native-tracks.ts"],"sourcesContent":["/**\n * The element's own track lists, for the audio, subtitles and video menus\n * of a native session. Safari lists the renditions of an HLS stream it\n * plays itself in `audioTracks`, `textTracks` and `videoTracks`. No\n * engine-shaped object goes over them: the menus read the lists and write\n * `enabled`, `mode` and `selected`.\n * Each list is feature-tested, so a browser without it keeps the menu hidden.\n */\nimport type { PlayerHost } from '../host.js';\n\n/** What the menus read of an `AudioTrack`, a `TextTrack` or a `VideoTrack`. */\nexport interface NativeTrack {\n readonly kind: string;\n readonly label: string;\n readonly language: string;\n}\n\n/** An `AudioTrackList` or a `TextTrackList`. lib.dom has no `AudioTrackList`. */\nexport interface NativeTrackList<T extends NativeTrack> extends EventTarget {\n readonly length: number;\n readonly [index: number]: T;\n}\n\n/**\n * The video's `audioTracks` or `textTracks` during a native session, or\n * undefined: an engine session has its own tracks, and Chromium has no\n * `audioTracks` without a flag.\n */\nexport function nativeTracks<T extends NativeTrack>(\n player: PlayerHost,\n name: 'audioTracks' | 'textTracks' | 'videoTracks',\n): T[] | undefined {\n const session = player.player?.session;\n if (session == null || session.engine !== null) return undefined;\n const list = (player.video as unknown as Record<string, NativeTrackList<T> | undefined>)[name];\n return list === undefined ? undefined : Array.from(list);\n}\n\n/** Calls `tick` when the video's list of `name` changes, and answers the unsubscribe. */\nexport function onNativeTracks(\n video: HTMLVideoElement,\n name: 'audioTracks' | 'textTracks' | 'videoTracks',\n tick: () => void,\n): (() => void) | undefined {\n const list = (video as unknown as Record<string, EventTarget | undefined>)[name];\n if (list === undefined) return undefined;\n const events = ['change', 'addtrack', 'removetrack'];\n for (const event of events) list.addEventListener(event, tick);\n return () => {\n for (const event of events) list.removeEventListener(event, tick);\n };\n}\n"],"mappings":";;;;;;AA4BA,SAAgB,aACd,QACA,MACiB;CACjB,MAAM,UAAU,OAAO,QAAQ;CAC/B,IAAI,WAAW,QAAQ,QAAQ,WAAW,MAAM,OAAO,KAAA;CACvD,MAAM,OAAQ,OAAO,MAAoE;CACzF,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,MAAM,KAAK,IAAI;AACzD;;AAGA,SAAgB,eACd,OACA,MACA,MAC0B;CAC1B,MAAM,OAAQ,MAA6D;CAC3E,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,MAAM,SAAS;EAAC;EAAU;EAAY;CAAa;CACnD,KAAK,MAAM,SAAS,QAAQ,KAAK,iBAAiB,OAAO,IAAI;CAC7D,aAAa;EACX,KAAK,MAAM,SAAS,QAAQ,KAAK,oBAAoB,OAAO,IAAI;CAClE;AACF"}
package/dist/element.d.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  * them into runtime helpers, and the emit check bans helpers. Statics are
18
18
  * getters and instance state is declared, then assigned in the constructor.
19
19
  */
20
- import type { Handler, Player, PlayerError, Session, Source } from '@mattebox/player-core';
20
+ import type { Handler, Player, PlayerError, Session, Source, SourceVideoTrack } from '@mattebox/player-core';
21
21
  import type { KernelConfig, Mattebox, Stage } from 'mattebox';
22
22
  import type { AttachEmeOptions } from 'mattebox/eme';
23
23
  import type { Marker, Markers } from './controls/markers.js';
@@ -85,6 +85,15 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
85
85
  /** Whether the element gave itself a tabindex for the bar, to take back with it. */
86
86
  private focusable;
87
87
  private readonly surface;
88
+ private readonly voice;
89
+ /** Runs out when the video has waited `LOADING_MS`. */
90
+ private slow;
91
+ /** The audio track the live region last saw, so it says only a change. Undefined before the first play. */
92
+ private heardAudio;
93
+ /** The subtitle track it last saw: null for off, undefined before the first play. */
94
+ private heardText;
95
+ /** Stops listening to the current engine's track selection. */
96
+ private offTracks;
88
97
  private readonly marks;
89
98
  /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */
90
99
  private track;
@@ -114,6 +123,16 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
114
123
  private queue;
115
124
  /** Whether a run is queued and not yet started, so a burst of changes loads once. */
116
125
  private pending;
126
+ /** The source the versions of `videoSources` belong to: the one that played before a switch. */
127
+ private programme;
128
+ /** The version that plays, or null for the programme itself. */
129
+ private version;
130
+ /** True while a version loads, so its `sourcechange` keeps the programme. */
131
+ private switching;
132
+ /** The source `switchSource` loaded, which a retry loads again, or null. */
133
+ private switched;
134
+ /** Ends the hold of a switch: the poster and `switching` go back. Null without one. */
135
+ private held;
117
136
  constructor(options?: MatteboxPlayerOptions);
118
137
  /** The media element. Everything the browser already does is here. */
119
138
  get video(): HTMLVideoElement;
@@ -126,6 +145,41 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
126
145
  */
127
146
  get sources(): readonly Source[] | null;
128
147
  set sources(value: readonly Source[] | null);
148
+ /**
149
+ * Loads the sources again, in the order a load reads them: the `src`
150
+ * attribute, the `sources` property, then the `<source>` children. The
151
+ * error screens' Retry calls it. On a version of `videoSources`, it
152
+ * loads that version again.
153
+ */
154
+ retry(): void;
155
+ /**
156
+ * Loads `source` in place of the one that plays, from the same position
157
+ * and in the same play state, with the same audio and subtitle choice.
158
+ * Use it for the same programme at another URL, such as its HLS and
159
+ * DASH manifests. The last frame and the controls hold until the new
160
+ * load shows a frame there. The markers stay, and the versions are the
161
+ * ones `source` names. A new `src`, `sources` or `<source>` load
162
+ * replaces it.
163
+ */
164
+ switchSource(source: Source): void;
165
+ /** The other versions of the picture the source names at their own URLs, for the video menu. */
166
+ get videoSources(): readonly SourceVideoTrack[];
167
+ /** The version of `videoSources` that plays, or null for the source itself. */
168
+ get videoSource(): SourceVideoTrack | null;
169
+ /**
170
+ * Plays a version of `videoSources`, or the source itself for null, from
171
+ * the same position and in the same play state, with the same audio and
172
+ * subtitle choice. A live source joins the version at its live edge.
173
+ * Fires `videosourcechange`.
174
+ */
175
+ selectVideoSource(track: SourceVideoTrack | null): void;
176
+ /**
177
+ * Loads `source` under the programme that plays, and puts the position,
178
+ * play state and tracks back. With `hold`, the last frame stays as the
179
+ * poster and the player carries `switching`, the play state from
180
+ * before, so the controls show that state through the load.
181
+ */
182
+ private swap;
129
183
  /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
130
184
  get player(): Player | null;
131
185
  /** The engine feeding the video, or null for a native session and before the first load. */
@@ -142,6 +196,14 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
142
196
  private measure;
143
197
  /** The two states the video does not hold: whether it has played once, and whether it waits for data. */
144
198
  private note;
199
+ /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */
200
+ private tell;
201
+ /**
202
+ * Says a change of the audio or the subtitle track, once the video has
203
+ * played: the tracks a load starts with are no change. A forced track
204
+ * reads as off, as in the subtitles menu.
205
+ */
206
+ private tracks;
145
207
  /** The video's state on the element, for `mattebox-player[paused]` and the like. */
146
208
  private reflect;
147
209
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQ3F,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB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AAO,CAAC,MAAM;IAsCd,oGAAoG;IACpG,OAAO,CAAC,KAAK;YAYC,MAAM;IA8BpB;;;;OAIG;IACH,OAAO,KAAK,OAAO,GAElB;YAEa,KAAK;IAiCnB;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAeX,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IA6BjB,OAAO,CAAC,OAAO;YAID,QAAQ;IAKtB,mFAAmF;YACrE,OAAO;CAMtB"}
package/dist/element.js CHANGED
@@ -1,9 +1,12 @@
1
+ import { announcer } from "./announcer.js";
1
2
  import { createMarkers } from "./controls/markers.js";
3
+ import { languageName } from "./controls/track-names.js";
2
4
  import { namespaces } from "./namespaces.js";
3
5
  import { drmGuard, resolvePreset } from "./presets.js";
4
6
  import { STYLE } from "./style.js";
5
7
  import { errorSurface } from "./surface.js";
6
8
  import { PLAYER } from "./tags.js";
9
+ import { chosen, holdFrame, markupVideoTracks, onNextFrame, restore, resume, versionSource } from "./video-sources.js";
7
10
  import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
8
11
  //#region src/element.ts
9
12
  /**
@@ -20,6 +23,20 @@ const FORWARDED = [
20
23
  "crossorigin"
21
24
  ];
22
25
  const LICENSE_URL = "license-url";
26
+ /** Carried through a switch: the play state from before it, `playing` or `paused`. */
27
+ const SWITCHING = "switching";
28
+ /** Whether the browser has EME, so a source may bring DRM. */
29
+ function emeAvailable() {
30
+ return drmGuard().without === void 0;
31
+ }
32
+ /** `source` without its DRM, for a browser without EME. */
33
+ function withoutDrm({ url, type, videoTracks }) {
34
+ return {
35
+ url,
36
+ ...type === void 0 ? {} : { type },
37
+ ...videoTracks === void 0 ? {} : { videoTracks }
38
+ };
39
+ }
23
40
  const CERTIFICATE_URL = "certificate-url";
24
41
  /** Everything else the element watches. Changing any of them reloads. */
25
42
  const OWN = [
@@ -91,6 +108,15 @@ const STATE_EVENTS = [
91
108
  "stalled",
92
109
  "canplay"
93
110
  ];
111
+ /**
112
+ * How long the video waits for data before the live region says so. A
113
+ * seek within the buffer waits for less, and saying it would only be noise.
114
+ */
115
+ const LOADING_MS = 1e3;
116
+ /** A track's name for the live region: its name in the stream, else its language's. */
117
+ function trackName(name, lang) {
118
+ return name || lang && (languageName(lang) ?? lang) || "";
119
+ }
94
120
  /** The stages that register a key system, which a native session's DRM offers. */
95
121
  const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
96
122
  /** Every stage the engine ships. A narrower preset is optimization. */
@@ -147,12 +173,27 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
147
173
  this.offs = [];
148
174
  this.queue = Promise.resolve();
149
175
  this.pending = false;
176
+ this.programme = null;
177
+ this.version = null;
178
+ this.switching = false;
179
+ this.switched = null;
180
+ this.held = null;
181
+ this.slow = void 0;
182
+ this.heardAudio = void 0;
183
+ this.heardText = void 0;
184
+ this.offTracks = null;
150
185
  this.media = document.createElement("video");
151
186
  this.media.controls = true;
152
187
  this.media.setAttribute(PLAYSINLINE, "");
153
188
  for (const name of STATE_EVENTS) this.media.addEventListener(name, () => {
189
+ const was = this.waiting;
154
190
  this.note(name);
155
191
  this.reflect();
192
+ this.tell(name, was);
193
+ });
194
+ const lists = this.media;
195
+ for (const list of [lists.audioTracks, lists.textTracks]) list?.addEventListener("change", () => {
196
+ this.tracks();
156
197
  });
157
198
  this.media.addEventListener("playing", () => {
158
199
  this.failure = null;
@@ -166,12 +207,13 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
166
207
  });
167
208
  this.stage.append(slot);
168
209
  this.surface = errorSurface(() => {
169
- this.reload();
210
+ this.retry();
170
211
  });
212
+ this.voice = announcer(this);
171
213
  const root = this.attachShadow({ mode: "open" });
172
214
  const style = document.createElement("style");
173
215
  style.textContent = STYLE;
174
- root.append(style, this.stage, this.surface.root);
216
+ root.append(style, this.stage, this.surface.root, this.voice.root);
175
217
  }
176
218
  /** The media element. Everything the browser already does is here. */
177
219
  get video() {
@@ -194,6 +236,104 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
194
236
  if (this.marks.list.length > 0) this.marks.set([]);
195
237
  this.reload();
196
238
  }
239
+ /**
240
+ * Loads the sources again, in the order a load reads them: the `src`
241
+ * attribute, the `sources` property, then the `<source>` children. The
242
+ * error screens' Retry calls it. On a version of `videoSources`, it
243
+ * loads that version again.
244
+ */
245
+ retry() {
246
+ const again = this.version === null ? this.switched : versionSource(this.version, emeAvailable());
247
+ if (again === null) this.reload();
248
+ else this.swap(again, null, false, null, false);
249
+ }
250
+ /**
251
+ * Loads `source` in place of the one that plays, from the same position
252
+ * and in the same play state, with the same audio and subtitle choice.
253
+ * Use it for the same programme at another URL, such as its HLS and
254
+ * DASH manifests. The last frame and the controls hold until the new
255
+ * load shows a frame there. The markers stay, and the versions are the
256
+ * ones `source` names. A new `src`, `sources` or `<source>` load
257
+ * replaces it.
258
+ */
259
+ switchSource(source) {
260
+ const media = this.media;
261
+ const at = Number.isFinite(media.duration) ? media.currentTime : null;
262
+ const playing = !media.paused;
263
+ const had = chosen(this.current?.engine ?? null);
264
+ const clean = emeAvailable() ? source : withoutDrm(source);
265
+ const was = this.version;
266
+ this.programme = clean;
267
+ this.switched = clean;
268
+ this.version = null;
269
+ if (was !== null) this.emit("videosourcechange", null);
270
+ this.swap(clean, at, playing, had, true);
271
+ }
272
+ /** The other versions of the picture the source names at their own URLs, for the video menu. */
273
+ get videoSources() {
274
+ return this.programme?.videoTracks ?? [];
275
+ }
276
+ /** The version of `videoSources` that plays, or null for the source itself. */
277
+ get videoSource() {
278
+ return this.version;
279
+ }
280
+ /**
281
+ * Plays a version of `videoSources`, or the source itself for null, from
282
+ * the same position and in the same play state, with the same audio and
283
+ * subtitle choice. A live source joins the version at its live edge.
284
+ * Fires `videosourcechange`.
285
+ */
286
+ selectVideoSource(track) {
287
+ const programme = this.programme;
288
+ if (programme === null || track === this.version) return;
289
+ if (track !== null && programme.videoTracks?.includes(track) !== true) return;
290
+ const media = this.media;
291
+ const at = Number.isFinite(media.duration) ? media.currentTime : null;
292
+ const playing = !media.paused;
293
+ const had = chosen(this.current?.engine ?? null);
294
+ this.version = track;
295
+ this.emit("videosourcechange", track);
296
+ this.swap(track === null ? programme : versionSource(track, emeAvailable()), at, playing, had, true);
297
+ }
298
+ /**
299
+ * Loads `source` under the programme that plays, and puts the position,
300
+ * play state and tracks back. With `hold`, the last frame stays as the
301
+ * poster and the player carries `switching`, the play state from
302
+ * before, so the controls show that state through the load.
303
+ */
304
+ swap(source, at, playing, had, hold) {
305
+ const media = this.media;
306
+ this.held?.();
307
+ let release = null;
308
+ if (hold) {
309
+ const frame = holdFrame(media);
310
+ const done = () => {
311
+ frame?.();
312
+ if (this.held !== done) return;
313
+ this.held = null;
314
+ this.removeAttribute(SWITCHING);
315
+ this.reflect();
316
+ };
317
+ this.held = done;
318
+ this.setAttribute(SWITCHING, playing ? "playing" : "paused");
319
+ release = done;
320
+ }
321
+ this.enqueue(async () => {
322
+ const core = await this.ensure();
323
+ this.switching = true;
324
+ try {
325
+ await core.load([source]);
326
+ } catch {
327
+ release?.();
328
+ return;
329
+ } finally {
330
+ this.switching = false;
331
+ }
332
+ resume(media, at, playing);
333
+ if (release !== null) onNextFrame(media, at, release);
334
+ restore(this.current?.engine ?? null, had);
335
+ });
336
+ }
197
337
  /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
198
338
  get player() {
199
339
  return this.core;
@@ -240,21 +380,67 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
240
380
  /** The two states the video does not hold: whether it has played once, and whether it waits for data. */
241
381
  note(event) {
242
382
  if (event === "playing") {
383
+ if (!this.started) this.tracks();
243
384
  this.started = true;
244
385
  this.waiting = false;
245
386
  } else if (event === "waiting" || event === "stalled") this.waiting = true;
246
387
  else if (event === "canplay") this.waiting = false;
247
388
  else if (event === "emptied") {
248
- this.started = false;
389
+ if (this.held === null) this.started = false;
249
390
  this.waiting = false;
391
+ this.heardAudio = void 0;
392
+ this.heardText = void 0;
393
+ }
394
+ }
395
+ /** Says a play or a pause, and a wait once it has lasted `LOADING_MS`. */
396
+ tell(event, was) {
397
+ if (event === "play" && this.held === null) this.voice.say("playing", "Playing");
398
+ if (event === "pause" && !this.media.ended && this.held === null) this.voice.say("paused", "Paused");
399
+ if (this.waiting === was) return;
400
+ clearTimeout(this.slow);
401
+ if (this.waiting) this.slow = setTimeout(() => {
402
+ this.voice.say("loading", "Loading");
403
+ }, LOADING_MS);
404
+ }
405
+ /**
406
+ * Says a change of the audio or the subtitle track, once the video has
407
+ * played: the tracks a load starts with are no change. A forced track
408
+ * reads as off, as in the subtitles menu.
409
+ */
410
+ tracks() {
411
+ const engine = this.current?.engine ?? null;
412
+ let audio;
413
+ let text;
414
+ if (engine !== null) {
415
+ const sound = engine.tracks.active("audio");
416
+ const words = engine.tracks.active("text");
417
+ audio = sound === null ? "" : trackName(sound.name, sound.lang);
418
+ text = words === null || words.forced === true ? null : trackName(words.name, words.lang);
419
+ } else {
420
+ const video = this.media;
421
+ const sound = Array.from(video.audioTracks ?? []).find((track) => track.enabled);
422
+ const words = Array.from(this.media.textTracks).find((track) => (track.kind === "subtitles" || track.kind === "captions") && track.mode === "showing");
423
+ audio = sound === void 0 ? "" : trackName(sound.label, sound.language);
424
+ text = words === void 0 ? null : trackName(words.label, words.language);
425
+ }
426
+ const { heardAudio, heardText } = this;
427
+ this.heardAudio = audio;
428
+ this.heardText = text;
429
+ if (!this.started) return;
430
+ if (heardAudio !== void 0 && audio !== heardAudio) this.voice.say("audio", "Audio: {track}", audio);
431
+ if (heardText !== void 0 && text !== heardText) {
432
+ if (text === null) this.voice.say("subtitles-off", "Subtitles off");
433
+ else this.voice.say("subtitles", "Subtitles: {track}", text);
250
434
  }
251
435
  }
252
436
  /** The video's state on the element, for `mattebox-player[paused]` and the like. */
253
437
  reflect() {
254
438
  const video = this.media;
255
439
  this.reflecting = true;
256
- this.toggleAttribute("paused", video.paused);
257
- this.toggleAttribute("playing", !video.paused);
440
+ const held = this.getAttribute(SWITCHING);
441
+ const paused = held === null ? video.paused : held === "paused";
442
+ this.toggleAttribute("paused", paused);
443
+ this.toggleAttribute("playing", !paused);
258
444
  this.toggleAttribute("ended", video.ended);
259
445
  this.toggleAttribute("muted", video.muted);
260
446
  this.toggleAttribute("audio", this.audio());
@@ -389,6 +575,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
389
575
  report(error) {
390
576
  if (error.fatal) {
391
577
  this.failure = error;
578
+ clearTimeout(this.slow);
579
+ if (this.querySelector("mbx-error-screen") === null) this.voice.say("error", "Playback failed");
392
580
  if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
393
581
  }
394
582
  this.emit("error", error);
@@ -415,19 +603,19 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
415
603
  * A child carries its own `license-url` and `certificate-url`.
416
604
  */
417
605
  wanted() {
606
+ const versions = markupVideoTracks(this);
607
+ const withVersions = versions.length === 0 ? {} : { videoTracks: versions };
418
608
  const url = this.getAttribute("src");
419
609
  if (url !== null) {
420
610
  const type = this.getAttribute("type");
421
- return [type === null ? { url } : {
611
+ return [{
422
612
  url,
423
- type
613
+ ...type === null ? {} : { type },
614
+ ...withVersions
424
615
  }];
425
616
  }
426
- const eme = drmGuard().without === void 0;
427
- if (this.list !== null) return eme ? this.list : this.list.map(({ url, type }) => type === void 0 ? { url } : {
428
- url,
429
- type
430
- });
617
+ const eme = emeAvailable();
618
+ if (this.list !== null) return eme ? this.list : this.list.map(withoutDrm);
431
619
  const found = [];
432
620
  for (const child of Array.from(this.children)) {
433
621
  const src = child.localName === "source" ? child.getAttribute("src") : null;
@@ -438,6 +626,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
438
626
  found.push({
439
627
  url: src,
440
628
  ...type === null ? {} : { type },
629
+ ...withVersions,
441
630
  ...!eme || license === null && certificate === null ? {} : { drm: {
442
631
  ...license === null ? {} : { licenseUrl: license },
443
632
  ...certificate === null ? {} : { certificateUrl: certificate }
@@ -457,6 +646,16 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
457
646
  const core = createPlayer(this.media, { handlers: await this.chain() });
458
647
  this.offs.push(core.on("sourcechange", (session) => {
459
648
  this.current = session;
649
+ if (!this.switching) {
650
+ const was = this.version;
651
+ this.programme = session?.source ?? null;
652
+ this.switched = null;
653
+ this.version = null;
654
+ this.held?.();
655
+ if (was !== null) this.emit("videosourcechange", null);
656
+ }
657
+ this.offTracks?.();
658
+ this.offTracks = session?.engine?.on("tracks:selected", () => this.tracks()) ?? null;
460
659
  if (session !== null && this.isConnected) this.adopt(session);
461
660
  this.emit("sourcechange", session);
462
661
  }), core.on("error", (error) => {