@mattebox/player 0.15.0 → 0.16.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 (112) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/chapters.d.ts +2 -8
  3. package/dist/controls/chapters.d.ts.map +1 -1
  4. package/dist/controls/chapters.js.map +1 -1
  5. package/dist/controls/cues.d.ts.map +1 -1
  6. package/dist/controls/cues.js +2 -2
  7. package/dist/controls/cues.js.map +1 -1
  8. package/dist/controls/icons.d.ts +1 -1
  9. package/dist/controls/icons.d.ts.map +1 -1
  10. package/dist/controls/icons.js +2 -0
  11. package/dist/controls/icons.js.map +1 -1
  12. package/dist/element.d.ts +19 -2
  13. package/dist/element.d.ts.map +1 -1
  14. package/dist/element.js +46 -6
  15. package/dist/element.js.map +1 -1
  16. package/dist/elements/casting.d.ts +3 -0
  17. package/dist/elements/casting.d.ts.map +1 -1
  18. package/dist/elements/casting.js +12 -15
  19. package/dist/elements/casting.js.map +1 -1
  20. package/dist/elements/control-bar.d.ts +16 -2
  21. package/dist/elements/control-bar.d.ts.map +1 -1
  22. package/dist/elements/control-bar.js +23 -2
  23. package/dist/elements/control-bar.js.map +1 -1
  24. package/dist/elements/drm-badge.js +1 -1
  25. package/dist/elements/error-screen.js +1 -1
  26. package/dist/elements/live-button.js +1 -1
  27. package/dist/elements/shared.js +3 -3
  28. package/dist/elements/speed-menu.d.ts.map +1 -1
  29. package/dist/elements/speed-menu.js +1 -1
  30. package/dist/elements/speed-menu.js.map +1 -1
  31. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  32. package/dist/elements/subtitles-menu.js +29 -6
  33. package/dist/elements/subtitles-menu.js.map +1 -1
  34. package/dist/es2015/controls/cues.js +2 -2
  35. package/dist/es2015/controls/icons.js +2 -0
  36. package/dist/es2015/element.js +63 -25
  37. package/dist/es2015/elements/casting.js +13 -15
  38. package/dist/es2015/elements/control-bar.js +23 -2
  39. package/dist/es2015/elements/drm-badge.js +1 -1
  40. package/dist/es2015/elements/error-screen.js +1 -1
  41. package/dist/es2015/elements/live-button.js +1 -1
  42. package/dist/es2015/elements/shared.js +3 -3
  43. package/dist/es2015/elements/speed-menu.js +1 -1
  44. package/dist/es2015/elements/subtitles-menu.js +29 -6
  45. package/dist/es2015/locales/ar.js +2 -0
  46. package/dist/es2015/locales/ca.js +2 -0
  47. package/dist/es2015/locales/de.js +2 -0
  48. package/dist/es2015/locales/es.js +2 -0
  49. package/dist/es2015/locales/fr.js +2 -0
  50. package/dist/es2015/locales/hi.js +2 -0
  51. package/dist/es2015/locales/it.js +2 -0
  52. package/dist/es2015/locales/ja.js +2 -0
  53. package/dist/es2015/locales/ko.js +2 -0
  54. package/dist/es2015/locales/pt.js +2 -0
  55. package/dist/es2015/locales/zh.js +2 -0
  56. package/dist/es2015/presets.js +2 -1
  57. package/dist/es2015/style.js +1 -1
  58. package/dist/host.d.ts +13 -1
  59. package/dist/host.d.ts.map +1 -1
  60. package/dist/host.js.map +1 -1
  61. package/dist/index.d.ts +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/locales/ar.d.ts +2 -0
  64. package/dist/locales/ar.d.ts.map +1 -1
  65. package/dist/locales/ar.js +2 -0
  66. package/dist/locales/ar.js.map +1 -1
  67. package/dist/locales/ca.d.ts +2 -0
  68. package/dist/locales/ca.d.ts.map +1 -1
  69. package/dist/locales/ca.js +2 -0
  70. package/dist/locales/ca.js.map +1 -1
  71. package/dist/locales/de.d.ts +2 -0
  72. package/dist/locales/de.d.ts.map +1 -1
  73. package/dist/locales/de.js +2 -0
  74. package/dist/locales/de.js.map +1 -1
  75. package/dist/locales/es.d.ts +2 -0
  76. package/dist/locales/es.d.ts.map +1 -1
  77. package/dist/locales/es.js +2 -0
  78. package/dist/locales/es.js.map +1 -1
  79. package/dist/locales/fr.d.ts +2 -0
  80. package/dist/locales/fr.d.ts.map +1 -1
  81. package/dist/locales/fr.js +2 -0
  82. package/dist/locales/fr.js.map +1 -1
  83. package/dist/locales/hi.d.ts +2 -0
  84. package/dist/locales/hi.d.ts.map +1 -1
  85. package/dist/locales/hi.js +2 -0
  86. package/dist/locales/hi.js.map +1 -1
  87. package/dist/locales/it.d.ts +2 -0
  88. package/dist/locales/it.d.ts.map +1 -1
  89. package/dist/locales/it.js +2 -0
  90. package/dist/locales/it.js.map +1 -1
  91. package/dist/locales/ja.d.ts +2 -0
  92. package/dist/locales/ja.d.ts.map +1 -1
  93. package/dist/locales/ja.js +2 -0
  94. package/dist/locales/ja.js.map +1 -1
  95. package/dist/locales/ko.d.ts +2 -0
  96. package/dist/locales/ko.d.ts.map +1 -1
  97. package/dist/locales/ko.js +2 -0
  98. package/dist/locales/ko.js.map +1 -1
  99. package/dist/locales/pt.d.ts +2 -0
  100. package/dist/locales/pt.d.ts.map +1 -1
  101. package/dist/locales/pt.js +2 -0
  102. package/dist/locales/pt.js.map +1 -1
  103. package/dist/locales/zh.d.ts +2 -0
  104. package/dist/locales/zh.d.ts.map +1 -1
  105. package/dist/locales/zh.js +2 -0
  106. package/dist/locales/zh.js.map +1 -1
  107. package/dist/messages.d.ts +4 -0
  108. package/dist/messages.d.ts.map +1 -1
  109. package/dist/presets.js +2 -1
  110. package/dist/presets.js.map +1 -1
  111. package/dist/style.js +1 -1
  112. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import { announcer } from "./announcer.js";
