@brightspace-ui/labs 2.63.6 → 2.63.7

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.6"
115
+ "version": "2.63.7"
116
116
  }
@@ -28,6 +28,8 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
28
28
  static properties = {
29
29
  _audioDescriptionControlsInMenu: { state: true },
30
30
  _audioDescriptionDialogOpened: { state: true },
31
+ _audioDescriptionPaused: { state: true },
32
+ _audioDescriptionPausedVideo: { state: true },
31
33
  _audioDescriptionPlaying: { state: true },
32
34
  _audioDescriptionTracks: { state: true },
33
35
  _canReplayAudioDescription: { state: true },
@@ -73,6 +75,7 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
73
75
  this._audioDescriptionTracks = [];
74
76
  this._audioDescriptionIndex = 0;
75
77
  this._audioDescriptionPreviousTime = -0.001;
78
+ this._audioDescriptionPaused = false;
76
79
  this._audioDescriptionPausedVideo = false;
77
80
  this._audioDescriptionPlaying = false;
78
81
  this._audioDescriptionControlsInMenu = false;
@@ -95,6 +98,11 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
95
98
  super.disconnectedCallback();
96
99
  }
97
100
 
101
+ // True while a pause-video description is speaking, so the player should present itself as playing
102
+ get _audioDescriptionHoldingPlayback() {
103
+ return this._audioDescriptionPausedVideo && !this._audioDescriptionPaused;
104
+ }
105
+
98
106
  #audioDescriptionResizeObserver = new ResizeObserver(entries => {
99
107
  for (const entry of entries) {
100
108
  this._audioDescriptionControlsInMenu = entry.contentRect.width < AUDIO_DESCRIPTION_CONTROLS_IN_MENU_MAX_WIDTH_PX;
@@ -104,8 +112,11 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
104
112
  _cancelAudioDescription() {
105
113
  if (this._audioDescriptionUtterance && window.speechSynthesis) {
106
114
  window.speechSynthesis.cancel();
115
+ // Some browsers stay paused after cancel(), which would hold back the next utterance
116
+ if (this._audioDescriptionPaused) window.speechSynthesis.resume();
107
117
  }
108
118
  this._audioDescriptionUtterance = null;
119
+ this._audioDescriptionPaused = false;
109
120
  this._audioDescriptionPausedVideo = false;
110
121
  this._audioDescriptionPlaying = false;
111
122
  }
@@ -285,6 +296,12 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
285
296
  this._audioDescriptionPreviousTime = currentTime;
286
297
  }
287
298
 
299
+ _pauseAudioDescription() {
300
+ if (!this._audioDescriptionPlaying || this._audioDescriptionPaused) return;
301
+ this._audioDescriptionPaused = true;
302
+ window.speechSynthesis?.pause();
303
+ }
304
+
288
305
  _replayAudioDescription() {
289
306
  if (!this._audioDescriptionPlaying) return;
290
307
  const track = this.#getSelectedAudioDescriptionTrack();
@@ -317,11 +334,22 @@ export const MediaPlayerAudioDescriptionsMixin = superclass => class extends sup
317
334
  this._resetAudioDescriptionCursor(this.currentTime);
318
335
  }
319
336
 
