@kkcompany/player 2.25.0-canary.17 → 2.25.0-canary.19

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/dist/core.mjs CHANGED
@@ -37,7 +37,7 @@ const waitFor = (check, handler) => {
37
37
  function getVersion() {
38
38
  try {
39
39
  // eslint-disable-next-line no-undef
40
- return "2.25.0-canary.17";
40
+ return "2.25.0-canary.19";
41
41
  } catch (e) {
42
42
  return undefined;
43
43
  }
@@ -130,7 +130,7 @@ const makeResponse = (headers, data, status, uri, responseURL, requestType) => {
130
130
  throw new shaka$1.util.Error(severity, shaka$1.util.Error.Category.NETWORK, shaka$1.util.Error.Code.BAD_HTTP_STATUS, uri, status, responseText, headers, requestType);
131
131
  };
132
132
 
133
- const goog$1 = {
133
+ const goog$2 = {
134
134
  asserts: {
135
135
  assert: () => {}
136
136
  }
@@ -276,7 +276,7 @@ class HttpFetchPlugin {
276
276
  }
277
277
 
278
278
  if (readObj.done) {
279
- goog$1.asserts.assert(!readObj.value, 'readObj should be unset when "done" is true.');
279
+ goog$2.asserts.assert(!readObj.value, 'readObj should be unset when "done" is true.');
280
280
  controller.close();
281
281
  } else {
282
282
  controller.enqueue(readObj.value);
@@ -515,6 +515,664 @@ const fixDashManifest = (data, {
515
515
  return new XMLSerializer().serializeToString(doc);
516
516
  };
517
517
 
518
+ /* eslint-disable no-cond-assign */
519
+
520
+ /* eslint-disable prefer-destructuring */
521
+
522
+ /*! @license
523
+ * Shaka Player
524
+ * Copyright 2016 Google LLC
525
+ * SPDX-License-Identifier: Apache-2.0
526
+ */
527
+ const goog$1 = {
528
+ asserts: {
529
+ assert: (condition, message) => {
530
+ if (!condition) {
531
+ console.warn('GOOG Assert!', message);
532
+ }
533
+ }
534
+ }
535
+ };
536
+
537
+ const addDefaultTextColor = styles => {
538
+ const textColor = shaka.text.Cue.defaultTextColor;
539
+
540
+ for (const [key, value] of Object.entries(textColor)) {
541
+ const cue = new shaka.text.Cue(0, 0, '');
542
+ cue.color = value;
543
+ styles.set(`.${key}`, cue);
544
+ }
545
+
546
+ const bgColor = shaka.text.Cue.defaultTextBackgroundColor;
547
+
548
+ for (const [key, value] of Object.entries(bgColor)) {
549
+ const cue = new shaka.text.Cue(0, 0, '');
550
+ cue.backgroundColor = value;
551
+ styles.set(`.${key}`, cue);
552
+ }
553
+ };
554
+
555
+ const parseTime = text => {
556
+ var _Array$from;
557
+
558
+ const timeFormat = /(?:(\d{1,}):)?(\d{2}):(\d{2})((\.(\d{1,3})))?/g;
559
+ const results = (_Array$from = Array.from(text.matchAll(timeFormat))) === null || _Array$from === void 0 ? void 0 : _Array$from[0];
560
+
561
+ if (results == null) {
562
+ return null;
563
+ } // This capture is optional, but will still be in the array as undefined,
564
+ // in which case it is 0.
565
+
566
+
567
+ const hours = Number(results[1]) || 0;
568
+ const minutes = Number(results[2]);
569
+ const seconds = Number(results[3]);
570
+ const milliseconds = Number(results[6]) || 0;
571
+
572
+ if (minutes > 59 || seconds > 59) {
573
+ return null;
574
+ }
575
+
576
+ return milliseconds / 1000 + seconds + minutes * 60 + hours * 3600;
577
+ };
578
+
579
+ const parseRegion = block => {
580
+ if (block[0].trim() !== 'REGION') {
581
+ return [];
582
+ }
583
+
584
+ const region = new shaka.text.CueRegion();
585
+ block.slice(1).forEach(word => {
586
+ let results = null;
587
+
588
+ if (results = /^id:(.*)$/.exec(word)) {
589
+ region.id = results[1];
590
+ } else if (results = /^width:(\d{1,2}|100)%$/.exec(word)) {
591
+ region.width = Number(results[1]);
592
+ } else if (results = /^lines:(\d+)$/.exec(word)) {
593
+ region.height = Number(results[1]);
594
+ region.heightUnits = shaka.text.CueRegion.units.LINES;
595
+ } else if (results = /^regionanchor:(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(word)) {
596
+ region.regionAnchorX = Number(results[1]);
597
+ region.regionAnchorY = Number(results[2]);
598
+ } else if (results = /^viewportanchor:(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(word)) {
599
+ region.viewportAnchorX = Number(results[1]);
600
+ region.viewportAnchorY = Number(results[2]);
601
+ } else if (results = /^scroll:up$/.exec(word)) {
602
+ region.scroll = shaka.text.CueRegion.scrollMode.UP;
603
+ } else {
604
+ shaka.log.warning('VTT parser encountered an invalid VTTRegion setting: ', word, ' The setting will be ignored.');
605
+ }
606
+ });
607
+ return [region];
608
+ };
609
+ /**
610
+ * @implements {shaka.extern.TextParser}
611
+ * @export
612
+ */
613
+
614
+
615
+ class VttTextParser {
616
+ /** Constructs a VTT parser. */
617
+ constructor() {
618
+ /** @private {boolean} */
619
+ this.sequenceMode_ = false;
620
+ /** @private {string} */
621
+
622
+ this.manifestType_ = shaka.media.ManifestParser.UNKNOWN;
623
+ }
624
+ /**
625
+ * @override
626
+ * @export
627
+ */
628
+
629
+
630
+ parseInit() {
631
+ goog$1.asserts.assert(false, 'VTT does not have init segments');
632
+ }
633
+ /**
634
+ * @override
635
+ * @export
636
+ */
637
+
638
+
639
+ setSequenceMode(sequenceMode) {
640
+ this.sequenceMode_ = sequenceMode;
641
+ }
642
+ /**
643
+ * @override
644
+ * @export
645
+ */
646
+
647
+
648
+ setManifestType(manifestType) {
649
+ this.manifestType_ = manifestType;
650
+ }
651
+ /**
652
+ * @override
653
+ * @export
654
+ */
655
+
656
+
657
+ parseMedia(data, time) {
658
+ // Get the input as a string. Normalize newlines to \n.
659
+ let str = shaka.util.StringUtils.fromUTF8(data);
660
+ str = str.replace(/\r\n|\r(?=[^\n]|$)/gm, '\n');
661
+ const blocks = str.split(/\n{2,}/m);
662
+
663
+ if (!/^WEBVTT($|[ \t\n])/m.test(blocks[0])) {
664
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
665
+ } // Depending on "segmentRelativeVttTiming" configuration,
666
+ // "vttOffset" will correspond to either "periodStart" (default)
667
+ // or "segmentStart", for segmented VTT where timings are relative
668
+ // to the beginning of each segment.
669
+ // NOTE: "periodStart" is the timestamp offset applied via TextEngine.
670
+ // It is no longer closely tied to periods, but the name stuck around.
671
+ // NOTE: This offset and the flag choosing its meaning have no effect on
672
+ // HLS content, which should use X-TIMESTAMP-MAP and periodStart instead.
673
+
674
+
675
+ let offset = time.vttOffset;
676
+
677
+ if (this.manifestType_ == shaka.media.ManifestParser.HLS) {
678
+ // Only use 'X-TIMESTAMP-MAP' with HLS.
679
+ if (blocks[0].includes('X-TIMESTAMP-MAP')) {
680
+ offset = this.computeHlsOffset_(blocks[0], time);
681
+ } else if (time.periodStart && time.vttOffset == time.periodStart) {
682
+ // In the case where X-TIMESTAMP-MAP is not used and it is HLS, we
683
+ // should not use offset unless segment-relative times are used.
684
+ offset = 0;
685
+ }
686
+ }
687
+
688
+ const regions = [];
689
+ /** @type {!Map<string, !shaka.text.Cue>} */
690
+
691
+ const styles = new Map();
692
+ addDefaultTextColor(styles); // Parse cues.
693
+
694
+ const ret = [];
695
+
696
+ for (const block of blocks.slice(1)) {
697
+ const lines = block.split('\n');
698
+ VttTextParser.parseStyle_(lines, styles);
699
+ regions.push(...parseRegion(lines));
700
+ const cue = VttTextParser.parseCue_(lines, offset, regions, styles);
701
+
702
+ if (cue) {
703
+ ret.push(cue);
704
+ }
705
+ }
706
+
707
+ return ret;
708
+ }
709
+ /**
710
+ * @param {string} headerBlock Contains X-TIMESTAMP-MAP.
711
+ * @param {shaka.extern.TextParser.TimeContext} time
712
+ * @return {number}
713
+ * @private
714
+ */
715
+
716
+
717
+ computeHlsOffset_(headerBlock, time) {
718
+ // https://bit.ly/2K92l7y
719
+ // The 'X-TIMESTAMP-MAP' header is used in HLS to align text with
720
+ // the rest of the media.
721
+ // The header format is 'X-TIMESTAMP-MAP=MPEGTS:n,LOCAL:m'
722
+ // (the attributes can go in any order)
723
+ // where n is MPEG-2 time and m is cue time it maps to.
724
+ // For example 'X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000'
725
+ // means an offset of 10 seconds
726
+ // 900000/MPEG_TIMESCALE - cue time.
727
+ const cueTimeMatch = headerBlock.match(/LOCAL:((?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{3}))/m);
728
+ const mpegTimeMatch = headerBlock.match(/MPEGTS:(\d+)/m);
729
+
730
+ if (!cueTimeMatch || !mpegTimeMatch) {
731
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
732
+ }
733
+
734
+ const cueTime = parseTime(cueTimeMatch[1]);
735
+
736
+ if (cueTime == null) {
737
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
738
+ }
739
+
740
+ let mpegTime = Number(mpegTimeMatch[1]);
741
+ const mpegTimescale = VttTextParser.MPEG_TIMESCALE_;
742
+ const rolloverSeconds = VttTextParser.TS_ROLLOVER_ / mpegTimescale;
743
+ let segmentStart = time.segmentStart - time.periodStart;
744
+
745
+ while (segmentStart >= rolloverSeconds) {
746
+ segmentStart -= rolloverSeconds;
747
+ mpegTime += VttTextParser.TS_ROLLOVER_;
748
+ }
749
+
750
+ return time.periodStart + mpegTime / mpegTimescale - cueTime;
751
+ }
752
+ /**
753
+ * Parses a style block into a Cue object.
754
+ *
755
+ * @param {!Array<string>} text
756
+ * @param {!Map<string, !shaka.text.Cue>} styles
757
+ * @private
758
+ */
759
+
760
+
761
+ static parseStyle_(text, styles) {
762
+ // Skip empty blocks.
763
+ if (text.length == 1 && !text[0]) {
764
+ return;
765
+ } // Skip comment blocks.
766
+
767
+
768
+ if (/^NOTE($|[ \t])/.test(text[0])) {
769
+ return;
770
+ } // Only style block are allowed.
771
+
772
+
773
+ if (text[0] != 'STYLE') {
774
+ return;
775
+ }
776
+ /** @type {!Array<!Array<string>>} */
777
+
778
+
779
+ const styleBlocks = [];
780
+ let lastBlockIndex = -1;
781
+
782
+ for (let i = 1; i < text.length; i++) {
783
+ if (text[i].includes('::cue')) {
784
+ styleBlocks.push([]);
785
+ lastBlockIndex = styleBlocks.length - 1;
786
+ }
787
+
788
+ if (lastBlockIndex == -1) {
789
+ continue;
790
+ }
791
+
792
+ styleBlocks[lastBlockIndex].push(text[i]);
793
+
794
+ if (text[i].includes('}')) {
795
+ lastBlockIndex = -1;
796
+ }
797
+ }
798
+
799
+ for (const styleBlock of styleBlocks) {
800
+ let styleSelector = 'global'; // Look for what is within parentheses. For example:
801
+ // <code>:: cue (b) {</code>, what we are looking for is <code>b</code>
802
+
803
+ const selector = styleBlock[0].match(/\((.*)\)/);
804
+
805
+ if (selector) {
806
+ styleSelector = selector.pop();
807
+ } // We start at 1 to avoid '::cue' and end earlier to avoid '}'
808
+
809
+
810
+ let propertyLines = styleBlock.slice(1, -1);
811
+
812
+ if (styleBlock[0].includes('}')) {
813
+ const payload = /\{(.*?)\}/.exec(styleBlock[0]);
814
+
815
+ if (payload) {
816
+ propertyLines = payload[1].split(';');
817
+ }
818
+ } // Continue styles over multiple selectors if necessary.
819
+ // For example,
820
+ // ::cue(b) { background: white; } ::cue(b) { color: blue; }
821
+ // should set both the background and foreground of bold tags.
822
+
823
+
824
+ let cue = styles.get(styleSelector);
825
+
826
+ if (!cue) {
827
+ cue = new shaka.text.Cue(0, 0, '');
828
+ }
829
+
830
+ let validStyle = false;
831
+
832
+ for (let i = 0; i < propertyLines.length; i++) {
833
+ // We look for CSS properties. As a general rule they are separated by
834
+ // <code>:</code>. Eg: <code>color: red;</code>
835
+ const lineParts = /^\s*([^:]+):\s*(.*)/.exec(propertyLines[i]);
836
+
837
+ if (lineParts) {
838
+ const name = lineParts[1].trim();
839
+ const value = lineParts[2].trim().replace(';', '');
840
+
841
+ switch (name) {
842
+ case 'background-color':
843
+ case 'background':
844
+ validStyle = true;
845
+ cue.backgroundColor = value;
846
+ break;
847
+
848
+ case 'color':
849
+ validStyle = true;
850
+ cue.color = value;
851
+ break;
852
+
853
+ case 'font-family':
854
+ validStyle = true;
855
+ cue.fontFamily = value;
856
+ break;
857
+
858
+ case 'font-size':
859
+ validStyle = true;
860
+ cue.fontSize = value;
861
+ break;
862
+
863
+ case 'font-weight':
864
+ if (parseInt(value, 10) >= 700 || value == 'bold') {
865
+ validStyle = true;
866
+ cue.fontWeight = shaka.text.Cue.fontWeight.BOLD;
867
+ }
868
+
869
+ break;
870
+
871
+ case 'font-style':
872
+ switch (value) {
873
+ case 'normal':
874
+ validStyle = true;
875
+ cue.fontStyle = shaka.text.Cue.fontStyle.NORMAL;
876
+ break;
877
+
878
+ case 'italic':
879
+ validStyle = true;
880
+ cue.fontStyle = shaka.text.Cue.fontStyle.ITALIC;
881
+ break;
882
+
883
+ case 'oblique':
884
+ validStyle = true;
885
+ cue.fontStyle = shaka.text.Cue.fontStyle.OBLIQUE;
886
+ break;
887
+ }
888
+
889
+ break;
890
+
891
+ case 'opacity':
892
+ validStyle = true;
893
+ cue.opacity = parseFloat(value);
894
+ break;
895
+
896
+ case 'text-combine-upright':
897
+ validStyle = true;
898
+ cue.textCombineUpright = value;
899
+ break;
900
+
901
+ case 'text-shadow':
902
+ validStyle = true;
903
+ cue.textShadow = value;
904
+ break;
905
+
906
+ case 'white-space':
907
+ validStyle = true;
908
+ cue.wrapLine = value != 'noWrap';
909
+ break;
910
+
911
+ default:
912
+ shaka.log.warning('VTT parser encountered an unsupported style: ', lineParts);
913
+ break;
914
+ }
915
+ }
916
+ }
917
+
918
+ if (validStyle) {
919
+ styles.set(styleSelector, cue);
920
+ }
921
+ }
922
+ }
923
+ /**
924
+ * Parses a text block into a Cue object.
925
+ *
926
+ * @param {!Array<string>} text
927
+ * @param {number} timeOffset
928
+ * @param {!Array<!shaka.text.CueRegion>} regions
929
+ * @param {!Map<string, !shaka.text.Cue>} styles
930
+ * @return {shaka.text.Cue}
931
+ * @private
932
+ */
933
+
934
+
935
+ static parseCue_(text, timeOffset, regions, styles) {
936
+ // Skip empty blocks.
937
+ if (text.length == 1 && !text[0]) {
938
+ return null;
939
+ } // Skip comment blocks.
940
+
941
+
942
+ if (/^NOTE($|[ \t])/.test(text[0])) {
943
+ return null;
944
+ } // Skip style and region blocks.
945
+
946
+
947
+ if (text[0] == 'STYLE' || text[0] == 'REGION') {
948
+ return null;
949
+ }
950
+
951
+ const skipIndex = text.findIndex(line => /^#/.test(line.trim()));
952
+
953
+ if (skipIndex > 0) {
954
+ text = text.slice(skipIndex);
955
+ }
956
+
957
+ if (text.length < 2) {
958
+ return;
959
+ }
960
+
961
+ let id = null;
962
+
963
+ if (!text[0].includes('-->')) {
964
+ id = text[0];
965
+ text.splice(0, 1);
966
+ } // Parse the times.
967
+
968
+
969
+ let [start, end] = text[0].split('-->').map(part => parseTime(part.trim()));
970
+
971
+ if (start == null || end == null) {
972
+ shaka.log.alwaysWarn('Failed to parse VTT time code. Cue skipped:', id, text);
973
+ return null;
974
+ }
975
+
976
+ start += timeOffset;
977
+ end += timeOffset; // Get the payload.
978
+
979
+ const payload = text.slice(1).join('\n').trim();
980
+ let cue = null;
981
+
982
+ if (styles.has('global')) {
983
+ cue = styles.get('global').clone();
984
+ cue.startTime = start;
985
+ cue.endTime = end;
986
+ cue.payload = payload;
987
+ } else {
988
+ cue = new shaka.text.Cue(start, end, payload);
989
+ } // Parse optional settings.
990
+
991
+
992
+ text[0].split(/\s+/g).slice(3).forEach(word => {
993
+ if (!word.trim()) {
994
+ return;
995
+ }
996
+
997
+ if (!VttTextParser.parseCueSetting(cue, word, regions)) {
998
+ shaka.log.warning('VTT parser encountered an invalid VTT setting: ', word, ' The setting will be ignored.');
999
+ }
1000
+ });
1001
+ shaka.text.Cue.parseCuePayload(cue, styles);
1002
+
1003
+ if (id != null) {
1004
+ cue.id = id;
1005
+ }
1006
+
1007
+ return cue;
1008
+ }
1009
+ /**
1010
+ * Parses a WebVTT setting from the given word.
1011
+ *
1012
+ * @param {!shaka.text.Cue} cue
1013
+ * @param {string} word
1014
+ * @param {!Array<!shaka.text.CueRegion>} regions
1015
+ * @return {boolean} True on success.
1016
+ */
1017
+
1018
+
1019
+ static parseCueSetting(cue, word, regions) {
1020
+ let results = null;
1021
+
1022
+ if (results = /^align:(start|middle|center|end|left|right)$/.exec(word)) {
1023
+ VttTextParser.setTextAlign_(cue, results[1]);
1024
+ } else if (results = /^vertical:(lr|rl)$/.exec(word)) {
1025
+ VttTextParser.setVerticalWritingMode_(cue, results[1]);
1026
+ } else if (results = /^size:([\d.]+)%$/.exec(word)) {
1027
+ cue.size = Number(results[1]);
1028
+ } else if (results = /^position:([\d.]+)%(?:,(line-left|line-right|middle|center|start|end|auto))?$/.exec(word)) {
1029
+ cue.position = Number(results[1]);
1030
+
1031
+ if (results[2]) {
1032
+ VttTextParser.setPositionAlign_(cue, results[2]);
1033
+ }
1034
+ } else if (results = /^region:(.*)$/.exec(word)) {
1035
+ const region = VttTextParser.getRegionById_(regions, results[1]);
1036
+
1037
+ if (region) {
1038
+ cue.region = region;
1039
+ }
1040
+ } else {
1041
+ return VttTextParser.parsedLineValueAndInterpretation_(cue, word);
1042
+ }
1043
+
1044
+ return true;
1045
+ }
1046
+ /**
1047
+ *
1048
+ * @param {!Array<!shaka.text.CueRegion>} regions
1049
+ * @param {string} id
1050
+ * @return {?shaka.text.CueRegion}
1051
+ * @private
1052
+ */
1053
+
1054
+
1055
+ static getRegionById_(regions, id) {
1056
+ const regionsWithId = regions.filter(region => region.id == id);
1057
+
1058
+ if (!regionsWithId.length) {
1059
+ shaka.log.warning('VTT parser could not find a region with id: ', id, ' The region will be ignored.');
1060
+ return null;
1061
+ }
1062
+
1063
+ goog$1.asserts.assert(regionsWithId.length == 1, 'VTTRegion ids should be unique!');
1064
+ return regionsWithId[0];
1065
+ }
1066
+ /**
1067
+ * @param {!shaka.text.Cue} cue
1068
+ * @param {string} align
1069
+ * @private
1070
+ */
1071
+
1072
+
1073
+ static setTextAlign_(cue, align) {
1074
+ const Cue = shaka.text.Cue;
1075
+
1076
+ if (align == 'middle') {
1077
+ cue.textAlign = Cue.textAlign.CENTER;
1078
+ } else {
1079
+ goog$1.asserts.assert(align.toUpperCase() in Cue.textAlign, `${align.toUpperCase()} Should be in Cue.textAlign values!`);
1080
+ cue.textAlign = Cue.textAlign[align.toUpperCase()];
1081
+ }
1082
+ }
1083
+ /**
1084
+ * @param {!shaka.text.Cue} cue
1085
+ * @param {string} align
1086
+ * @private
1087
+ */
1088
+
1089
+
1090
+ static setPositionAlign_(cue, align) {
1091
+ const Cue = shaka.text.Cue;
1092
+
1093
+ if (align == 'line-left' || align == 'start') {
1094
+ cue.positionAlign = Cue.positionAlign.LEFT;
1095
+ } else if (align == 'line-right' || align == 'end') {
1096
+ cue.positionAlign = Cue.positionAlign.RIGHT;
1097
+ } else if (align == 'center' || align == 'middle') {
1098
+ cue.positionAlign = Cue.positionAlign.CENTER;
1099
+ } else {
1100
+ cue.positionAlign = Cue.positionAlign.AUTO;
1101
+ }
1102
+ }
1103
+ /**
1104
+ * @param {!shaka.text.Cue} cue
1105
+ * @param {string} value
1106
+ * @private
1107
+ */
1108
+
1109
+
1110
+ static setVerticalWritingMode_(cue, value) {
1111
+ const Cue = shaka.text.Cue;
1112
+
1113
+ if (value == 'lr') {
1114
+ cue.writingMode = Cue.writingMode.VERTICAL_LEFT_TO_RIGHT;
1115
+ } else {
1116
+ cue.writingMode = Cue.writingMode.VERTICAL_RIGHT_TO_LEFT;
1117
+ }
1118
+ }
1119
+ /**
1120
+ * @param {!shaka.text.Cue} cue
1121
+ * @param {string} word
1122
+ * @return {boolean}
1123
+ * @private
1124
+ */
1125
+
1126
+
1127
+ static parsedLineValueAndInterpretation_(cue, word) {
1128
+ const Cue = shaka.text.Cue;
1129
+ let results = null;
1130
+
1131
+ if (results = /^line:([\d.]+)%(?:,(start|end|center))?$/.exec(word)) {
1132
+ cue.lineInterpretation = Cue.lineInterpretation.PERCENTAGE;
1133
+ cue.line = Number(results[1]);
1134
+
1135
+ if (results[2]) {
1136
+ goog$1.asserts.assert(results[2].toUpperCase() in Cue.lineAlign, `${results[2].toUpperCase()} Should be in Cue.lineAlign values!`);
1137
+ cue.lineAlign = Cue.lineAlign[results[2].toUpperCase()];
1138
+ }
1139
+ } else if (results = /^line:(-?\d+)(?:,(start|end|center))?$/.exec(word)) {
1140
+ cue.lineInterpretation = Cue.lineInterpretation.LINE_NUMBER;
1141
+ cue.line = Number(results[1]);
1142
+
1143
+ if (results[2]) {
1144
+ goog$1.asserts.assert(results[2].toUpperCase() in Cue.lineAlign, `${results[2].toUpperCase()} Should be in Cue.lineAlign values!`);
1145
+ cue.lineAlign = Cue.lineAlign[results[2].toUpperCase()];
1146
+ }
1147
+ } else {
1148
+ return false;
1149
+ }
1150
+
1151
+ return true;
1152
+ }
1153
+
1154
+ }
1155
+ /**
1156
+ * @const {number}
1157
+ * @private
1158
+ */
1159
+
1160
+
1161
+ VttTextParser.MPEG_TIMESCALE_ = 90000;
1162
+ /**
1163
+ * At this value, timestamps roll over in TS content.
1164
+ * @const {number}
1165
+ * @private
1166
+ */
1167
+
1168
+ VttTextParser.TS_ROLLOVER_ = 0x200000000;
1169
+
1170
+ VttTextParser.register = shakaNameSpace => {
1171
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt', () => new VttTextParser());
1172
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt; codecs="vtt"', () => new VttTextParser());
1173
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt; codecs="wvtt"', () => new VttTextParser());
1174
+ };
1175
+
518
1176
  /*! @license
519
1177
  * Shaka Player
520
1178
  * Copyright 2016 Google LLC
@@ -1404,9 +2062,13 @@ class UITextDisplayer {
1404
2062
  } else if (cue.textAlign == Cue.textAlign.RIGHT || cue.textAlign == Cue.textAlign.END) {
1405
2063
  style.width = '100%';
1406
2064
  style.alignItems = 'end';
1407
- }
2065
+ } // in VTT displayAlign can't be set, it defaults to 'after',
2066
+ // but for vertical, it should be 'before'
1408
2067
 
1409
- if (cue.displayAlign == Cue.displayAlign.BEFORE) {
2068
+
2069
+ if (/vertical/.test(cue.writingMode)) {
2070
+ style.justifyContent = 'flex-start';
2071
+ } else if (cue.displayAlign == Cue.displayAlign.BEFORE) {
1410
2072
  style.justifyContent = 'flex-start';
1411
2073
  } else if (cue.displayAlign == Cue.displayAlign.CENTER) {
1412
2074
  style.justifyContent = 'center';
@@ -1779,6 +2441,7 @@ const loadShaka = async (videoElement, config = {}, options = {}) => {
1779
2441
  return getQualityItem(activeTrack);
1780
2442
  };
1781
2443
 
2444
+ VttTextParser.register(shaka);
1782
2445
  HttpFetchPlugin.register(shaka);
1783
2446
  const networkEngine = player.getNetworkingEngine();
1784
2447
  networkEngine.registerRequestFilter((type, request) => extensionOptions.requestHandlers.reduce((merged, handler) => handler(type, merged, player, extensionOptions), request));