2
2
  import { createBreakMarks } from "./controls/breaks.js";
3
+ import { chapters } from "./controls/chapters.js";
3
4
  import { createMarkers } from "./controls/markers.js";
4
5
  import { live } from "./controls/session.js";
5
6
  import { languageName } from "./controls/track-names.js";
@@ -45,8 +46,8 @@ function emeAvailable() {
45
46
  return drmGuard().without === void 0;
46
47
  }
47
48
  /** `source` without its DRM, for a browser without EME. */
48
- function withoutDrm({ url, type, videoTracks }) {
49
- return _objectSpread2(_objectSpread2({ url }, type === void 0 ? {} : { type }), videoTracks === void 0 ? {} : { videoTracks });
49
+ function withoutDrm({ url, type, videoTracks, projection }) {
50
+ return _objectSpread2(_objectSpread2(_objectSpread2({ url }, type === void 0 ? {} : { type }), videoTracks === void 0 ? {} : { videoTracks }), projection === void 0 ? {} : { projection });
50
51
  }
51
52
  const CERTIFICATE_URL = "certificate-url";
52
53
  /** Everything else the element watches. Changing any of them reloads. */
@@ -278,6 +279,13 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
278
279
  get media() {
279
280
  return this.playback.media;
280
281
  }
282
+ /**
283
+ * The programme's chapters, in order: the engine's when its session holds
284
+ * some, else the video's chapters track. Read again on each access.
285
+ */
286
+ get chapters() {
287
+ return chapters(this.node, this.engine);
288
+ }
281
289
  /** The ranges the page named in this source: credits to skip, parts that must not play. */
282
290
  get markers() {
283
291
  return this.marks;
@@ -463,6 +471,20 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
463
471
  var _this$original$videoT, _this$original;
464
472
  return (_this$original$videoT = (_this$original = this.original) === null || _this$original === void 0 ? void 0 : _this$original.videoTracks) !== null && _this$original$videoT !== void 0 ? _this$original$videoT : [];
465
473
  }
474
+ /**
475
+ * How the playing picture maps onto a sphere, for 360° video: the
476
+ * source's `projection`, else the manifest's, else null for a flat one.
477
+ * A version of `videoSources` is flat.
478
+ */
479
+ get projection() {
480
+ var _this$original2, _this$current4, _track$renditions;
481
+ if (this.version !== null) return null;
482
+ const given = (_this$original2 = this.original) === null || _this$original2 === void 0 ? void 0 : _this$original2.projection;
483
+ if (given !== void 0) return given;
484
+ const track = (_this$current4 = this.current) === null || _this$current4 === void 0 || (_this$current4 = _this$current4.engine) === null || _this$current4 === void 0 ? void 0 : _this$current4.tracks.active("video");
485
+ for (const rendition of (_track$renditions = track === null || track === void 0 ? void 0 : track.renditions) !== null && _track$renditions !== void 0 ? _track$renditions : []) if (rendition.projection !== void 0) return rendition.projection;
486
+ return null;
487
+ }
466
488
  /** The version of `videoSources` that plays, or null for the source itself. */
467
489
  get videoSource() {
468
490
  return this.version;
@@ -474,14 +496,14 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
474
496
  * Fires `videosourcechange`.
475
497
  */
476
498
  selectVideoSource(track) {
477
- var _programme$videoTrack, _this$current$engine4, _this$current4;
499
+ var _programme$videoTrack, _this$current$engine4, _this$current5;
478
500
  const programme = this.original;
479
501
  if (programme === null || track === this.version) return;
480
502
  if (track !== null && ((_programme$videoTrack = programme.videoTracks) === null || _programme$videoTrack === void 0 ? void 0 : _programme$videoTrack.includes(track)) !== true) return;
481
503
  const media = this.playback.media;
482
504
  const at = Number.isFinite(media.duration) ? media.currentTime : null;
483
505
  const playing = !media.paused;
484
- const had = chosen((_this$current$engine4 = (_this$current4 = this.current) === null || _this$current4 === void 0 ? void 0 : _this$current4.engine) !== null && _this$current$engine4 !== void 0 ? _this$current$engine4 : null);
506
+ const had = chosen((_this$current$engine4 = (_this$current5 = this.current) === null || _this$current5 === void 0 ? void 0 : _this$current5.engine) !== null && _this$current$engine4 !== void 0 ? _this$current$engine4 : null);
485
507
  this.version = track;
486
508
  this.emit("videosourcechange", track);
487
509
  this.swap(track === null ? programme : versionSource(track, emeAvailable()), at, playing, had, true);
@@ -512,7 +534,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
512
534
  release = done;
513
535
  }
514
536
  this.enqueue(_asyncToGenerator(function* () {
515
- var _this$current$engine5, _this$current5;
537
+ var _this$current$engine5, _this$current6;
516
538
  const core = yield _this3.ensure();
517
539
  _this3.switching = true;
518
540
  if (_this3.away) _this3.handoff = {
@@ -532,7 +554,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
532
554
  resume(media, at, playing);
533
555
  if (release !== null) onNextFrame(media, at, release);
534
556
  }
535
- restore((_this$current$engine5 = (_this$current5 = _this3.current) === null || _this$current5 === void 0 ? void 0 : _this$current5.engine) !== null && _this$current$engine5 !== void 0 ? _this$current$engine5 : null, had);
557
+ restore((_this$current$engine5 = (_this$current6 = _this3.current) === null || _this$current6 === void 0 ? void 0 : _this$current6.engine) !== null && _this$current$engine5 !== void 0 ? _this$current$engine5 : null, had);
536
558
  }));
537
559
  }
538
560
  /** The device that plays in the video's place, its kind and its name, or null. The `casting` attribute carries the kind. */
@@ -558,7 +580,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
558
580
  this.playback.attach(remote.media);
559
581
  } else this.hand(session.source, this.position(), !this.node.paused, true);