337
+ _resumeAudioDescription() {
338
+ if (!this._audioDescriptionPaused) return;
339
+ this._audioDescriptionPaused = false;
340
+ window.speechSynthesis?.resume();
341
+ }
342
+
320
343
  _skipAudioDescription() {
321
344
  if (!this._audioDescriptionPlaying || !this.#getSelectedAudioDescriptionTrack()?.pauseVideo) return;
322
- const pausedVideo = this._audioDescriptionPausedVideo;
345
+ const resumeVideo = this._audioDescriptionHoldingPlayback;
323
346
  this._cancelAudioDescription();
324
- if (pausedVideo) this._play();
347
+ if (resumeVideo) this._play();
348
+ }
349
+
350
+ _toggleAudioDescriptionPause() {
351
+ if (this._audioDescriptionPaused) this._resumeAudioDescription();
352
+ else this._pauseAudioDescription();
325
353
  }
326
354
 
327
355
  #getAudioDescriptionVoice(language) {
@@ -659,11 +659,12 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerTranscriptMixin(MediaPl
659
659
 
660
660
  render() {
661
661
  const fullscreenIcon = fullscreenApi.isFullscreen ? 'tier1:smallscreen' : 'tier1:fullscreen';
662
- const playIcon = this._playing ? 'tier1:pause' : 'tier1:play';
662
+ const playing = this._playing || this._audioDescriptionHoldingPlayback;
663
+ const playIcon = playing ? 'tier1:pause' : 'tier1:play';
663
664
  const volumeIcon = this._muted ? 'tier1:volume-muted' : 'tier1:volume';
664
665
 
665
666
  const fullscreenTooltip = `${fullscreenApi.isFullscreen ? this.localize('components:mediaPlayer:exitFullscreen') : this.localize('components:mediaPlayer:fullscreen')} (${KEY_BINDINGS.fullscreen})`;
666
- const playTooltip = `${this._playing ? this.localize('components:mediaPlayer:pause') : this.localize('components:mediaPlayer:play')} (${KEY_BINDINGS.play})`;
667
+ const playTooltip = `${playing ? this.localize('components:mediaPlayer:pause') : this.localize('components:mediaPlayer:play')} (${KEY_BINDINGS.play})`;
667
668
  const volumeTooltip = `${this._muted ? this.localize('components:mediaPlayer:unmute') : this.localize('components:mediaPlayer:mute')} (${KEY_BINDINGS.mute})`;
668
669
 
669
670
  const height = this._maintainHeight ? `${this._maintainHeight}px` : (this._heightPixels ? `${this._heightPixels}px` : '100%');
@@ -864,13 +865,13 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerTranscriptMixin(MediaPl
864
865
  }
865
866
 
866
867
  pause() {
867
- if (this._media && !this._media.paused) {
868
+ if (this._media && (!this._media.paused || this._audioDescriptionHoldingPlayback)) {
868
869
  this._togglePlay();
869
870
  }
870
871
  }
871
872
 
872
873
  play() {
873
- if (this._media && this._media.paused) {
874
+ if (this._media && this._media.paused && !this._audioDescriptionHoldingPlayback) {
874
875
  this._togglePlay();
875
876
  }
876
877
  }
@@ -1039,8 +1040,9 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerTranscriptMixin(MediaPl
1039
1040
  }
1040
1041
 
1041
1042
  _getMediaAreaView() {
1042
- const playIcon = `tier3:${this._playing ? 'pause' : 'play'}`;
1043
- const playTooltip = `${this._playing ? this.localize('components:mediaPlayer:pause') : this.localize('components:mediaPlayer:play')} (${KEY_BINDINGS.play})`;
1043
+ const playing = this._playing || this._audioDescriptionHoldingPlayback;
1044
+ const playIcon = `tier3:${playing ? 'pause' : 'play'}`;
1045
+ const playTooltip = `${playing ? this.localize('components:mediaPlayer:pause') : this.localize('components:mediaPlayer:play')} (${KEY_BINDINGS.play})`;
1044
1046
 
1045
1047
  switch (this.mediaType) {
1046
1048
  case SOURCE_TYPES.video:
@@ -1417,12 +1419,13 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerTranscriptMixin(MediaPl
1417
1419
  }
1418
1420
 
1419
1421
  _onPause() {
1420
- if (!this._audioDescriptionPausedVideo) this._cancelAudioDescription();
1422
+ if (!this._audioDescriptionPausedVideo) this._pauseAudioDescription();
1421
1423
  this._playing = false;
1422
1424
  this.dispatchEvent(new CustomEvent('pause'));
1423
1425
  }
1424
1426
 
1425
1427
  _onPlay() {
1428
+ this._resumeAudioDescription();
1426
1429
  this.dispatchEvent(new CustomEvent('play'));
1427
1430
  }
1428
1431
 
@@ -1932,6 +1935,10 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerTranscriptMixin(MediaPl
1932
1935
 
1933
1936
  _togglePlay() {
1934
1937
  this._posterVisible = false;
1938
+ if (this._audioDescriptionPausedVideo) {
1939
+ this._toggleAudioDescriptionPause();
1940
+ return;
1941
+ }
1935
1942
  if (this._media.paused) {
1936
1943
  if (this.playInView) {
1937
1944
  this._loadVisibilityObserver({ target: this._mediaContainer });