@brightspace-ui/labs 2.63.2 → 2.63.4

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.
package/package.json CHANGED
@@ -112,5 +112,5 @@
112
112
  "parse-srt": "^1.0.0-alpha",
113
113
  "webvtt-parser": "^2"
114
114
  },
115
- "version": "2.63.2"
115
+ "version": "2.63.4"
116
116
  }
@@ -253,10 +253,7 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
253
253
  if (!track) return;
254
254
 
255
255
  if (currentTime < this._audioDescriptionPreviousTime) {
256
- this._audioDescriptionIndex = track.descriptions.findIndex(description => description.time >= currentTime);
257
- if (this._audioDescriptionIndex < 0) this._audioDescriptionIndex = track.descriptions.length;
258
- this._cancelAudioDescription();
259
- this._activeDescriptionCue = null;
256
+ this._resetAudioDescriptionCursor(currentTime);
260
257
  }
261
258
 
262
259
  const next = track.descriptions[this._audioDescriptionIndex];
@@ -732,6 +732,17 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerAudioDescriptionsMixin(
732
732
  return this._media ? this._media.textTracks : null;
733
733
  }
734
734
 
735
+ connectedCallback() {
736
+ super.connectedCallback();
737
+ fullscreenApi.onchange(this.#onFullscreenChange);
738
+ }
739
+
740
+ disconnectedCallback() {
741
+ fullscreenApi.off('change', this.#onFullscreenChange);
742
+ this.#releaseFullscreenEscape();
743
+ super.disconnectedCallback();
744
+ }
745
+
735
746
  firstUpdated(changedProperties) {
736
747
  super.firstUpdated(changedProperties);
737
748
 
@@ -1039,8 +1050,38 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerAudioDescriptionsMixin(
1039
1050
  return this.localize('components:mediaPlayer:off');
1040
1051
  }
1041
1052
 
1053
+ #isFullscreen = false;
1054
+ #keyboardLocked = false;
1042
1055
  #searchTimeout = null;
1043
1056
 
1057
+ #onFullscreenChange = () => {
1058
+ const root = this.shadowRoot;
1059
+ const isFullscreen = !!this._mediaContainer && (root?.fullscreenElement ?? root?.webkitFullscreenElement) === this._mediaContainer;
1060
+ if (isFullscreen === this.#isFullscreen) return;
1061
+ this.#isFullscreen = isFullscreen;
1062
+
1063
+ if (isFullscreen) {
1064
+ document.addEventListener('keydown', this.#onFullscreenKeyDown, true);
1065
+ // Lets Escape reach the page so open menus can close before fullscreen exits (Chromium only)
1066
+ navigator.keyboard?.lock?.(['Escape'])
1067
+ .then(() => {
1068
+ if (this.#isFullscreen) this.#keyboardLocked = true;
1069
+ else navigator.keyboard.unlock();
1070
+ })
1071
+ .catch(() => {});
1072
+ } else {
1073
+ this.#releaseFullscreenEscape();
1074
+ // Browsers without keyboard lock exit fullscreen on Escape without dispatching it to the page
1075
+ this.#getOpenDropdowns().forEach(dropdown => dropdown.close());
1076
+ }
1077
+ };
1078
+
1079
+ // Capture phase runs before the dropdowns' own Escape handler closes them
1080
+ #onFullscreenKeyDown = e => {
1081
+ if (e.key !== 'Escape' || this.#getOpenDropdowns().length > 0) return;
1082
+ fullscreenApi.exit();
1083
+ };
1084
+
1044
1085
  _beginIOSVideoFullscreen() {
1045
1086
  this._iosVideoFullscreen = true;
1046
1087
  }
@@ -2355,6 +2396,18 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerAudioDescriptionsMixin(
2355
2396
  }
2356
2397
  }
2357
2398
  }
2399
+
2400
+ #getOpenDropdowns() {
2401
+ return [...(this.shadowRoot?.querySelectorAll('d2l-dropdown-menu[opened], d2l-dropdown-content[opened]') ?? [])];
2402
+ }
2403
+
2404
+ #releaseFullscreenEscape() {
2405
+ document.removeEventListener('keydown', this.#onFullscreenKeyDown, true);
2406
+ if (this.#keyboardLocked) {
2407
+ navigator.keyboard?.unlock?.();
2408
+ this.#keyboardLocked = false;
2409
+ }
2410
+ }
2358
2411
  }
2359
2412
 
2360
2413
  customElements.define('d2l-labs-media-player', MediaPlayer);