560
582
  const end = () => {
561
- var _this$current6;
583
+ var _this$current7;
562
584
  if (this.device !== remote) return;
563
585
  const time = remote.media.currentTime;
564
586
  const playing = !remote.media.paused;
@@ -569,7 +591,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
569
591
  this.playback.detach();
570
592
  this.aim(null);
571
593
  if (!away) return;
572
- (_this$current6 = this.current) === null || _this$current6 === void 0 || (_this$current6 = _this$current6.engine) === null || _this$current6 === void 0 || _this$current6.resume();
594
+ (_this$current7 = this.current) === null || _this$current7 === void 0 || (_this$current7 = _this$current7.engine) === null || _this$current7 === void 0 || _this$current7.resume();
573
595
  if (this.current !== null && !this.frozenLive && Number.isFinite(time)) this.node.currentTime = time;
574
596
  if (playing) this.node.play().catch(() => void 0);
575
597
  };
@@ -582,9 +604,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
582
604
  * suspended, which no longer says where the edge is.
583
605
  */
584
606
  position() {
585
- var _this$current$engine6, _this$current7;
607
+ var _this$current$engine6, _this$current8;
586
608
  const node = this.node;
587
- const engine = (_this$current$engine6 = (_this$current7 = this.current) === null || _this$current7 === void 0 ? void 0 : _this$current7.engine) !== null && _this$current$engine6 !== void 0 ? _this$current$engine6 : null;
609
+ const engine = (_this$current$engine6 = (_this$current8 = this.current) === null || _this$current8 === void 0 ? void 0 : _this$current8.engine) !== null && _this$current$engine6 !== void 0 ? _this$current$engine6 : null;
588
610
  const edge = live(engine);
589
611
  if (edge !== void 0) {
590
612
  var _namespaces$pdt$toWal, _namespaces$pdt;
@@ -596,8 +618,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
596
618
  }
597
619
  /** Pauses the video and stops the engine's requests. The source stays loaded, for the chapters and the thumbnails. */
598
620
  freeze() {
599
- var _this$current$engine7, _this$current8;
600
- const engine = (_this$current$engine7 = (_this$current8 = this.current) === null || _this$current8 === void 0 ? void 0 : _this$current8.engine) !== null && _this$current$engine7 !== void 0 ? _this$current$engine7 : null;
621
+ var _this$current$engine7, _this$current9;
622
+ const engine = (_this$current$engine7 = (_this$current9 = this.current) === null || _this$current9 === void 0 ? void 0 : _this$current9.engine) !== null && _this$current$engine7 !== void 0 ? _this$current$engine7 : null;
601
623
  this.frozenLive = live(engine) !== void 0;
602
624
  this.node.pause();
603
625
  engine === null || engine === void 0 || engine.suspend();
@@ -630,14 +652,14 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
630
652
  addons
631
653
  });
