@brightspace-ui/labs 2.63.5 → 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 +1 -1
- package/src/components/media-player/README.md +6 -0
- package/src/components/media-player/media-player-audio-descriptions.js +30 -2
- package/src/components/media-player/media-player-chapters.js +158 -0
- package/src/components/media-player/media-player-transcript.js +266 -0
- package/src/components/media-player/media-player.js +19 -350
- package/src/lang/ar.js +2 -0
- package/src/lang/ca.js +2 -0
- package/src/lang/cy.js +2 -0
- package/src/lang/da.js +2 -0
- package/src/lang/de.js +2 -0
- package/src/lang/en-gb.js +2 -0
- package/src/lang/en.js +2 -0
- package/src/lang/es-es.js +2 -0
- package/src/lang/es.js +2 -0
- package/src/lang/fr-fr.js +2 -0
- package/src/lang/fr-on.js +2 -0
- package/src/lang/fr.js +2 -0
- package/src/lang/haw.js +2 -0
- package/src/lang/hi.js +2 -0
- package/src/lang/ja.js +2 -0
- package/src/lang/ko.js +2 -0
- package/src/lang/mi.js +2 -0
- package/src/lang/nl.js +2 -0
- package/src/lang/pl.js +2 -0
- package/src/lang/pt.js +2 -0
- package/src/lang/ru.js +2 -0
- package/src/lang/sv.js +2 -0
- package/src/lang/th.js +2 -0
- package/src/lang/tr.js +2 -0
- package/src/lang/ur.js +2 -0
- package/src/lang/vi.js +2 -0
- package/src/lang/zh-cn.js +2 -0
- package/src/lang/zh-tw.js +2 -0
|
@@ -2,7 +2,6 @@ import '@brightspace-ui/core/components/button/button-icon.js';
|
|
|
2
2
|
import '@brightspace-ui/core/components/colors/colors.js';
|
|
3
3
|
import '@brightspace-ui/core/components/dropdown/dropdown.js';
|
|
4
4
|
import '@brightspace-ui/core/components/dropdown/dropdown-menu.js';
|
|
5
|
-
import '@brightspace-ui/core/components/dropdown/dropdown-button-subtle.js';
|
|
6
5
|
import '@brightspace-ui/core/components/icons/icon.js';
|
|
7
6
|
import '@brightspace-ui/core/components/loading-spinner/loading-spinner.js';
|
|
8
7
|
import '@brightspace-ui/core/components/menu/menu.js';
|
|
@@ -21,7 +20,9 @@ import { getFocusPseudoClass } from '@brightspace-ui/core/helpers/focus.js';
|
|
|
21
20
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
22
21
|
import { labelStyles } from '@brightspace-ui/core/components/typography/styles.js';
|
|
23
22
|
import { LocalizeLabsElement } from '../localize-labs-element.js';
|
|
23
|
+
import { MediaPlayerChaptersMixin } from './media-player-chapters.js';
|
|
24
24
|
import { MediaPlayerThumbnailsMixin } from './media-player-thumbnails.js';
|
|
25
|
+
import { MediaPlayerTranscriptMixin } from './media-player-transcript.js';
|
|
25
26
|
import parseSRT from 'parse-srt/src/parse-srt.js';
|
|
26
27
|
import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
|
|
27
28
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
@@ -75,7 +76,7 @@ const tryParseUrlExpiry = url => {
|
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPlayerAudioDescriptionsMixin(RtlMixin(LitElement)))) {
|
|
79
|
+
class MediaPlayer extends LocalizeLabsElement(MediaPlayerTranscriptMixin(MediaPlayerThumbnailsMixin(MediaPlayerChaptersMixin(MediaPlayerAudioDescriptionsMixin(RtlMixin(LitElement)))))) {
|
|
79
80
|
|
|
80
81
|
static properties = {
|
|
81
82
|
allowDownload: { type: Boolean, attribute: 'allow-download', reflect: true },
|
|
@@ -88,13 +89,10 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
88
89
|
hideSeekBar: { type: Boolean, attribute: 'hide-seek-bar' },
|
|
89
90
|
loop: { type: Boolean },
|
|
90
91
|
mediaType: { type: String, attribute: 'media-type' },
|
|
91
|
-
metadata: { type: Object },
|
|
92
92
|
poster: { type: String },
|
|
93
93
|
src: { type: String },
|
|
94
94
|
disableSetPreferences: { type: Boolean, attribute: 'disable-set-preferences' },
|
|
95
|
-
transcriptViewerOn: { type: Boolean, attribute: 'transcript-viewer-on' },
|
|
96
95
|
playInView: { type: Boolean, attribute: 'play-in-view' },
|
|
97
|
-
_chapters: { state: true },
|
|
98
96
|
_currentTime: { state: true },
|
|
99
97
|
_duration: { state: true },
|
|
100
98
|
_heightPixels: { state: true },
|
|
@@ -399,28 +397,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
399
397
|
width: 2.75rem;
|
|
400
398
|
}
|
|
401
399
|
|
|
402
|
-
.chapter-marker, .chapter-marker-highlight {
|
|
403
|
-
cursor: pointer;
|
|
404
|
-
height: 6px;
|
|
405
|
-
pointer-events: none;
|
|
406
|
-
position: absolute;
|
|
407
|
-
top: 4px;
|
|
408
|
-
width: 3px;
|
|
409
|
-
z-index: 2;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
.chapter-marker {
|
|
413
|
-
background-color: var(--d2l-color-ferrite);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
.chapter-marker-highlight {
|
|
417
|
-
background-color: var(--d2l-color-celestine-minus-1);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
.chapter-marker[theme="dark"] {
|
|
421
|
-
background-color: white;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
400
|
#search-container {
|
|
425
401
|
align-items: center;
|
|
426
402
|
display: flex;
|
|
@@ -512,73 +488,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
512
488
|
font-size: 1rem;
|
|
513
489
|
line-height: 2.1rem;
|
|
514
490
|
}
|
|
515
|
-
|
|
516
|
-
.transcript-cue-container {
|
|
517
|
-
padding-left: 10px;
|
|
518
|
-
}
|
|
519
|
-
.video-transcript-cue {
|
|
520
|
-
padding-left: 5px;
|
|
521
|
-
}
|
|
522
|
-
.audio-transcript-cue {
|
|
523
|
-
padding-left: 5px;
|
|
524
|
-
}
|
|
525
|
-
.video-transcript-cue[active] {
|
|
526
|
-
background-color: gray;
|
|
527
|
-
box-shadow: -5px 0 0 white;
|
|
528
|
-
}
|
|
529
|
-
.audio-transcript-cue[active] {
|
|
530
|
-
background-color: lightgray;
|
|
531
|
-
box-shadow: -5px 0 0 black;
|
|
532
|
-
}
|
|
533
|
-
#video-transcript-viewer {
|
|
534
|
-
bottom: 55px;
|
|
535
|
-
color: white;
|
|
536
|
-
overflow-anchor: none;
|
|
537
|
-
overflow-y: auto;
|
|
538
|
-
position: absolute;
|
|
539
|
-
right: 0;
|
|
540
|
-
top: 50px;
|
|
541
|
-
width: 65%;
|
|
542
|
-
z-index: 1;
|
|
543
|
-
}
|
|
544
|
-
#audio-transcript-viewer {
|
|
545
|
-
bottom: 60px;
|
|
546
|
-
color: black;
|
|
547
|
-
overflow-anchor: none;
|
|
548
|
-
overflow-y: auto;
|
|
549
|
-
position: absolute;
|
|
550
|
-
right: 0;
|
|
551
|
-
top: 45px;
|
|
552
|
-
width: 100%;
|
|
553
|
-
z-index: 1;
|
|
554
|
-
}
|
|
555
|
-
#close-transcript {
|
|
556
|
-
position: absolute;
|
|
557
|
-
right: 7px;
|
|
558
|
-
top: 0;
|
|
559
|
-
z-index: 1;
|
|
560
|
-
}
|
|
561
|
-
#video-transcript-download-button {
|
|
562
|
-
left: 35%;
|
|
563
|
-
position: absolute;
|
|
564
|
-
top: 5px;
|
|
565
|
-
z-index: 2;
|
|
566
|
-
}
|
|
567
|
-
#audio-transcript-download-button {
|
|
568
|
-
left: 10px;
|
|
569
|
-
position: absolute;
|
|
570
|
-
top: 0;
|
|
571
|
-
z-index: 2;
|
|
572
|
-
}
|
|
573
|
-
#audio-transcript-download-menu {
|
|
574
|
-
left: 35px;
|
|
575
|
-
}
|
|
576
|
-
#video-close-transcript-icon {
|
|
577
|
-
color: white;
|
|
578
|
-
}
|
|
579
|
-
#audio-close-transcript-icon {
|
|
580
|
-
color: black;
|
|
581
|
-
}
|
|
582
491
|
`];
|
|
583
492
|
|
|
584
493
|
constructor() {
|
|
@@ -589,7 +498,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
589
498
|
this.loop = false;
|
|
590
499
|
this.playInView = false;
|
|
591
500
|
|
|
592
|
-
this._chapters = [];
|
|
593
501
|
this._currentTime = 0;
|
|
594
502
|
this._determiningSourceType = true;
|
|
595
503
|
this._duration = this.durationHint || 1;
|
|
@@ -623,8 +531,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
623
531
|
this._playRequested = false;
|
|
624
532
|
this._mediaContainerAspectRatio = {
|
|
625
533
|
};
|
|
626
|
-
this.afterCaptions = [];
|
|
627
|
-
this.beforeCaptions = [];
|
|
628
534
|
this._iosVideoFullscreen = false;
|
|
629
535
|
}
|
|
630
536
|
|
|
@@ -722,8 +628,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
722
628
|
this._searchInput = this.shadowRoot.getElementById('search-input');
|
|
723
629
|
this._searchContainer = this.shadowRoot.getElementById('search-container');
|
|
724
630
|
|
|
725
|
-
this._getMetadata();
|
|
726
|
-
|
|
727
631
|
this._startUpdatingCurrentTime();
|
|
728
632
|
new ResizeObserver((entries) => {
|
|
729
633
|
for (const entry of entries) {
|
|
@@ -755,11 +659,12 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
755
659
|
|
|
756
660
|
render() {
|
|
757
661
|
const fullscreenIcon = fullscreenApi.isFullscreen ? 'tier1:smallscreen' : 'tier1:fullscreen';
|
|
758
|
-
const
|
|
662
|
+
const playing = this._playing || this._audioDescriptionHoldingPlayback;
|
|
663
|
+
const playIcon = playing ? 'tier1:pause' : 'tier1:play';
|
|
759
664
|
const volumeIcon = this._muted ? 'tier1:volume-muted' : 'tier1:volume';
|
|
760
665
|
|
|
761
666
|
const fullscreenTooltip = `${fullscreenApi.isFullscreen ? this.localize('components:mediaPlayer:exitFullscreen') : this.localize('components:mediaPlayer:fullscreen')} (${KEY_BINDINGS.fullscreen})`;
|
|
762
|
-
const playTooltip = `${
|
|
667
|
+
const playTooltip = `${playing ? this.localize('components:mediaPlayer:pause') : this.localize('components:mediaPlayer:play')} (${KEY_BINDINGS.play})`;
|
|
763
668
|
const volumeTooltip = `${this._muted ? this.localize('components:mediaPlayer:unmute') : this.localize('components:mediaPlayer:mute')} (${KEY_BINDINGS.mute})`;
|
|
764
669
|
|
|
765
670
|
const height = this._maintainHeight ? `${this._maintainHeight}px` : (this._heightPixels ? `${this._heightPixels}px` : '100%');
|
|
@@ -918,6 +823,7 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
918
823
|
</d2l-menu-item>
|
|
919
824
|
${this._getTracksMenuView()}
|
|
920
825
|
${this._getQualityMenuView()}
|
|
826
|
+
${this._renderTranscriptViewerMenuItem()}
|
|
921
827
|
${(this.allowDownload && this._getCurrentSource()) ? this._getDownloadButtonView() : ''}
|
|
922
828
|
<slot name="settings-menu-item"></slot>
|
|
923
829
|
</d2l-menu>
|
|
@@ -938,10 +844,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
938
844
|
if (changedProperties.has('src') || changedProperties.has('mediaType')) {
|
|
939
845
|
this._reloadSource();
|
|
940
846
|
}
|
|
941
|
-
|
|
942
|
-
if (changedProperties.has('metadata')) {
|
|
943
|
-
this._getMetadata();
|
|
944
|
-
}
|
|
945
847
|
}
|
|
946
848
|
|
|
947
849
|
exitFullscreen() {
|
|
@@ -963,13 +865,13 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
963
865
|
}
|
|
964
866
|
|
|
965
867
|
pause() {
|
|
966
|
-
if (this._media && !this._media.paused) {
|
|
868
|
+
if (this._media && (!this._media.paused || this._audioDescriptionHoldingPlayback)) {
|
|
967
869
|
this._togglePlay();
|
|
968
870
|
}
|
|
969
871
|
}
|
|
970
872
|
|
|
971
873
|
play() {
|
|
972
|
-
if (this._media && this._media.paused) {
|
|
874
|
+
if (this._media && this._media.paused && !this._audioDescriptionHoldingPlayback) {
|
|
973
875
|
this._togglePlay();
|
|
974
876
|
}
|
|
975
877
|
}
|
|
@@ -1048,10 +950,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1048
950
|
localStorage.removeItem(preferenceKey);
|
|
1049
951
|
}
|
|
1050
952
|
|
|
1051
|
-
_closeTranscript() {
|
|
1052
|
-
this.dispatchEvent(new CustomEvent('close-transcript', { bubbles: true, composed: true }));
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
953
|
_disableNativeCaptions() {
|
|
1056
954
|
if (!this._media) return;
|
|
1057
955
|
for (let i = 0; i < this._media.textTracks.length; i++) {
|
|
@@ -1065,14 +963,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1065
963
|
}
|
|
1066
964
|
}
|
|
1067
965
|
|
|
1068
|
-
_downloadCaptions() {
|
|
1069
|
-
this.dispatchEvent(new CustomEvent('download-captions', { bubbles: true, composed: true }));
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
_downloadTranscript() {
|
|
1073
|
-
this.dispatchEvent(new CustomEvent('download-transcript', { bubbles: true, composed: true }));
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
966
|
_endIOSVideoFullscreen() {
|
|
1077
967
|
this._iosVideoFullscreen = false;
|
|
1078
968
|
}
|
|
@@ -1112,57 +1002,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1112
1002
|
return a.href;
|
|
1113
1003
|
}
|
|
1114
1004
|
|
|
1115
|
-
_getChapterMarkersView() {
|
|
1116
|
-
if (this._chapters.length === 0) return;
|
|
1117
|
-
|
|
1118
|
-
let start, end;
|
|
1119
|
-
if (this._chapters[this._chapters.length - 1].time === Math.floor(this._duration)) this._chapters.pop();
|
|
1120
|
-
|
|
1121
|
-
for (let i = 0; i < this._chapters.length; i++) {
|
|
1122
|
-
if (i === this._chapters.length - 1) {
|
|
1123
|
-
start = this._chapters[i].time;
|
|
1124
|
-
break;
|
|
1125
|
-
}
|
|
1126
|
-
else if (this._hoverTime >= this._chapters[i].time && this._hoverTime < this._chapters[i + 1].time) {
|
|
1127
|
-
start = this._chapters[i].time;
|
|
1128
|
-
end = this._chapters[i + 1].time;
|
|
1129
|
-
break;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
return this._chapters.map(chapter => {
|
|
1134
|
-
const highlight = this._hovering && this._hoverTime >= this._chapters[0].time && (chapter.time === start || chapter.time === end);
|
|
1135
|
-
return chapter.time > 0 ? html`
|
|
1136
|
-
<div
|
|
1137
|
-
class=${highlight ? 'chapter-marker-highlight' : 'chapter-marker'}
|
|
1138
|
-
theme="${ifDefined(this._getTheme())}"
|
|
1139
|
-
style=${styleMap({ left: `${this._getPercentageTime(chapter.time)}%` })}
|
|
1140
|
-
></div>
|
|
1141
|
-
` : nothing;
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
_getChapterTitle() {
|
|
1146
|
-
if (!(this._chapters.length > 0 && this._hoverTime >= this._chapters[0].time)) return;
|
|
1147
|
-
|
|
1148
|
-
const chapter = this._chapters.find((_chapter, index, chapters) => (
|
|
1149
|
-
index === chapters.length - 1 || (this._hoverTime >= chapters[0].time && this._hoverTime < chapters[index + 1].time)
|
|
1150
|
-
));
|
|
1151
|
-
const chapterTitle = chapter && chapter.title;
|
|
1152
|
-
|
|
1153
|
-
if (!chapterTitle) return;
|
|
1154
|
-
|
|
1155
|
-
if (typeof chapterTitle === 'string') {
|
|
1156
|
-
return chapterTitle;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
for (const locale in chapterTitle) {
|
|
1160
|
-
if (locale.split('-')[0] === 'en') {
|
|
1161
|
-
return chapterTitle[locale];
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
1005
|
_getCurrentSource() {
|
|
1167
1006
|
return this.src || this._sources[this._selectedQuality];
|
|
1168
1007
|
}
|
|
@@ -1201,8 +1040,9 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1201
1040
|
}
|
|
1202
1041
|
|
|
1203
1042
|
_getMediaAreaView() {
|
|
1204
|
-
const
|
|
1205
|
-
const
|
|
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})`;
|
|
1206
1046
|
|
|
1207
1047
|
switch (this.mediaType) {
|
|
1208
1048
|
case SOURCE_TYPES.video:
|
|
@@ -1273,61 +1113,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1273
1113
|
}
|
|
1274
1114
|
}
|
|
1275
1115
|
|
|
1276
|
-
_getMetadata() {
|
|
1277
|
-
if (!this.metadata) return;
|
|
1278
|
-
|
|
1279
|
-
const data = (typeof this.metadata === 'string' || this.metadata instanceof String) ? JSON.parse(this.metadata) : this.metadata;
|
|
1280
|
-
if (!(data && data.chapters && data.chapters.length > 0)) return;
|
|
1281
|
-
let chapters = data.chapters.map(({ time, title }) => {
|
|
1282
|
-
return {
|
|
1283
|
-
time: parseInt(time),
|
|
1284
|
-
title
|
|
1285
|
-
};
|
|
1286
|
-
}).sort((a, b) => a.time - b.time);
|
|
1287
|
-
|
|
1288
|
-
if (!data.cuts) {
|
|
1289
|
-
data.cuts = [];
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
// updating the chapter times based on the cuts, loops over all chapters per cut because it can change multiple chapters
|
|
1293
|
-
let cutDiff = 0;
|
|
1294
|
-
for (const cut of data.cuts) {
|
|
1295
|
-
const cutIn = cut.in - cutDiff;
|
|
1296
|
-
|
|
1297
|
-
const newChapters = new Map(); // using map to preserve sort ordering
|
|
1298
|
-
|
|
1299
|
-
if (!cut.out) { // if cut is until the end of the video
|
|
1300
|
-
for (const chapter of chapters) {
|
|
1301
|
-
if (chapter.time < cutIn) {
|
|
1302
|
-
newChapters.set(chapter.time, chapter.title);
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1305
|
-
} else {
|
|
1306
|
-
const cutOut = cut.out - cutDiff;
|
|
1307
|
-
const cutLength = cutOut - cutIn;
|
|
1308
|
-
|
|
1309
|
-
for (const chapter of chapters) {
|
|
1310
|
-
let newTime = chapter.time;
|
|
1311
|
-
if (chapter.time > cutIn && chapter.time <= cutOut) {
|
|
1312
|
-
newTime = cutIn;
|
|
1313
|
-
} else if (chapter.time > cutOut) {
|
|
1314
|
-
newTime = chapter.time - cutLength;
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
newChapters.set(newTime, chapter.title);
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
cutDiff += cutLength;
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
chapters = [...newChapters].map(([chapterTime, chapterTitle]) => ({
|
|
1324
|
-
time: chapterTime,
|
|
1325
|
-
title: chapterTitle
|
|
1326
|
-
}));
|
|
1327
|
-
}
|
|
1328
|
-
this._chapters = chapters;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
1116
|
_getPercentageTime(time) {
|
|
1332
1117
|
if (this._media) return (time / this.duration) * 100;
|
|
1333
1118
|
}
|
|
@@ -1502,13 +1287,7 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1502
1287
|
|
|
1503
1288
|
async _onCueChange() {
|
|
1504
1289
|
if (this.transcriptViewerOn) {
|
|
1505
|
-
|
|
1506
|
-
this._transcriptViewer = this.shadowRoot.getElementById('video-transcript-viewer')
|
|
1507
|
-
|| this.shadowRoot.getElementById('audio-transcript-viewer');
|
|
1508
|
-
}
|
|
1509
|
-
this._updateTranscriptViewerCues();
|
|
1510
|
-
await this.requestUpdate();
|
|
1511
|
-
this._scrollTranscriptViewer();
|
|
1290
|
+
await this._onTranscriptCueChange();
|
|
1512
1291
|
}
|
|
1513
1292
|
for (let i = 0; i < this._media.textTracks.length; i++) {
|
|
1514
1293
|
if (this._media.textTracks[i].mode === 'hidden') {
|
|
@@ -1640,12 +1419,13 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
1640
1419
|
}
|
|
1641
1420
|
|
|
1642
1421
|
_onPause() {
|
|
1643
|
-
if (!this._audioDescriptionPausedVideo) this.
|
|
1422
|
+
if (!this._audioDescriptionPausedVideo) this._pauseAudioDescription();
|
|
1644
1423
|
this._playing = false;
|
|
1645
1424
|
this.dispatchEvent(new CustomEvent('pause'));
|
|
1646
1425
|
}
|
|
1647
1426
|
|
|
1648
1427
|
_onPlay() {
|
|
1428
|
+
this._resumeAudioDescription();
|
|
1649
1429
|
this.dispatchEvent(new CustomEvent('play'));
|
|
1650
1430
|
}
|
|
1651
1431
|
|
|
@@ -2052,82 +1832,10 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
2052
1832
|
}
|
|
2053
1833
|
}
|
|
2054
1834
|
|
|
2055
|
-
_renderTranscriptViewer() {
|
|
2056
|
-
if (!this._media) {
|
|
2057
|
-
return;
|
|
2058
|
-
}
|
|
2059
|
-
const captionsMenu = this.shadowRoot.getElementById('captions-menu');
|
|
2060
|
-
if (captionsMenu) {
|
|
2061
|
-
this._captionsMenuReturnItem = captionsMenu.shadowRoot.querySelector('d2l-menu-item-return');
|
|
2062
|
-
this._captionsMenuReturnItem?.setAttribute('text', this.localize('components:mediaPlayer:language'));
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
if (!this._transcriptViewer) {
|
|
2066
|
-
this._onCueChange();
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
const isVideo = this.mediaType === SOURCE_TYPES.video;
|
|
2070
|
-
const captionsToHtml = (item) => {
|
|
2071
|
-
const updateTime = async() => {
|
|
2072
|
-
this.currentTime = item.startTime;
|
|
2073
|
-
this._media.currentTime = item.startTime;
|
|
2074
|
-
};
|
|
2075
|
-
return html`
|
|
2076
|
-
<div class=${isVideo ? 'video-transcript-cue' : 'audio-transcript-cue'}
|
|
2077
|
-
@click=${updateTime}>
|
|
2078
|
-
${item.text}<br>
|
|
2079
|
-
</div>`;
|
|
2080
|
-
};
|
|
2081
|
-
|
|
2082
|
-
return html`
|
|
2083
|
-
<span id="close-transcript"
|
|
2084
|
-
@click=${this._closeTranscript}>
|
|
2085
|
-
<d2l-icon class="d2l-button-icon"
|
|
2086
|
-
id=${isVideo ? 'video-close-transcript-icon' : 'audio-close-transcript-icon'}
|
|
2087
|
-
icon="tier1:close-small"></d2l-icon>
|
|
2088
|
-
</span>
|
|
2089
|
-
<div
|
|
2090
|
-
id=${isVideo ? 'video-transcript-viewer' : 'audio-transcript-viewer'}
|
|
2091
|
-
>
|
|
2092
|
-
<div class="transcript-cue-container">
|
|
2093
|
-
${this.beforeCaptions.map(captionsToHtml)}
|
|
2094
|
-
<div class=${isVideo ? 'video-transcript-cue' : 'audio-transcript-cue'} active
|
|
2095
|
-
id="transcript-viewer-active-cue">
|
|
2096
|
-
${this.transcriptActiveCue?.text}
|
|
2097
|
-
</div>
|
|
2098
|
-
${this.afterCaptions.map(captionsToHtml)}
|
|
2099
|
-
</div>
|
|
2100
|
-
</div>
|
|
2101
|
-
<d2l-dropdown-button-subtle
|
|
2102
|
-
id=${isVideo ? 'video-transcript-download-button' : 'audio-transcript-download-button'}
|
|
2103
|
-
text="${this.localize('components:mediaPlayer:download')}">
|
|
2104
|
-
<d2l-dropdown-menu id=${isVideo ? 'video-transcript-download-menu' : 'audio-transcript-download-menu'}>
|
|
2105
|
-
<d2l-menu>
|
|
2106
|
-
<d2l-menu-item @click=${this._downloadTranscript} text="${this.localize('components:mediaPlayer:transcriptTxt')}"></d2l-menu-item>
|
|
2107
|
-
<d2l-menu-item @click=${this._downloadCaptions} text="${this.localize('components:mediaPlayer:captionsVtt')}"></d2l-menu-item>
|
|
2108
|
-
</d2l-menu>
|
|
2109
|
-
</d2l-dropdown-menu>
|
|
2110
|
-
</d2l-dropdown-button-subtle>
|
|
2111
|
-
`;
|
|
2112
|
-
}
|
|
2113
|
-
|
|
2114
1835
|
_sanitizeText(text) {
|
|
2115
1836
|
return text.replace(/<br \/>/g, '\n');
|
|
2116
1837
|
}
|
|
2117
1838
|
|
|
2118
|
-
_scrollTranscriptViewer() {
|
|
2119
|
-
const cue = this.shadowRoot.getElementById('transcript-viewer-active-cue');
|
|
2120
|
-
const cueRect = cue?.getBoundingClientRect();
|
|
2121
|
-
const transcriptRect = this._transcriptViewer?.getBoundingClientRect();
|
|
2122
|
-
if (cue && cueRect && transcriptRect) {
|
|
2123
|
-
if (cueRect.bottom > transcriptRect.bottom && cueRect.height <= transcriptRect.height) {
|
|
2124
|
-
this._transcriptViewer.scrollBy({ top: cueRect.bottom - transcriptRect.bottom + transcriptRect.height - cueRect.height, left: 0, behavior: 'smooth' });
|
|
2125
|
-
} else if (cueRect.top < transcriptRect.top) {
|
|
2126
|
-
this._transcriptViewer.scrollBy({ top: cueRect.top - transcriptRect.top, left: 0, behavior: 'smooth' });
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
|
|
2131
1839
|
_setPreference(preferenceKey, value) {
|
|
2132
1840
|
if (!this.disableSetPreferences) {
|
|
2133
1841
|
localStorage.setItem(preferenceKey, value);
|
|
@@ -2227,6 +1935,10 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
2227
1935
|
|
|
2228
1936
|
_togglePlay() {
|
|
2229
1937
|
this._posterVisible = false;
|
|
1938
|
+
if (this._audioDescriptionPausedVideo) {
|
|
1939
|
+
this._toggleAudioDescriptionPause();
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
2230
1942
|
if (this._media.paused) {
|
|
2231
1943
|
if (this.playInView) {
|
|
2232
1944
|
this._loadVisibilityObserver({ target: this._mediaContainer });
|
|
@@ -2255,49 +1967,6 @@ class MediaPlayer extends LocalizeLabsElement(MediaPlayerThumbnailsMixin(MediaPl
|
|
|
2255
1967
|
});
|
|
2256
1968
|
}
|
|
2257
1969
|
|
|
2258
|
-
_updateTranscriptViewerCues() {
|
|
2259
|
-
let cues = null;
|
|
2260
|
-
const lang = this._getSrclangFromTrackIdentifier(this._selectedTrackIdentifier);
|
|
2261
|
-
for (let i = 0; i < this._media.textTracks.length; i += 1) {
|
|
2262
|
-
const currTrack = this._media.textTracks[i];
|
|
2263
|
-
if (currTrack?.cues) {
|
|
2264
|
-
const activeCues = currTrack.activeCues;
|
|
2265
|
-
if (lang === currTrack.language) {
|
|
2266
|
-
this.transcriptActiveCue = activeCues?.[activeCues?.length - 1];
|
|
2267
|
-
cues = currTrack.cues;
|
|
2268
|
-
break;
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
if (!cues) {
|
|
2273
|
-
let defaultTrack;
|
|
2274
|
-
for (let i = 0; i < this._media.textTracks.length; i++) {
|
|
2275
|
-
if (this._media.textTracks[i].default) {
|
|
2276
|
-
defaultTrack = this._media.textTracks[i];
|
|
2277
|
-
break;
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
defaultTrack = defaultTrack || this._media.textTracks[0];
|
|
2281
|
-
if (defaultTrack) defaultTrack.mode = 'hidden';
|
|
2282
|
-
this._selectedTrackIdentifier = { kind: defaultTrack?.kind, srclang: defaultTrack?.language };
|
|
2283
|
-
this.requestUpdate();
|
|
2284
|
-
return;
|
|
2285
|
-
}
|
|
2286
|
-
|
|
2287
|
-
this.beforeCaptions = [];
|
|
2288
|
-
this.afterCaptions = [];
|
|
2289
|
-
for (let i = 0; i < cues.length; i += 1) {
|
|
2290
|
-
const currCue = cues[i];
|
|
2291
|
-
const currTime = this._media?.currentTime;
|
|
2292
|
-
const before = currCue !== this.transcriptActiveCue && (currCue.endTime < currTime || currCue.endTime <= this.transcriptActiveCue?.endTime);
|
|
2293
|
-
if (before) {
|
|
2294
|
-
this.beforeCaptions.push(currCue);
|
|
2295
|
-
} else if (currCue !== this.transcriptActiveCue) {
|
|
2296
|
-
this.afterCaptions.push(currCue);
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
1970
|
#getOpenDropdowns() {
|
|
2302
1971
|
return [...(this.shadowRoot?.querySelectorAll('d2l-dropdown-menu[opened], d2l-dropdown-content[opened]') ?? [])];
|
|
2303
1972
|
}
|
package/src/lang/ar.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "تنزيل",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "الخروج من وضع ملء الشاشة",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "ملء الشاشة",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "اللغة",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "عذرًا، حدثت مشكلة أثناء تحميل ملف الوسائط هذا",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "تم تحميل الوسائط بنجاح",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "النص (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "لا يمكن التنزيل. يُرجى تحديث الصفحة والمحاولة مرة أخرى.",
|
|
67
68
|
"components:mediaPlayer:unmute": "إلغاء كتم الصوت",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "شريط تمرير مستوى الصوت",
|
|
69
71
|
"components:navigation:back": "العودة",
|
|
70
72
|
"components:navigation:next": "التالي",
|
package/src/lang/ca.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Descarrega",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Sortir de pantalla completa",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Pantalla completa",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Idioma",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Vaja! Hi ha hagut un problema en carregar aquest fitxer multimèdia.",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "L’element multimèdia s’ha carregat correctament",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Transcripció (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "No s’ha pogut descarregar. Actualitzeu la pàgina i torneu-ho a provar.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Activar el so",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "control lliscant de volum",
|
|
69
71
|
"components:navigation:back": "Enrere",
|
|
70
72
|
"components:navigation:next": "Següent",
|
package/src/lang/cy.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Lawrlwytho",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Gadael sgrîn lawn",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Sgrin Lawn",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Iaith",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Wps, roedd problem wrth lwytho’r ffeil gyfryngau hon",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "Mae’r cyfryngau wedi llwytho’n llwyddiannus",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Trawsgrifiad (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "Methu lawrlwytho. Adnewyddwch y dudalen neu rhowch gynnig arall arni.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Dad-dewi",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "llithrydd sain",
|
|
69
71
|
"components:navigation:back": "Yn ôl",
|
|
70
72
|
"components:navigation:next": "Nesaf",
|
package/src/lang/da.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Download",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Afslut fuld skærm",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Fuld skærm",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Sprog",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Hovsa, der opstod et problem med at indlæse denne mediefil",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "Mediet er indlæst",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Afskrift (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "Kan ikke downloade. Opdater siden, og prøv igen.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Slå lyd til",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "lydstyrkeskyder",
|
|
69
71
|
"components:navigation:back": "Tilbage",
|
|
70
72
|
"components:navigation:next": "Næste",
|
package/src/lang/de.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Herunterladen",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Vollbildmodus beenden",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Vollbildmodus",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Sprache",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Hoppla, beim Laden dieser Mediendatei ist ein Problem aufgetreten",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "Diese Medien wurden erfolgreich geladen",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Transkript (txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "Herunterladen nicht möglich. Aktualisieren Sie die Seite und versuchen Sie es erneut.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Stummschaltung aufheben",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "Lautstärkeregler",
|
|
69
71
|
"components:navigation:back": "Zurück",
|
|
70
72
|
"components:navigation:next": "Weiter",
|
package/src/lang/en-gb.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Download",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Exit fullscreen",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Fullscreen",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Language",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Oops, there was a problem loading this media file",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "The media has loaded successfully",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Transcript (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "Unable to download. Please refresh the page and try again.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Unmute",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "volume slider",
|
|
69
71
|
"components:navigation:back": "Back",
|
|
70
72
|
"components:navigation:next": "Next",
|
package/src/lang/en.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Download",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Exit fullscreen",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Fullscreen",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Language",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Oops, there was a problem loading this media file",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "The media has loaded successfully",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Transcript (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "Unable to download. Please refresh the page and try again.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Unmute",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "volume slider",
|
|
69
71
|
"components:navigation:back": "Back",
|
|
70
72
|
"components:navigation:next": "Next",
|
package/src/lang/es-es.js
CHANGED
|
@@ -41,6 +41,7 @@ export default {
|
|
|
41
41
|
"components:mediaPlayer:download": "Descargar",
|
|
42
42
|
"components:mediaPlayer:exitFullscreen": "Salir de la pantalla completa",
|
|
43
43
|
"components:mediaPlayer:fullscreen": "Pantalla completa",
|
|
44
|
+
"components:mediaPlayer:hideTranscript": "Hide transcript",
|
|
44
45
|
"components:mediaPlayer:language": "Idioma",
|
|
45
46
|
"components:mediaPlayer:loadErrorMessage": "Lo sentimos. Ha surgido un problema al cargar este archivo multimedia",
|
|
46
47
|
"components:mediaPlayer:loadSuccessMessage": "El archivo multimedia se ha cargado correctamente",
|
|
@@ -65,6 +66,7 @@ export default {
|
|
|
65
66
|
"components:mediaPlayer:transcriptTxt": "Transcripción (.txt)",
|
|
66
67
|
"components:mediaPlayer:unableToDownload": "Se ha producido un error al descargar. Actualice la página e inténtelo de nuevo.",
|
|
67
68
|
"components:mediaPlayer:unmute": "Activar sonido",
|
|
69
|
+
"components:mediaPlayer:viewTranscript": "View transcript",
|
|
68
70
|
"components:mediaPlayer:volumeSlider": "control deslizante del volumen",
|
|
69
71
|
"components:navigation:back": "Volver",
|
|
70
72
|
"components:navigation:next": "Siguiente",
|