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

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/index.mjs CHANGED
@@ -812,7 +812,7 @@ function convertToSeconds(timeString) {
812
812
  function getVersion() {
813
813
  try {
814
814
  // eslint-disable-next-line no-undef
815
- return "2.25.0-canary.17";
815
+ return "2.25.0-canary.18";
816
816
  } catch (e) {
817
817
  return undefined;
818
818
  }
@@ -6007,7 +6007,7 @@ const makeResponse = (headers, data, status, uri, responseURL, requestType) => {
6007
6007
  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);
6008
6008
  };
6009
6009
 
6010
- const goog$1 = {
6010
+ const goog$2 = {
6011
6011
  asserts: {
6012
6012
  assert: () => {}
6013
6013
  }
@@ -6153,7 +6153,7 @@ class HttpFetchPlugin {
6153
6153
  }
6154
6154
 
6155
6155
  if (readObj.done) {
6156
- goog$1.asserts.assert(!readObj.value, 'readObj should be unset when "done" is true.');
6156
+ goog$2.asserts.assert(!readObj.value, 'readObj should be unset when "done" is true.');
6157
6157
  controller.close();
6158
6158
  } else {
6159
6159
  controller.enqueue(readObj.value);
@@ -6392,6 +6392,654 @@ const fixDashManifest = (data, {
6392
6392
  return new XMLSerializer().serializeToString(doc);
6393
6393
  };
6394
6394
 
6395
+ /* eslint-disable no-cond-assign */
6396
+
6397
+ /* eslint-disable prefer-destructuring */
6398
+
6399
+ /*! @license
6400
+ * Shaka Player
6401
+ * Copyright 2016 Google LLC
6402
+ * SPDX-License-Identifier: Apache-2.0
6403
+ */
6404
+ const goog$1 = {
6405
+ asserts: {
6406
+ assert: (condition, message) => {
6407
+ if (!condition) {
6408
+ console.warn('GOOG Assert!', message);
6409
+ }
6410
+ }
6411
+ }
6412
+ };
6413
+
6414
+ const addDefaultTextColor = styles => {
6415
+ const textColor = shaka.text.Cue.defaultTextColor;
6416
+
6417
+ for (const [key, value] of Object.entries(textColor)) {
6418
+ const cue = new shaka.text.Cue(0, 0, '');
6419
+ cue.color = value;
6420
+ styles.set(`.${key}`, cue);
6421
+ }
6422
+
6423
+ const bgColor = shaka.text.Cue.defaultTextBackgroundColor;
6424
+
6425
+ for (const [key, value] of Object.entries(bgColor)) {
6426
+ const cue = new shaka.text.Cue(0, 0, '');
6427
+ cue.backgroundColor = value;
6428
+ styles.set(`.${key}`, cue);
6429
+ }
6430
+ };
6431
+
6432
+ const parseTime = text => {
6433
+ var _Array$from;
6434
+
6435
+ const timeFormat = /(?:(\d{1,}):)?(\d{2}):(\d{2})((\.(\d{1,3})))?/g;
6436
+ const results = (_Array$from = Array.from(text.matchAll(timeFormat))) === null || _Array$from === void 0 ? void 0 : _Array$from[0];
6437
+
6438
+ if (results == null) {
6439
+ return null;
6440
+ } // This capture is optional, but will still be in the array as undefined,
6441
+ // in which case it is 0.
6442
+
6443
+
6444
+ const hours = Number(results[1]) || 0;
6445
+ const minutes = Number(results[2]);
6446
+ const seconds = Number(results[3]);
6447
+ const milliseconds = Number(results[6]) || 0;
6448
+
6449
+ if (minutes > 59 || seconds > 59) {
6450
+ return null;
6451
+ }
6452
+
6453
+ return milliseconds / 1000 + seconds + minutes * 60 + hours * 3600;
6454
+ };
6455
+
6456
+ const parseRegion = block => {
6457
+ if (block[0].trim() !== 'REGION') {
6458
+ return [];
6459
+ }
6460
+
6461
+ const region = new shaka.text.CueRegion();
6462
+ block.slice(1).forEach(word => {
6463
+ let results = null;
6464
+
6465
+ if (results = /^id:(.*)$/.exec(word)) {
6466
+ region.id = results[1];
6467
+ } else if (results = /^width:(\d{1,2}|100)%$/.exec(word)) {
6468
+ region.width = Number(results[1]);
6469
+ } else if (results = /^lines:(\d+)$/.exec(word)) {
6470
+ region.height = Number(results[1]);
6471
+ region.heightUnits = shaka.text.CueRegion.units.LINES;
6472
+ } else if (results = /^regionanchor:(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(word)) {
6473
+ region.regionAnchorX = Number(results[1]);
6474
+ region.regionAnchorY = Number(results[2]);
6475
+ } else if (results = /^viewportanchor:(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(word)) {
6476
+ region.viewportAnchorX = Number(results[1]);
6477
+ region.viewportAnchorY = Number(results[2]);
6478
+ } else if (results = /^scroll:up$/.exec(word)) {
6479
+ region.scroll = shaka.text.CueRegion.scrollMode.UP;
6480
+ } else {
6481
+ shaka.log.warning('VTT parser encountered an invalid VTTRegion setting: ', word, ' The setting will be ignored.');
6482
+ }
6483
+ });
6484
+ return [region];
6485
+ };
6486
+ /**
6487
+ * @implements {shaka.extern.TextParser}
6488
+ * @export
6489
+ */
6490
+
6491
+
6492
+ class VttTextParser {
6493
+ /** Constructs a VTT parser. */
6494
+ constructor() {
6495
+ /** @private {boolean} */
6496
+ this.sequenceMode_ = false;
6497
+ /** @private {string} */
6498
+
6499
+ this.manifestType_ = shaka.media.ManifestParser.UNKNOWN;
6500
+ }
6501
+ /**
6502
+ * @override
6503
+ * @export
6504
+ */
6505
+
6506
+
6507
+ parseInit() {
6508
+ goog$1.asserts.assert(false, 'VTT does not have init segments');
6509
+ }
6510
+ /**
6511
+ * @override
6512
+ * @export
6513
+ */
6514
+
6515
+
6516
+ setSequenceMode(sequenceMode) {
6517
+ this.sequenceMode_ = sequenceMode;
6518
+ }
6519
+ /**
6520
+ * @override
6521
+ * @export
6522
+ */
6523
+
6524
+
6525
+ setManifestType(manifestType) {
6526
+ this.manifestType_ = manifestType;
6527
+ }
6528
+ /**
6529
+ * @override
6530
+ * @export
6531
+ */
6532
+
6533
+
6534
+ parseMedia(data, time) {
6535
+ // Get the input as a string. Normalize newlines to \n.
6536
+ let str = shaka.util.StringUtils.fromUTF8(data);
6537
+ str = str.replace(/\r\n|\r(?=[^\n]|$)/gm, '\n');
6538
+ const blocks = str.split(/\n{2,}/m);
6539
+
6540
+ if (!/^WEBVTT($|[ \t\n])/m.test(blocks[0])) {
6541
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
6542
+ } // Depending on "segmentRelativeVttTiming" configuration,
6543
+ // "vttOffset" will correspond to either "periodStart" (default)
6544
+ // or "segmentStart", for segmented VTT where timings are relative
6545
+ // to the beginning of each segment.
6546
+ // NOTE: "periodStart" is the timestamp offset applied via TextEngine.
6547
+ // It is no longer closely tied to periods, but the name stuck around.
6548
+ // NOTE: This offset and the flag choosing its meaning have no effect on
6549
+ // HLS content, which should use X-TIMESTAMP-MAP and periodStart instead.
6550
+
6551
+
6552
+ let offset = time.vttOffset;
6553
+
6554
+ if (this.manifestType_ == shaka.media.ManifestParser.HLS) {
6555
+ // Only use 'X-TIMESTAMP-MAP' with HLS.
6556
+ if (blocks[0].includes('X-TIMESTAMP-MAP')) {
6557
+ offset = this.computeHlsOffset_(blocks[0], time);
6558
+ } else if (time.periodStart && time.vttOffset == time.periodStart) {
6559
+ // In the case where X-TIMESTAMP-MAP is not used and it is HLS, we
6560
+ // should not use offset unless segment-relative times are used.
6561
+ offset = 0;
6562
+ }
6563
+ }
6564
+
6565
+ const regions = [];
6566
+ /** @type {!Map<string, !shaka.text.Cue>} */
6567
+
6568
+ const styles = new Map();
6569
+ addDefaultTextColor(styles); // Parse cues.
6570
+
6571
+ const ret = [];
6572
+
6573
+ for (const block of blocks.slice(1)) {
6574
+ const lines = block.split('\n');
6575
+ VttTextParser.parseStyle_(lines, styles);
6576
+ regions.push(...parseRegion(lines));
6577
+ const cue = VttTextParser.parseCue_(lines, offset, regions, styles);
6578
+
6579
+ if (cue) {
6580
+ ret.push(cue);
6581
+ }
6582
+ }
6583
+
6584
+ return ret;
6585
+ }
6586
+ /**
6587
+ * @param {string} headerBlock Contains X-TIMESTAMP-MAP.
6588
+ * @param {shaka.extern.TextParser.TimeContext} time
6589
+ * @return {number}
6590
+ * @private
6591
+ */
6592
+
6593
+
6594
+ computeHlsOffset_(headerBlock, time) {
6595
+ // https://bit.ly/2K92l7y
6596
+ // The 'X-TIMESTAMP-MAP' header is used in HLS to align text with
6597
+ // the rest of the media.
6598
+ // The header format is 'X-TIMESTAMP-MAP=MPEGTS:n,LOCAL:m'
6599
+ // (the attributes can go in any order)
6600
+ // where n is MPEG-2 time and m is cue time it maps to.
6601
+ // For example 'X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000'
6602
+ // means an offset of 10 seconds
6603
+ // 900000/MPEG_TIMESCALE - cue time.
6604
+ const cueTimeMatch = headerBlock.match(/LOCAL:((?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{3}))/m);
6605
+ const mpegTimeMatch = headerBlock.match(/MPEGTS:(\d+)/m);
6606
+
6607
+ if (!cueTimeMatch || !mpegTimeMatch) {
6608
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
6609
+ }
6610
+
6611
+ const cueTime = parseTime(cueTimeMatch[1]);
6612
+
6613
+ if (cueTime == null) {
6614
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
6615
+ }
6616
+
6617
+ let mpegTime = Number(mpegTimeMatch[1]);
6618
+ const mpegTimescale = VttTextParser.MPEG_TIMESCALE_;
6619
+ const rolloverSeconds = VttTextParser.TS_ROLLOVER_ / mpegTimescale;
6620
+ let segmentStart = time.segmentStart - time.periodStart;
6621
+
6622
+ while (segmentStart >= rolloverSeconds) {
6623
+ segmentStart -= rolloverSeconds;
6624
+ mpegTime += VttTextParser.TS_ROLLOVER_;
6625
+ }
6626
+
6627
+ return time.periodStart + mpegTime / mpegTimescale - cueTime;
6628
+ }
6629
+ /**
6630
+ * Parses a style block into a Cue object.
6631
+ *
6632
+ * @param {!Array<string>} text
6633
+ * @param {!Map<string, !shaka.text.Cue>} styles
6634
+ * @private
6635
+ */
6636
+
6637
+
6638
+ static parseStyle_(text, styles) {
6639
+ // Skip empty blocks.
6640
+ if (text.length == 1 && !text[0]) {
6641
+ return;
6642
+ } // Skip comment blocks.
6643
+
6644
+
6645
+ if (/^NOTE($|[ \t])/.test(text[0])) {
6646
+ return;
6647
+ } // Only style block are allowed.
6648
+
6649
+
6650
+ if (text[0] != 'STYLE') {
6651
+ return;
6652
+ }
6653
+ /** @type {!Array<!Array<string>>} */
6654
+
6655
+
6656
+ const styleBlocks = [];
6657
+ let lastBlockIndex = -1;
6658
+
6659
+ for (let i = 1; i < text.length; i++) {
6660
+ if (text[i].includes('::cue')) {
6661
+ styleBlocks.push([]);
6662
+ lastBlockIndex = styleBlocks.length - 1;
6663
+ }
6664
+
6665
+ if (lastBlockIndex == -1) {
6666
+ continue;
6667
+ }
6668
+
6669
+ styleBlocks[lastBlockIndex].push(text[i]);
6670
+
6671
+ if (text[i].includes('}')) {
6672
+ lastBlockIndex = -1;
6673
+ }
6674
+ }
6675
+
6676
+ for (const styleBlock of styleBlocks) {
6677
+ let styleSelector = 'global'; // Look for what is within parentheses. For example:
6678
+ // <code>:: cue (b) {</code>, what we are looking for is <code>b</code>
6679
+
6680
+ const selector = styleBlock[0].match(/\((.*)\)/);
6681
+
6682
+ if (selector) {
6683
+ styleSelector = selector.pop();
6684
+ } // We start at 1 to avoid '::cue' and end earlier to avoid '}'
6685
+
6686
+
6687
+ let propertyLines = styleBlock.slice(1, -1);
6688
+
6689
+ if (styleBlock[0].includes('}')) {
6690
+ const payload = /\{(.*?)\}/.exec(styleBlock[0]);
6691
+
6692
+ if (payload) {
6693
+ propertyLines = payload[1].split(';');
6694
+ }
6695
+ } // Continue styles over multiple selectors if necessary.
6696
+ // For example,
6697
+ // ::cue(b) { background: white; } ::cue(b) { color: blue; }
6698
+ // should set both the background and foreground of bold tags.
6699
+
6700
+
6701
+ let cue = styles.get(styleSelector);
6702
+
6703
+ if (!cue) {
6704
+ cue = new shaka.text.Cue(0, 0, '');
6705
+ }
6706
+
6707
+ let validStyle = false;
6708
+
6709
+ for (let i = 0; i < propertyLines.length; i++) {
6710
+ // We look for CSS properties. As a general rule they are separated by
6711
+ // <code>:</code>. Eg: <code>color: red;</code>
6712
+ const lineParts = /^\s*([^:]+):\s*(.*)/.exec(propertyLines[i]);
6713
+
6714
+ if (lineParts) {
6715
+ const name = lineParts[1].trim();
6716
+ const value = lineParts[2].trim().replace(';', '');
6717
+
6718
+ switch (name) {
6719
+ case 'background-color':
6720
+ case 'background':
6721
+ validStyle = true;
6722
+ cue.backgroundColor = value;
6723
+ break;
6724
+
6725
+ case 'color':
6726
+ validStyle = true;
6727
+ cue.color = value;
6728
+ break;
6729
+
6730
+ case 'font-family':
6731
+ validStyle = true;
6732
+ cue.fontFamily = value;
6733
+ break;
6734
+
6735
+ case 'font-size':
6736
+ validStyle = true;
6737
+ cue.fontSize = value;
6738
+ break;
6739
+
6740
+ case 'font-weight':
6741
+ if (parseInt(value, 10) >= 700 || value == 'bold') {
6742
+ validStyle = true;
6743
+ cue.fontWeight = shaka.text.Cue.fontWeight.BOLD;
6744
+ }
6745
+
6746
+ break;
6747
+
6748
+ case 'font-style':
6749
+ switch (value) {
6750
+ case 'normal':
6751
+ validStyle = true;
6752
+ cue.fontStyle = shaka.text.Cue.fontStyle.NORMAL;
6753
+ break;
6754
+
6755
+ case 'italic':
6756
+ validStyle = true;
6757
+ cue.fontStyle = shaka.text.Cue.fontStyle.ITALIC;
6758
+ break;
6759
+
6760
+ case 'oblique':
6761
+ validStyle = true;
6762
+ cue.fontStyle = shaka.text.Cue.fontStyle.OBLIQUE;
6763
+ break;
6764
+ }
6765
+
6766
+ break;
6767
+
6768
+ case 'opacity':
6769
+ validStyle = true;
6770
+ cue.opacity = parseFloat(value);
6771
+ break;
6772
+
6773
+ case 'text-combine-upright':
6774
+ validStyle = true;
6775
+ cue.textCombineUpright = value;
6776
+ break;
6777
+
6778
+ case 'text-shadow':
6779
+ validStyle = true;
6780
+ cue.textShadow = value;
6781
+ break;
6782
+
6783
+ case 'white-space':
6784
+ validStyle = true;
6785
+ cue.wrapLine = value != 'noWrap';
6786
+ break;
6787
+
6788
+ default:
6789
+ shaka.log.warning('VTT parser encountered an unsupported style: ', lineParts);
6790
+ break;
6791
+ }
6792
+ }
6793
+ }
6794
+
6795
+ if (validStyle) {
6796
+ styles.set(styleSelector, cue);
6797
+ }
6798
+ }
6799
+ }
6800
+ /**
6801
+ * Parses a text block into a Cue object.
6802
+ *
6803
+ * @param {!Array<string>} text
6804
+ * @param {number} timeOffset
6805
+ * @param {!Array<!shaka.text.CueRegion>} regions
6806
+ * @param {!Map<string, !shaka.text.Cue>} styles
6807
+ * @return {shaka.text.Cue}
6808
+ * @private
6809
+ */
6810
+
6811
+
6812
+ static parseCue_(text, timeOffset, regions, styles) {
6813
+ // Skip empty blocks.
6814
+ if (text.length == 1 && !text[0]) {
6815
+ return null;
6816
+ } // Skip comment blocks.
6817
+
6818
+
6819
+ if (/^NOTE($|[ \t])/.test(text[0])) {
6820
+ return null;
6821
+ } // Skip style and region blocks.
6822
+
6823
+
6824
+ if (text[0] == 'STYLE' || text[0] == 'REGION') {
6825
+ return null;
6826
+ }
6827
+
6828
+ let id = null;
6829
+
6830
+ if (!text[0].includes('-->')) {
6831
+ id = text[0];
6832
+ text.splice(0, 1);
6833
+ } // Parse the times.
6834
+
6835
+
6836
+ let [start, end] = text[0].split('-->').map(part => parseTime(part.trim()));
6837
+
6838
+ if (start == null || end == null) {
6839
+ shaka.log.alwaysWarn('Failed to parse VTT time code. Cue skipped:', id, text);
6840
+ return null;
6841
+ }
6842
+
6843
+ start += timeOffset;
6844
+ end += timeOffset; // Get the payload.
6845
+
6846
+ const payload = text.slice(1).join('\n').trim();
6847
+ let cue = null;
6848
+
6849
+ if (styles.has('global')) {
6850
+ cue = styles.get('global').clone();
6851
+ cue.startTime = start;
6852
+ cue.endTime = end;
6853
+ cue.payload = payload;
6854
+ } else {
6855
+ cue = new shaka.text.Cue(start, end, payload);
6856
+ } // Parse optional settings.
6857
+
6858
+
6859
+ text[0].split(/\s+/g).slice(3).forEach(word => {
6860
+ if (!word.trim()) {
6861
+ return;
6862
+ }
6863
+
6864
+ if (!VttTextParser.parseCueSetting(cue, word, regions)) {
6865
+ shaka.log.warning('VTT parser encountered an invalid VTT setting: ', word, ' The setting will be ignored.');
6866
+ }
6867
+ });
6868
+ shaka.text.Cue.parseCuePayload(cue, styles);
6869
+
6870
+ if (id != null) {
6871
+ cue.id = id;
6872
+ }
6873
+
6874
+ return cue;
6875
+ }
6876
+ /**
6877
+ * Parses a WebVTT setting from the given word.
6878
+ *
6879
+ * @param {!shaka.text.Cue} cue
6880
+ * @param {string} word
6881
+ * @param {!Array<!shaka.text.CueRegion>} regions
6882
+ * @return {boolean} True on success.
6883
+ */
6884
+
6885
+
6886
+ static parseCueSetting(cue, word, regions) {
6887
+ let results = null;
6888
+
6889
+ if (results = /^align:(start|middle|center|end|left|right)$/.exec(word)) {
6890
+ VttTextParser.setTextAlign_(cue, results[1]);
6891
+ } else if (results = /^vertical:(lr|rl)$/.exec(word)) {
6892
+ VttTextParser.setVerticalWritingMode_(cue, results[1]);
6893
+ } else if (results = /^size:([\d.]+)%$/.exec(word)) {
6894
+ cue.size = Number(results[1]);
6895
+ } else if (results = /^position:([\d.]+)%(?:,(line-left|line-right|middle|center|start|end|auto))?$/.exec(word)) {
6896
+ cue.position = Number(results[1]);
6897
+
6898
+ if (results[2]) {
6899
+ VttTextParser.setPositionAlign_(cue, results[2]);
6900
+ }
6901
+ } else if (results = /^region:(.*)$/.exec(word)) {
6902
+ const region = VttTextParser.getRegionById_(regions, results[1]);
6903
+
6904
+ if (region) {
6905
+ cue.region = region;
6906
+ }
6907
+ } else {
6908
+ return VttTextParser.parsedLineValueAndInterpretation_(cue, word);
6909
+ }
6910
+
6911
+ return true;
6912
+ }
6913
+ /**
6914
+ *
6915
+ * @param {!Array<!shaka.text.CueRegion>} regions
6916
+ * @param {string} id
6917
+ * @return {?shaka.text.CueRegion}
6918
+ * @private
6919
+ */
6920
+
6921
+
6922
+ static getRegionById_(regions, id) {
6923
+ const regionsWithId = regions.filter(region => region.id == id);
6924
+
6925
+ if (!regionsWithId.length) {
6926
+ shaka.log.warning('VTT parser could not find a region with id: ', id, ' The region will be ignored.');
6927
+ return null;
6928
+ }
6929
+
6930
+ goog$1.asserts.assert(regionsWithId.length == 1, 'VTTRegion ids should be unique!');
6931
+ return regionsWithId[0];
6932
+ }
6933
+ /**
6934
+ * @param {!shaka.text.Cue} cue
6935
+ * @param {string} align
6936
+ * @private
6937
+ */
6938
+
6939
+
6940
+ static setTextAlign_(cue, align) {
6941
+ const Cue = shaka.text.Cue;
6942
+
6943
+ if (align == 'middle') {
6944
+ cue.textAlign = Cue.textAlign.CENTER;
6945
+ } else {
6946
+ goog$1.asserts.assert(align.toUpperCase() in Cue.textAlign, `${align.toUpperCase()} Should be in Cue.textAlign values!`);
6947
+ cue.textAlign = Cue.textAlign[align.toUpperCase()];
6948
+ }
6949
+ }
6950
+ /**
6951
+ * @param {!shaka.text.Cue} cue
6952
+ * @param {string} align
6953
+ * @private
6954
+ */
6955
+
6956
+
6957
+ static setPositionAlign_(cue, align) {
6958
+ const Cue = shaka.text.Cue;
6959
+
6960
+ if (align == 'line-left' || align == 'start') {
6961
+ cue.positionAlign = Cue.positionAlign.LEFT;
6962
+ } else if (align == 'line-right' || align == 'end') {
6963
+ cue.positionAlign = Cue.positionAlign.RIGHT;
6964
+ } else if (align == 'center' || align == 'middle') {
6965
+ cue.positionAlign = Cue.positionAlign.CENTER;
6966
+ } else {
6967
+ cue.positionAlign = Cue.positionAlign.AUTO;
6968
+ }
6969
+ }
6970
+ /**
6971
+ * @param {!shaka.text.Cue} cue
6972
+ * @param {string} value
6973
+ * @private
6974
+ */
6975
+
6976
+
6977
+ static setVerticalWritingMode_(cue, value) {
6978
+ const Cue = shaka.text.Cue;
6979
+
6980
+ if (value == 'lr') {
6981
+ cue.writingMode = Cue.writingMode.VERTICAL_LEFT_TO_RIGHT;
6982
+ } else {
6983
+ cue.writingMode = Cue.writingMode.VERTICAL_RIGHT_TO_LEFT;
6984
+ }
6985
+ }
6986
+ /**
6987
+ * @param {!shaka.text.Cue} cue
6988
+ * @param {string} word
6989
+ * @return {boolean}
6990
+ * @private
6991
+ */
6992
+
6993
+
6994
+ static parsedLineValueAndInterpretation_(cue, word) {
6995
+ const Cue = shaka.text.Cue;
6996
+ let results = null;
6997
+
6998
+ if (results = /^line:([\d.]+)%(?:,(start|end|center))?$/.exec(word)) {
6999
+ cue.lineInterpretation = Cue.lineInterpretation.PERCENTAGE;
7000
+ cue.line = Number(results[1]);
7001
+
7002
+ if (results[2]) {
7003
+ goog$1.asserts.assert(results[2].toUpperCase() in Cue.lineAlign, `${results[2].toUpperCase()} Should be in Cue.lineAlign values!`);
7004
+ cue.lineAlign = Cue.lineAlign[results[2].toUpperCase()];
7005
+ }
7006
+ } else if (results = /^line:(-?\d+)(?:,(start|end|center))?$/.exec(word)) {
7007
+ cue.lineInterpretation = Cue.lineInterpretation.LINE_NUMBER;
7008
+ cue.line = Number(results[1]);
7009
+
7010
+ if (results[2]) {
7011
+ goog$1.asserts.assert(results[2].toUpperCase() in Cue.lineAlign, `${results[2].toUpperCase()} Should be in Cue.lineAlign values!`);
7012
+ cue.lineAlign = Cue.lineAlign[results[2].toUpperCase()];
7013
+ }
7014
+ } else {
7015
+ return false;
7016
+ }
7017
+
7018
+ return true;
7019
+ }
7020
+
7021
+ }
7022
+ /**
7023
+ * @const {number}
7024
+ * @private
7025
+ */
7026
+
7027
+
7028
+ VttTextParser.MPEG_TIMESCALE_ = 90000;
7029
+ /**
7030
+ * At this value, timestamps roll over in TS content.
7031
+ * @const {number}
7032
+ * @private
7033
+ */
7034
+
7035
+ VttTextParser.TS_ROLLOVER_ = 0x200000000;
7036
+
7037
+ VttTextParser.register = shakaNameSpace => {
7038
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt', () => new VttTextParser());
7039
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt; codecs="vtt"', () => new VttTextParser());
7040
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt; codecs="wvtt"', () => new VttTextParser());
7041
+ };
7042
+
6395
7043
  /*! @license
6396
7044
  * Shaka Player
6397
7045
  * Copyright 2016 Google LLC
@@ -7281,9 +7929,13 @@ class UITextDisplayer {
7281
7929
  } else if (cue.textAlign == Cue.textAlign.RIGHT || cue.textAlign == Cue.textAlign.END) {
7282
7930
  style.width = '100%';
7283
7931
  style.alignItems = 'end';
7284
- }
7932
+ } // in VTT displayAlign can't be set, it defaults to 'after',
7933
+ // but for vertical, it should be 'before'
7285
7934
 
7286
- if (cue.displayAlign == Cue.displayAlign.BEFORE) {
7935
+
7936
+ if (/vertical/.test(cue.writingMode)) {
7937
+ style.justifyContent = 'flex-start';
7938
+ } else if (cue.displayAlign == Cue.displayAlign.BEFORE) {
7287
7939
  style.justifyContent = 'flex-start';
7288
7940
  } else if (cue.displayAlign == Cue.displayAlign.CENTER) {
7289
7941
  style.justifyContent = 'center';
@@ -7656,6 +8308,7 @@ const loadShaka = async (videoElement, config = {}, options = {}) => {
7656
8308
  return getQualityItem(activeTrack);
7657
8309
  };
7658
8310
 
8311
+ VttTextParser.register(shaka);
7659
8312
  HttpFetchPlugin.register(shaka);
7660
8313
  const networkEngine = player.getNetworkingEngine();
7661
8314
  networkEngine.registerRequestFilter((type, request) => extensionOptions.requestHandlers.reduce((merged, handler) => handler(type, merged, player, extensionOptions), request));