632
654
  remote.load(source, load).catch(() => {
633
- var _this$current$handler, _this$current9;
655
+ var _this$current$handler, _this$current10;
634
656
  if (this.device !== remote) return;
635
657
  this.report({
636
658
  category: "remote",
637
659
  code: "REMOTE_LOAD_FAILED",
638
660
  fatal: false,
639
661
  recoverable: true,
640
- handler: (_this$current$handler = (_this$current9 = this.current) === null || _this$current9 === void 0 ? void 0 : _this$current9.handler) !== null && _this$current$handler !== void 0 ? _this$current$handler : null
662
+ handler: (_this$current$handler = (_this$current10 = this.current) === null || _this$current10 === void 0 ? void 0 : _this$current10.handler) !== null && _this$current$handler !== void 0 ? _this$current$handler : null
641
663
  });
642
664
  });
643
665
  }
@@ -669,8 +691,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
669
691
  }
670
692
  /** The engine feeding the video, or null for a native session and before the first load. */
671
693
  get engine() {
672
- var _this$current$engine8, _this$current10;
673
- return (_this$current$engine8 = (_this$current10 = this.current) === null || _this$current10 === void 0 ? void 0 : _this$current10.engine) !== null && _this$current$engine8 !== void 0 ? _this$current$engine8 : null;
694
+ var _this$current$engine8, _this$current11;
695
+ return (_this$current$engine8 = (_this$current11 = this.current) === null || _this$current11 === void 0 ? void 0 : _this$current11.engine) !== null && _this$current$engine8 !== void 0 ? _this$current$engine8 : null;
674
696
  }
675
697
  /**
676
698
  * The fatal error of the current load, or null once a load starts or
@@ -830,8 +852,8 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
830
852
  * reads as off, as in the subtitles menu.
831
853
  */
832
854
  tracks() {
833
- var _this$current$engine9, _this$current11;
834
- const engine = (_this$current$engine9 = (_this$current11 = this.current) === null || _this$current11 === void 0 ? void 0 : _this$current11.engine) !== null && _this$current$engine9 !== void 0 ? _this$current$engine9 : null;
855
+ var _this$current$engine9, _this$current12;
856
+ const engine = (_this$current$engine9 = (_this$current12 = this.current) === null || _this$current12 === void 0 ? void 0 : _this$current12.engine) !== null && _this$current$engine9 !== void 0 ? _this$current$engine9 : null;
835
857
  let audio;
836
858
  let text;
837
859
  if (engine !== null) {
@@ -868,6 +890,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
868
890
  this.toggleAttribute("ended", video.ended);
869
891
  this.toggleAttribute("muted", video.muted);
870
892
  this.toggleAttribute("audio", this.audio());
893
+ const projection = this.projection;
894
+ if (projection === null) this.removeAttribute("projection");
895
+ else this.setAttribute("projection", projection);
871
896
  this.toggleAttribute("started", this.started);
872
897
  this.toggleAttribute("waiting", this.waiting);
873
898
  this.toggleAttribute("error", this.failure !== null);
@@ -916,7 +941,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
916
941
  return;
917
942
  }
918
943
  if (name === CHAPTERS) {
919
- this.chapters();
944
+ this.chaptersAttribute();
920
945
  return;
921
946
  }
922
947
  if (name === LAYOUT) {
@@ -958,10 +983,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
958
983
  }
959
984
  }
960
985
  /** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
961
- chapters() {
962
- var _this$current$engine10, _this$current12;
986
+ chaptersAttribute() {
987
+ var _this$current$engine10, _this$current13;
963
988
  const url = this.getAttribute(CHAPTERS);
964
- const engine = (_this$current$engine10 = (_this$current12 = this.current) === null || _this$current12 === void 0 ? void 0 : _this$current12.engine) !== null && _this$current$engine10 !== void 0 ? _this$current$engine10 : null;
989
+ const engine = (_this$current$engine10 = (_this$current13 = this.current) === null || _this$current13 === void 0 ? void 0 : _this$current13.engine) !== null && _this$current$engine10 !== void 0 ? _this$current$engine10 : null;
965
990
  const api = engine === null ? void 0 : namespaces(engine).chapters;
966
991
  if (api !== void 0) {
967
992
  var _this$track;
@@ -1032,6 +1057,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
1032
1057
  var _this4 = this;
1033
1058
  return _asyncToGenerator(function* () {
1034
1059
  _this4.unmount();
1060
+ if (!_this4.hasAttribute("poster")) _this4.node.removeAttribute("poster");
1035
1061
  if (!_this4.isConnected) return;
1036
1062
  const sources = _this4.wanted();
1037
1063
  _this4.tried = JSON.stringify(sources);
@@ -1084,7 +1110,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
1084
1110
  var _namespaces$chapters;
1085
1111
  (_namespaces$chapters = namespaces(session.engine).chapters) === null || _namespaces$chapters === void 0 || _namespaces$chapters.set(chapters);
1086
1112
  }
1087
- this.chapters();
1113
+ this.chaptersAttribute();
1088
1114
  }
1089
1115
  ensure() {
1090
1116
  var _this5 = this;
@@ -1124,6 +1150,16 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
1124
1150
  })();
1125
1151
  }
1126
1152
  /**
1153
+ * An add-on or an element inside the player needs the engine, so Safari's
1154
+ * own HLS is not the default. Read at each load: an element may come later.
1155
+ */
1156
+ needsEngine() {
1157
+ var _this$options$addons2;
1158
+ if (((_this$options$addons2 = this.options.addons) !== null && _this$options$addons2 !== void 0 ? _this$options$addons2 : []).some((addon) => addon.engine === true)) return true;
1159
+ for (const element of this.querySelectorAll("*")) if (element.needsEngine === true) return true;
1160
+ return false;
1161
+ }
1162
+ /**
1127
1163
  * Read at each use, not once in the constructor. Importing the package
1128
1164
  * registers the element, and the parser's elements are constructed then,
1129
1165
  * before the page's own `define()` call can run.
@@ -1140,8 +1176,10 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
1140
1176
  const config = _this6.options.config === void 0 ? {} : { config: _this6.options.config };
1141
1177
  const native = (stages) => nativeHandler({
1142
1178
  prefer: (source, env) => {
1143
- var _this$options$addons2;
1144
- return _this6.getAttribute(NATIVE_HLS) !== "off" && !((_this$options$addons2 = _this6.options.addons) !== null && _this$options$addons2 !== void 0 ? _this$options$addons2 : []).some((addon) => addon.engine === true) && preferNativeHls(source, env);
1179
+ const asked = _this6.getAttribute(NATIVE_HLS);
1180
+ if (asked === "off") return false;
1181
+ if (asked !== "on" && _this6.needsEngine()) return false;
1182
+ return preferNativeHls(source, env);
1145
1183
  },
1146
1184
  drm: () => _this6.drm(stages)
1147
1185
  });
@@ -1,22 +1,10 @@
1
+ import { icon } from "../controls/icons.js";
1
2
  import { el } from "../dom.js";
2
3
  import { fill } from "../labels.js";
3
4
  import { Component } from "./component.js";
4
5
  import { style } from "./shared.js";
5
6
  // src/elements/casting.ts
6
- /**
7
- * <mbx-casting>: what the picture shows while a device plays in the
8
- * video's place. The programme's poster, or its image, covers the paused
9
- * video, with a line that names the device: "Casting to Living room". The
10
- * controls stay as they are and drive the device.
11
- *
12
- * Shown while the player carries `casting`, for a Chromecast and for
13
- * AirPlay alike, and hidden otherwise. The element carries `casting` too,
14
- * with the device's kind, so a page styles one kind in CSS. Safari names no AirPlay device, so
15
- * the line is "AirPlay" there. The `label` attribute gives the line its
16
- * words, with `{device}` for the name. Placed first among the screens, so
17
- * the title, the start button and the bar paint over it.
18
- */
19
- const STYLE = ":host{color:var(--mbx-text);font-family:var(--mbx-font);pointer-events:none;background:#000;justify-content:center;align-items:center;display:none;position:absolute;top:0;bottom:0;left:0;right:0}:host([casting]){display:flex}:host([hidden]){display:none}[part~=poster]{object-fit:contain;opacity:.45;width:100%;height:100%;position:absolute;top:0;left:0}[part~=label]{padding:0 var(--mbx-pad);text-align:center;position:relative}";
7
+ const STYLE = ":host{color:var(--mbx-text);font-family:var(--mbx-font);pointer-events:none;background:#000;justify-content:center;align-items:center;display:none;position:absolute;top:0;bottom:0;left:0;right:0}:host([casting]){display:flex}:host([hidden]){display:none}[part~=poster]{object-fit:contain;opacity:.35;width:100%;height:100%;position:absolute;top:0;left:0}[part~=device]{max-width:100%;padding:0 var(--mbx-pad) var(--mbx-bar-rows,0px);text-align:center;text-shadow:0 1px 3px #0009;flex-direction:column;align-items:center;display:flex;position:relative}[part~=icon]{fill:currentColor;filter:drop-shadow(0 1px 3px #0009);width:3.5em;height:3.5em;margin-bottom:.6em}[part~=label]{font-size:1.25em;font-weight:600;line-height:1.3}:host([layout=compact]) [part~=icon]{width:2.5em;height:2.5em;margin-bottom:.4em}:host([layout=compact]) [part~=label]{font-size:1em}";
20
8
  var MbxCasting = class extends Component {
21
9
  static get observedAttributes() {
22
10
  return ["label"];
@@ -27,9 +15,12 @@ var MbxCasting = class extends Component {
27
15
  this.poster = el("img", "poster");
28
16
  this.poster.alt = "";
29
17
  this.poster.hidden = true;
18
+ this.device = el("div", "device");
30
19
  this.label = el("div", "label");
31
20
  this.label.setAttribute("role", "status");
32
- root.append(style(STYLE), this.poster, this.label);
21
+ this.device.append(this.label);
22
+ this.glyph = null;
23
+ root.append(style(STYLE), this.poster, this.device);
33
24
  }
34
25
  attach(player) {
35
26
  this.listen(player, ["programmechange"], () => {
@@ -51,6 +42,13 @@ var MbxCasting = class extends Component {
51
42
  const poster = (_ref = (_metadata$poster = metadata === null || metadata === void 0 ? void 0 : metadata.poster) !== null && _metadata$poster !== void 0 ? _metadata$poster : metadata === null || metadata === void 0 ? void 0 : metadata.image) !== null && _ref !== void 0 ? _ref : player.getAttribute("poster");
52
43
  this.poster.hidden = poster === null || poster === void 0;
53
44
  if (poster !== null && poster !== void 0 && this.poster.getAttribute("src") !== poster) this.poster.src = poster;
45
+ const glyph = target.kind === "airplay" ? "airplay-active" : "cast";
46
+ if (glyph !== this.glyph) {
47
+ var _this$device$querySel;
48
+ this.glyph = glyph;
49
+ (_this$device$querySel = this.device.querySelector("svg")) === null || _this$device$querySel === void 0 || _this$device$querySel.remove();
50
+ this.device.insertBefore(icon(glyph), this.label);
51
+ }
54
52
  this.label.textContent = target.name === "" ? target.kind === "airplay" ? this.word("label", "airplay", "AirPlay") : "" : fill(this.word("label", "castingTo", "Casting to {device}"), { device: target.name });
55
53
  }
56
54
  };
@@ -74,6 +74,8 @@ var MbxControlBar = class extends Component {
74
74
  super();
75
75
  this.timer = void 0;
76
76
  this.keyboard = false;
77
+ this.touch = false;
78
+ this.shownAtPress = false;
77
79
  this.cues = null;
78
80
  this.screen = null;
79
81
  this.resizer = null;
@@ -153,6 +155,7 @@ var MbxControlBar = class extends Component {
153
155
  }
154
156
  held(player) {
155
157
  if (shownPaused(player, ["switching"])) return true;
158
+ if (player.hasAttribute("casting")) return true;
156
159
  if (this.querySelector("[open]") !== null) return true;
157
160
  if (!this.keyboard) return false;
158
161
  const active = this.getRootNode().activeElement;
@@ -173,6 +176,12 @@ var MbxControlBar = class extends Component {
173
176
  }
174
177
  this.idle(player, true);
175
178
  }
179
+ /** Hides the bar now, as a tap asks: the next input shows it again. */
180
+ rest(player) {
181
+ clearTimeout(this.timer);
182
+ this.timer = void 0;
183
+ this.idle(player, true);
184
+ }
176
185
  wake(player) {
177
186
  clearTimeout(this.timer);
178
187
  this.idle(player, false);
@@ -194,6 +203,7 @@ var MbxControlBar = class extends Component {
194
203
  }
195
204
  key(player, event) {
196
205
  this.keyboard = true;
206
+ this.touch = false;
197
207
  this.wake(player);
198
208
  if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;
199
209
  const video = player.media;
@@ -265,13 +275,24 @@ var MbxControlBar = class extends Component {
265
275
  this.keyboard = false;
266
276
  this.wake(player);
267
277
  };
278
+ const press = (event) => {
279
+ this.touch = event.pointerType === "touch";
280
+ this.shownAtPress = !this.hasAttribute("idle");
281
+ pointer();
282
+ };
268
283
  const key = (event) => {
269
284
  this.key(player, event);
270
285
  };
271
286
  const click = (event) => {
272
- if (event.composedPath()[0] === videoOf(player)) toggle(video);
287
+ if (event.composedPath()[0] !== videoOf(player)) return;
288
+ if (this.touch && !this.hasAttribute("tap-plays") && !player.hasAttribute("casting")) {
289
+ if (this.shownAtPress) this.rest(player);
290
+ return;
291
+ }
292
+ toggle(video);
273
293
  };
274
- this.listen(player, ["pointermove", "pointerdown"], pointer);
294
+ this.listen(player, ["pointermove"], pointer);
295
+ this.listen(player, ["pointerdown"], press);
275
296
  player.addEventListener("keydown", key);
276
297
  player.addEventListener("click", click);
277
298
  this.keep(() => {
@@ -5,7 +5,7 @@ import { namespaces } from "../namespaces.js";
5
5
  import { Component } from "./component.js";
6
6
  import { style } from "./shared.js";
7
7
  // src/elements/drm-badge.ts
8
- const STYLE = ":host{width:2.5em;height:2.5em;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#1c1c20f2;margin-bottom:.6154em;padding:.6154em .7692em;font-size:.8125em;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
8
+ const STYLE = ":host{width:2.5em;height:2.5em;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline-style:var(--mbx-focus-ring,none)}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#1c1c20f2;margin-bottom:.6154em;padding:.6154em .7692em;font-size:.8125em;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
9
9
  /** The name a viewer knows a key system by. */
10
10
  function keySystemName(id) {
11
11
  if (id.startsWith("com.widevine")) return "Widevine";
@@ -2,7 +2,7 @@ import { el } from "../dom.js";
2
2
  import { Component } from "./component.js";
3
3
  import { style } from "./shared.js";
4
4
  // src/elements/error-screen.ts
5
- const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=message]{max-width:32em}[part~=actions]>:not([hidden])~:not([hidden]){margin-left:.5333em}[part~=action]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=action]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=action]:focus:not(:focus-visible){outline:none}";
5
+ const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=message]{max-width:32em}[part~=actions]>:not([hidden])~:not([hidden]){margin-left:.5333em}[part~=action]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=action]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=action]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}";
6
6
  /** The diagnostics element, another package's, named here as a string. */
7
7
  const DIAGNOSTICS = "mbx-diagnostics";
8
8
  var MbxErrorScreen = class extends Component {
@@ -16,7 +16,7 @@ import { seekRow, style } from "./shared.js";
16
16
  * `text`, the name from `label-live` and `label-at-edge`. It sits in the
17
17
  * bar's seek row unless the page says otherwise.
18
18
  */
19
- const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:2.5em;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 .5em;font-size:.75em;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:.625em;height:.625em;margin-right:.375em;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
19
+ const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:2.5em;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 .5em;font-size:.75em;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:.625em;height:.625em;margin-right:.375em;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
20
20
  var MbxLiveButton = class extends Component {
21
21
  static get observedAttributes() {
22
22
  return [
@@ -1,6 +1,6 @@
1
1
  // src/elements/shared.ts
2
- const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
3
- const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
2
+ const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:var(--mbx-focus-tooltip,0);transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
3
+ const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
4
4
  const BUTTON_STYLE = BUTTON_STYLE_CSS;
5
5
  /** The style of a slider: the rail, the track with its fill, and the thumb. */
6
6
  const SLIDER_STYLE = SLIDER_STYLE_CSS;
@@ -11,7 +11,7 @@ function number(node, name, fallback) {
11
11
  return Number.isFinite(value) && value >= 0 ? value : fallback;
12
12
  }
13
13
  /** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
14
- const MENU_STYLE = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
14
+ const MENU_STYLE = ":host{display:inline-flex}:host([hidden]),:host([away]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:var(--mbx-focus-tooltip,0);transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline-style:var(--mbx-focus-ring,none)}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
15
15
  /** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
16
16
  function seekRow(node) {
17
17
  var _node$parentElement;
@@ -20,7 +20,7 @@ var MbxSpeedMenu = class extends MenuElement {
20
20
  }
21
21
  constructor() {
22
22
  super(...single("playback-speed"));
23
- this.leaves = "remote";
23
+ this.leaves = "device";
24
24
  show(this.slots, "default");
25
25
  }
26
26
  name() {
@@ -7,6 +7,10 @@ import { show } from "./shared.js";
7
7
  import { isSdh } from "mattebox";
8
8
  // src/elements/subtitles-menu.ts
9
9
  const OFF = "off";
10
+ /** The live captions' item, a value no track id or native index takes. */
11
+ const LIVE = "live-captions";
12
+ /** The player's attribute a live captions package sets: absent, `off` or `on`. */
13
+ const LIVE_CAPTIONS = "live-captions";
10
14
  const SUBTITLE_SIZE = "subtitle-size";
11
15
  const SUBTITLE_BACKGROUND = "subtitle-background";
12
16
  const SIZES = [
@@ -61,6 +65,8 @@ var MbxSubtitlesMenu = class extends MenuElement {
61
65
  "label-background",
62
66
  "label-sdh",
63
67
  "label-cc",
68
+ "label-live",
69
+ "label-generated",
64
70
  ...SIZES.map(([id]) => `label-${id}`),
65
71
  ...BACKGROUNDS.map(([id]) => `label-${id}`)
66
72
  ];
@@ -104,6 +110,9 @@ var MbxSubtitlesMenu = class extends MenuElement {
104
110
  };
105
111
  }
106
112
  attach(player) {
113
+ this.observe(player, [LIVE_CAPTIONS], () => {
114
+ this.render();
115
+ });
107
116
  this.follow(player, (engine) => {
108
117
  this.engine = engine;
109
118
  this.render();
@@ -140,7 +149,19 @@ var MbxSubtitlesMenu = class extends MenuElement {
140
149
  const sdh = this.word("label-sdh", "sdh", "SDH");
141
150
  const [tracks, active] = listed !== void 0 ? this.native(listed) : trackItems(engine, "text", (track) => [...track.instreamId !== void 0 ? [cc] : [], ...isSdh(track) ? [sdh] : []], (track) => track.forced !== true);
142
151
  const word = this.word("label-track", "track", "Track");
143
- const items = [[OFF, this.word("label-off", "subtitlesOff", "Off")], ...trackNames(tracks, word, player.locale || void 0)];
152
+ const live = player.getAttribute(LIVE_CAPTIONS);
153
+ const generated = this.word("label-generated", "liveCaptionsGenerated", "Generated automatically from speech");
154
+ const items = [
155
+ [OFF, this.word("label-off", "subtitlesOff", "Off")],
156
+ ...live === null ? [] : [[
157
+ LIVE,
158
+ this.word("label-live", "liveCaptions", "Live captions"),
159
+ void 0,
160
+ void 0,
161
+ [generated]
162
+ ]],
163
+ ...trackNames(tracks, word, player.locale || void 0)
164
+ ];
144
165
  this.menu.fill([{
145
166
  name: "track",
146
167
  label: word,
@@ -148,15 +169,17 @@ var MbxSubtitlesMenu = class extends MenuElement {
148
169
  items,
149
170
  badgeGlyphs: {
150
171
  [cc]: () => icon("closed-captions"),
151
- [sdh]: () => icon("sdh")
172
+ [sdh]: () => icon("sdh"),
173
+ [generated]: () => icon("generated")
152
174
  },
153
- value: active !== null && active !== void 0 ? active : OFF,
175
+ value: live === "on" ? LIVE : active !== null && active !== void 0 ? active : OFF,
154
176
  onSelect: (value) => {
177
+ if (live !== null) player.setAttribute(LIVE_CAPTIONS, value === LIVE ? "on" : "off");
155
178
  if (listed !== void 0) {
156
179
  for (const track of listed) track.mode = "disabled";
157
180
  const chosen = listed[Number(value)];
158
181
  if (chosen !== void 0) chosen.mode = "showing";
159
- } else if (value === OFF) engine === null || engine === void 0 || engine.tracks.deselect("text");
182
+ } else if (value === OFF || value === LIVE) engine === null || engine === void 0 || engine.tracks.deselect("text");
160
183
  else engine === null || engine === void 0 || engine.tracks.select(value);
161
184
  this.render();
162
185
  }
@@ -165,8 +188,8 @@ var MbxSubtitlesMenu = class extends MenuElement {
165
188
  label: this.word("label-settings", "subtitleSettings", "Settings"),
166
189
  entries: [this.looks(player, SUBTITLE_SIZE, "size", "subtitleSize", "Size", SIZES, "medium", "text-size"), this.looks(player, SUBTITLE_BACKGROUND, "background", "subtitleBackground", "Background", BACKGROUNDS, "dark", "text-background")]
167
190
  }]);
168
- show(this.slots, active === null ? "off" : "on");
169
- this.hidden = tracks.length === 0;
191
+ show(this.slots, active === null && live !== "on" ? "off" : "on");
192
+ this.hidden = tracks.length === 0 && live === null;
170
193
  }
171
194
  };
172
195
  export { MbxSubtitlesMenu, SUBTITLE_BACKGROUND, SUBTITLE_SIZE };
@@ -40,6 +40,8 @@ var ar_default = {
40
40
  track: "المسار",
41
41
  subtitles: "الترجمة",
42
42
  subtitlesOff: "إيقاف",
43
+ liveCaptions: "ترجمة مباشرة",
44
+ liveCaptionsGenerated: "مُنشأة تلقائيًا من الكلام",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "الإعدادات",
@@ -40,6 +40,8 @@ var ca_default = {
40
40
  track: "Pista",
41
41
  subtitles: "Subtítols",
42
42
  subtitlesOff: "Cap",
43
+ liveCaptions: "Subtítols en directe",
44
+ liveCaptionsGenerated: "Generats automàticament a partir de la veu",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "Opcions",
@@ -40,6 +40,8 @@ var de_default = {
40
40
  track: "Spur",
41
41
  subtitles: "Untertitel",
42
42
  subtitlesOff: "Aus",
43
+ liveCaptions: "Live-Untertitel",
44
+ liveCaptionsGenerated: "Automatisch aus der Sprache erzeugt",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "Einstellungen",
@@ -40,6 +40,8 @@ var es_default = {
40
40
  track: "Pista",
41
41
  subtitles: "Subtítulos",
42
42
  subtitlesOff: "Desactivados",
43
+ liveCaptions: "Subtítulos en directo",
44
+ liveCaptionsGenerated: "Generados automáticamente a partir del habla",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "Ajustes",
@@ -40,6 +40,8 @@ var fr_default = {
40
40
  track: "Piste",
41
41
  subtitles: "Sous-titres",
42
42
  subtitlesOff: "Désactivés",
43
+ liveCaptions: "Sous-titres en direct",
44
+ liveCaptionsGenerated: "Générés automatiquement à partir de la parole",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "Réglages",
@@ -40,6 +40,8 @@ var hi_default = {
40
40
  track: "ट्रैक",
41
41
  subtitles: "उपशीर्षक",
42
42
  subtitlesOff: "बंद",
43
+ liveCaptions: "लाइव कैप्शन",
44
+ liveCaptionsGenerated: "बोली से अपने आप बनाए गए",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "सेटिंग",
@@ -40,6 +40,8 @@ var it_default = {
40
40
  track: "Traccia",
41
41
  subtitles: "Sottotitoli",
42
42
  subtitlesOff: "Disattivati",
43
+ liveCaptions: "Sottotitoli in diretta",
44
+ liveCaptionsGenerated: "Generati automaticamente dal parlato",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "Impostazioni",
@@ -40,6 +40,8 @@ var ja_default = {
40
40
  track: "トラック",
41
41
  subtitles: "字幕",
42
42
  subtitlesOff: "オフ",
43
+ liveCaptions: "ライブ字幕",
44
+ liveCaptionsGenerated: "音声から自動生成",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "設定",
@@ -40,6 +40,8 @@ var ko_default = {
40
40
  track: "트랙",
41
41
  subtitles: "자막",
42
42
  subtitlesOff: "끄기",
43
+ liveCaptions: "실시간 자막",
44
+ liveCaptionsGenerated: "음성에서 자동 생성됨",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "설정",
@@ -40,6 +40,8 @@ var pt_default = {
40
40
  track: "Faixa",
41
41
  subtitles: "Legendas",
42
42
  subtitlesOff: "Desligadas",
43
+ liveCaptions: "Legendas em direto",
44
+ liveCaptionsGenerated: "Geradas automaticamente a partir da fala",
43
45
  sdh: "SDH",
44
46
  closedCaptions: "CC",
45
47
  subtitleSettings: "Definições",