@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/react.mjs CHANGED
@@ -1992,7 +1992,7 @@ var ja = {
1992
1992
  "KKS.QUALITY": "解像度",
1993
1993
  "KKS.AUDIO": "音声",
1994
1994
  "KKS.SETTING.OFF": "オフ",
1995
- "KKS.SETTING.none": "オフ",
1995
+ "KKS.SETTING.none": "なし",
1996
1996
  "KKS.SETTING.ja": "日本語",
1997
1997
  "KKS.SETTING.en": "英語",
1998
1998
  "KKS.SUBTITLES": "字幕",
@@ -2420,7 +2420,7 @@ function convertToSeconds(timeString) {
2420
2420
  function getVersion() {
2421
2421
  try {
2422
2422
  // eslint-disable-next-line no-undef
2423
- return "2.25.0-canary.17";
2423
+ return "2.25.0-canary.19";
2424
2424
  } catch (e) {
2425
2425
  return undefined;
2426
2426
  }
@@ -2870,13 +2870,10 @@ const nativeTextStyle = {
2870
2870
  };
2871
2871
  const customTextStyle = {
2872
2872
  '.shaka-text-container': {
2873
+ boxSizing: 'border-box',
2873
2874
  padding: '2cqmin',
2874
2875
  font: '3cqmin/1 sans-serif',
2875
2876
  color: '#ffffff',
2876
- fontFamily: 'system-ui-monospaced',
2877
- 'unicode-bidi': 'plaintext',
2878
- 'overflow-wrap': 'break-word',
2879
- textWrap: 'balance',
2880
2877
  textShadow: '1px 1px 0.2cqmin #000'
2881
2878
  },
2882
2879
  '.shaka-text-container > .shaka-cue-horizontal-tb': {
@@ -6222,7 +6219,7 @@ const makeResponse = (headers, data, status, uri, responseURL, requestType) => {
6222
6219
  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);
6223
6220
  };
6224
6221
 
6225
- const goog$1 = {
6222
+ const goog$2 = {
6226
6223
  asserts: {
6227
6224
  assert: () => {}
6228
6225
  }
@@ -6368,7 +6365,7 @@ class HttpFetchPlugin {
6368
6365
  }
6369
6366
 
6370
6367
  if (readObj.done) {
6371
- goog$1.asserts.assert(!readObj.value, 'readObj should be unset when "done" is true.');
6368
+ goog$2.asserts.assert(!readObj.value, 'readObj should be unset when "done" is true.');
6372
6369
  controller.close();
6373
6370
  } else {
6374
6371
  controller.enqueue(readObj.value);
@@ -6607,6 +6604,664 @@ const fixDashManifest = (data, {
6607
6604
  return new XMLSerializer().serializeToString(doc);
6608
6605
  };
6609
6606
 
6607
+ /* eslint-disable no-cond-assign */
6608
+
6609
+ /* eslint-disable prefer-destructuring */
6610
+
6611
+ /*! @license
6612
+ * Shaka Player
6613
+ * Copyright 2016 Google LLC
6614
+ * SPDX-License-Identifier: Apache-2.0
6615
+ */
6616
+ const goog$1 = {
6617
+ asserts: {
6618
+ assert: (condition, message) => {
6619
+ if (!condition) {
6620
+ console.warn('GOOG Assert!', message);
6621
+ }
6622
+ }
6623
+ }
6624
+ };
6625
+
6626
+ const addDefaultTextColor = styles => {
6627
+ const textColor = shaka.text.Cue.defaultTextColor;
6628
+
6629
+ for (const [key, value] of Object.entries(textColor)) {
6630
+ const cue = new shaka.text.Cue(0, 0, '');
6631
+ cue.color = value;
6632
+ styles.set(`.${key}`, cue);
6633
+ }
6634
+
6635
+ const bgColor = shaka.text.Cue.defaultTextBackgroundColor;
6636
+
6637
+ for (const [key, value] of Object.entries(bgColor)) {
6638
+ const cue = new shaka.text.Cue(0, 0, '');
6639
+ cue.backgroundColor = value;
6640
+ styles.set(`.${key}`, cue);
6641
+ }
6642
+ };
6643
+
6644
+ const parseTime = text => {
6645
+ var _Array$from;
6646
+
6647
+ const timeFormat = /(?:(\d{1,}):)?(\d{2}):(\d{2})((\.(\d{1,3})))?/g;
6648
+ const results = (_Array$from = Array.from(text.matchAll(timeFormat))) === null || _Array$from === void 0 ? void 0 : _Array$from[0];
6649
+
6650
+ if (results == null) {
6651
+ return null;
6652
+ } // This capture is optional, but will still be in the array as undefined,
6653
+ // in which case it is 0.
6654
+
6655
+
6656
+ const hours = Number(results[1]) || 0;
6657
+ const minutes = Number(results[2]);
6658
+ const seconds = Number(results[3]);
6659
+ const milliseconds = Number(results[6]) || 0;
6660
+
6661
+ if (minutes > 59 || seconds > 59) {
6662
+ return null;
6663
+ }
6664
+
6665
+ return milliseconds / 1000 + seconds + minutes * 60 + hours * 3600;
6666
+ };
6667
+
6668
+ const parseRegion = block => {
6669
+ if (block[0].trim() !== 'REGION') {
6670
+ return [];
6671
+ }
6672
+
6673
+ const region = new shaka.text.CueRegion();
6674
+ block.slice(1).forEach(word => {
6675
+ let results = null;
6676
+
6677
+ if (results = /^id:(.*)$/.exec(word)) {
6678
+ region.id = results[1];
6679
+ } else if (results = /^width:(\d{1,2}|100)%$/.exec(word)) {
6680
+ region.width = Number(results[1]);
6681
+ } else if (results = /^lines:(\d+)$/.exec(word)) {
6682
+ region.height = Number(results[1]);
6683
+ region.heightUnits = shaka.text.CueRegion.units.LINES;
6684
+ } else if (results = /^regionanchor:(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(word)) {
6685
+ region.regionAnchorX = Number(results[1]);
6686
+ region.regionAnchorY = Number(results[2]);
6687
+ } else if (results = /^viewportanchor:(\d{1,2}|100)%,(\d{1,2}|100)%$/.exec(word)) {
6688
+ region.viewportAnchorX = Number(results[1]);
6689
+ region.viewportAnchorY = Number(results[2]);
6690
+ } else if (results = /^scroll:up$/.exec(word)) {
6691
+ region.scroll = shaka.text.CueRegion.scrollMode.UP;
6692
+ } else {
6693
+ shaka.log.warning('VTT parser encountered an invalid VTTRegion setting: ', word, ' The setting will be ignored.');
6694
+ }
6695
+ });
6696
+ return [region];
6697
+ };
6698
+ /**
6699
+ * @implements {shaka.extern.TextParser}
6700
+ * @export
6701
+ */
6702
+
6703
+
6704
+ class VttTextParser {
6705
+ /** Constructs a VTT parser. */
6706
+ constructor() {
6707
+ /** @private {boolean} */
6708
+ this.sequenceMode_ = false;
6709
+ /** @private {string} */
6710
+
6711
+ this.manifestType_ = shaka.media.ManifestParser.UNKNOWN;
6712
+ }
6713
+ /**
6714
+ * @override
6715
+ * @export
6716
+ */
6717
+
6718
+
6719
+ parseInit() {
6720
+ goog$1.asserts.assert(false, 'VTT does not have init segments');
6721
+ }
6722
+ /**
6723
+ * @override
6724
+ * @export
6725
+ */
6726
+
6727
+
6728
+ setSequenceMode(sequenceMode) {
6729
+ this.sequenceMode_ = sequenceMode;
6730
+ }
6731
+ /**
6732
+ * @override
6733
+ * @export
6734
+ */
6735
+
6736
+
6737
+ setManifestType(manifestType) {
6738
+ this.manifestType_ = manifestType;
6739
+ }
6740
+ /**
6741
+ * @override
6742
+ * @export
6743
+ */
6744
+
6745
+
6746
+ parseMedia(data, time) {
6747
+ // Get the input as a string. Normalize newlines to \n.
6748
+ let str = shaka.util.StringUtils.fromUTF8(data);
6749
+ str = str.replace(/\r\n|\r(?=[^\n]|$)/gm, '\n');
6750
+ const blocks = str.split(/\n{2,}/m);
6751
+
6752
+ if (!/^WEBVTT($|[ \t\n])/m.test(blocks[0])) {
6753
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
6754
+ } // Depending on "segmentRelativeVttTiming" configuration,
6755
+ // "vttOffset" will correspond to either "periodStart" (default)
6756
+ // or "segmentStart", for segmented VTT where timings are relative
6757
+ // to the beginning of each segment.
6758
+ // NOTE: "periodStart" is the timestamp offset applied via TextEngine.
6759
+ // It is no longer closely tied to periods, but the name stuck around.
6760
+ // NOTE: This offset and the flag choosing its meaning have no effect on
6761
+ // HLS content, which should use X-TIMESTAMP-MAP and periodStart instead.
6762
+
6763
+
6764
+ let offset = time.vttOffset;
6765
+
6766
+ if (this.manifestType_ == shaka.media.ManifestParser.HLS) {
6767
+ // Only use 'X-TIMESTAMP-MAP' with HLS.
6768
+ if (blocks[0].includes('X-TIMESTAMP-MAP')) {
6769
+ offset = this.computeHlsOffset_(blocks[0], time);
6770
+ } else if (time.periodStart && time.vttOffset == time.periodStart) {
6771
+ // In the case where X-TIMESTAMP-MAP is not used and it is HLS, we
6772
+ // should not use offset unless segment-relative times are used.
6773
+ offset = 0;
6774
+ }
6775
+ }
6776
+
6777
+ const regions = [];
6778
+ /** @type {!Map<string, !shaka.text.Cue>} */
6779
+
6780
+ const styles = new Map();
6781
+ addDefaultTextColor(styles); // Parse cues.
6782
+
6783
+ const ret = [];
6784
+
6785
+ for (const block of blocks.slice(1)) {
6786
+ const lines = block.split('\n');
6787
+ VttTextParser.parseStyle_(lines, styles);
6788
+ regions.push(...parseRegion(lines));
6789
+ const cue = VttTextParser.parseCue_(lines, offset, regions, styles);
6790
+
6791
+ if (cue) {
6792
+ ret.push(cue);
6793
+ }
6794
+ }
6795
+
6796
+ return ret;
6797
+ }
6798
+ /**
6799
+ * @param {string} headerBlock Contains X-TIMESTAMP-MAP.
6800
+ * @param {shaka.extern.TextParser.TimeContext} time
6801
+ * @return {number}
6802
+ * @private
6803
+ */
6804
+
6805
+
6806
+ computeHlsOffset_(headerBlock, time) {
6807
+ // https://bit.ly/2K92l7y
6808
+ // The 'X-TIMESTAMP-MAP' header is used in HLS to align text with
6809
+ // the rest of the media.
6810
+ // The header format is 'X-TIMESTAMP-MAP=MPEGTS:n,LOCAL:m'
6811
+ // (the attributes can go in any order)
6812
+ // where n is MPEG-2 time and m is cue time it maps to.
6813
+ // For example 'X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000'
6814
+ // means an offset of 10 seconds
6815
+ // 900000/MPEG_TIMESCALE - cue time.
6816
+ const cueTimeMatch = headerBlock.match(/LOCAL:((?:(\d{1,}):)?(\d{2}):(\d{2})\.(\d{3}))/m);
6817
+ const mpegTimeMatch = headerBlock.match(/MPEGTS:(\d+)/m);
6818
+
6819
+ if (!cueTimeMatch || !mpegTimeMatch) {
6820
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
6821
+ }
6822
+
6823
+ const cueTime = parseTime(cueTimeMatch[1]);
6824
+
6825
+ if (cueTime == null) {
6826
+ throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.TEXT, shaka.util.Error.Code.INVALID_TEXT_HEADER);
6827
+ }
6828
+
6829
+ let mpegTime = Number(mpegTimeMatch[1]);
6830
+ const mpegTimescale = VttTextParser.MPEG_TIMESCALE_;
6831
+ const rolloverSeconds = VttTextParser.TS_ROLLOVER_ / mpegTimescale;
6832
+ let segmentStart = time.segmentStart - time.periodStart;
6833
+
6834
+ while (segmentStart >= rolloverSeconds) {
6835
+ segmentStart -= rolloverSeconds;
6836
+ mpegTime += VttTextParser.TS_ROLLOVER_;
6837
+ }
6838
+
6839
+ return time.periodStart + mpegTime / mpegTimescale - cueTime;
6840
+ }
6841
+ /**
6842
+ * Parses a style block into a Cue object.
6843
+ *
6844
+ * @param {!Array<string>} text
6845
+ * @param {!Map<string, !shaka.text.Cue>} styles
6846
+ * @private
6847
+ */
6848
+
6849
+
6850
+ static parseStyle_(text, styles) {
6851
+ // Skip empty blocks.
6852
+ if (text.length == 1 && !text[0]) {
6853
+ return;
6854
+ } // Skip comment blocks.
6855
+
6856
+
6857
+ if (/^NOTE($|[ \t])/.test(text[0])) {
6858
+ return;
6859
+ } // Only style block are allowed.
6860
+
6861
+
6862
+ if (text[0] != 'STYLE') {
6863
+ return;
6864
+ }
6865
+ /** @type {!Array<!Array<string>>} */
6866
+
6867
+
6868
+ const styleBlocks = [];
6869
+ let lastBlockIndex = -1;
6870
+
6871
+ for (let i = 1; i < text.length; i++) {
6872
+ if (text[i].includes('::cue')) {
6873
+ styleBlocks.push([]);
6874
+ lastBlockIndex = styleBlocks.length - 1;
6875
+ }
6876
+
6877
+ if (lastBlockIndex == -1) {
6878
+ continue;
6879
+ }
6880
+
6881
+ styleBlocks[lastBlockIndex].push(text[i]);
6882
+
6883
+ if (text[i].includes('}')) {
6884
+ lastBlockIndex = -1;
6885
+ }
6886
+ }
6887
+
6888
+ for (const styleBlock of styleBlocks) {
6889
+ let styleSelector = 'global'; // Look for what is within parentheses. For example:
6890
+ // <code>:: cue (b) {</code>, what we are looking for is <code>b</code>
6891
+
6892
+ const selector = styleBlock[0].match(/\((.*)\)/);
6893
+
6894
+ if (selector) {
6895
+ styleSelector = selector.pop();
6896
+ } // We start at 1 to avoid '::cue' and end earlier to avoid '}'
6897
+
6898
+
6899
+ let propertyLines = styleBlock.slice(1, -1);
6900
+
6901
+ if (styleBlock[0].includes('}')) {
6902
+ const payload = /\{(.*?)\}/.exec(styleBlock[0]);
6903
+
6904
+ if (payload) {
6905
+ propertyLines = payload[1].split(';');
6906
+ }
6907
+ } // Continue styles over multiple selectors if necessary.
6908
+ // For example,
6909
+ // ::cue(b) { background: white; } ::cue(b) { color: blue; }
6910
+ // should set both the background and foreground of bold tags.
6911
+
6912
+
6913
+ let cue = styles.get(styleSelector);
6914
+
6915
+ if (!cue) {
6916
+ cue = new shaka.text.Cue(0, 0, '');
6917
+ }
6918
+
6919
+ let validStyle = false;
6920
+
6921
+ for (let i = 0; i < propertyLines.length; i++) {
6922
+ // We look for CSS properties. As a general rule they are separated by
6923
+ // <code>:</code>. Eg: <code>color: red;</code>
6924
+ const lineParts = /^\s*([^:]+):\s*(.*)/.exec(propertyLines[i]);
6925
+
6926
+ if (lineParts) {
6927
+ const name = lineParts[1].trim();
6928
+ const value = lineParts[2].trim().replace(';', '');
6929
+
6930
+ switch (name) {
6931
+ case 'background-color':
6932
+ case 'background':
6933
+ validStyle = true;
6934
+ cue.backgroundColor = value;
6935
+ break;
6936
+
6937
+ case 'color':
6938
+ validStyle = true;
6939
+ cue.color = value;
6940
+ break;
6941
+
6942
+ case 'font-family':
6943
+ validStyle = true;
6944
+ cue.fontFamily = value;
6945
+ break;
6946
+
6947
+ case 'font-size':
6948
+ validStyle = true;
6949
+ cue.fontSize = value;
6950
+ break;
6951
+
6952
+ case 'font-weight':
6953
+ if (parseInt(value, 10) >= 700 || value == 'bold') {
6954
+ validStyle = true;
6955
+ cue.fontWeight = shaka.text.Cue.fontWeight.BOLD;
6956
+ }
6957
+
6958
+ break;
6959
+
6960
+ case 'font-style':
6961
+ switch (value) {
6962
+ case 'normal':
6963
+ validStyle = true;
6964
+ cue.fontStyle = shaka.text.Cue.fontStyle.NORMAL;
6965
+ break;
6966
+
6967
+ case 'italic':
6968
+ validStyle = true;
6969
+ cue.fontStyle = shaka.text.Cue.fontStyle.ITALIC;
6970
+ break;
6971
+
6972
+ case 'oblique':
6973
+ validStyle = true;
6974
+ cue.fontStyle = shaka.text.Cue.fontStyle.OBLIQUE;
6975
+ break;
6976
+ }
6977
+
6978
+ break;
6979
+
6980
+ case 'opacity':
6981
+ validStyle = true;
6982
+ cue.opacity = parseFloat(value);
6983
+ break;
6984
+
6985
+ case 'text-combine-upright':
6986
+ validStyle = true;
6987
+ cue.textCombineUpright = value;
6988
+ break;
6989
+
6990
+ case 'text-shadow':
6991
+ validStyle = true;
6992
+ cue.textShadow = value;
6993
+ break;
6994
+
6995
+ case 'white-space':
6996
+ validStyle = true;
6997
+ cue.wrapLine = value != 'noWrap';
6998
+ break;
6999
+
7000
+ default:
7001
+ shaka.log.warning('VTT parser encountered an unsupported style: ', lineParts);
7002
+ break;
7003
+ }
7004
+ }
7005
+ }
7006
+
7007
+ if (validStyle) {
7008
+ styles.set(styleSelector, cue);
7009
+ }
7010
+ }
7011
+ }
7012
+ /**
7013
+ * Parses a text block into a Cue object.
7014
+ *
7015
+ * @param {!Array<string>} text
7016
+ * @param {number} timeOffset
7017
+ * @param {!Array<!shaka.text.CueRegion>} regions
7018
+ * @param {!Map<string, !shaka.text.Cue>} styles
7019
+ * @return {shaka.text.Cue}
7020
+ * @private
7021
+ */
7022
+
7023
+
7024
+ static parseCue_(text, timeOffset, regions, styles) {
7025
+ // Skip empty blocks.
7026
+ if (text.length == 1 && !text[0]) {
7027
+ return null;
7028
+ } // Skip comment blocks.
7029
+
7030
+
7031
+ if (/^NOTE($|[ \t])/.test(text[0])) {
7032
+ return null;
7033
+ } // Skip style and region blocks.
7034
+
7035
+
7036
+ if (text[0] == 'STYLE' || text[0] == 'REGION') {
7037
+ return null;
7038
+ }
7039
+
7040
+ const skipIndex = text.findIndex(line => /^#/.test(line.trim()));
7041
+
7042
+ if (skipIndex > 0) {
7043
+ text = text.slice(skipIndex);
7044
+ }
7045
+
7046
+ if (text.length < 2) {
7047
+ return;
7048
+ }
7049
+
7050
+ let id = null;
7051
+
7052
+ if (!text[0].includes('-->')) {
7053
+ id = text[0];
7054
+ text.splice(0, 1);
7055
+ } // Parse the times.
7056
+
7057
+
7058
+ let [start, end] = text[0].split('-->').map(part => parseTime(part.trim()));
7059
+
7060
+ if (start == null || end == null) {
7061
+ shaka.log.alwaysWarn('Failed to parse VTT time code. Cue skipped:', id, text);
7062
+ return null;
7063
+ }
7064
+
7065
+ start += timeOffset;
7066
+ end += timeOffset; // Get the payload.
7067
+
7068
+ const payload = text.slice(1).join('\n').trim();
7069
+ let cue = null;
7070
+
7071
+ if (styles.has('global')) {
7072
+ cue = styles.get('global').clone();
7073
+ cue.startTime = start;
7074
+ cue.endTime = end;
7075
+ cue.payload = payload;
7076
+ } else {
7077
+ cue = new shaka.text.Cue(start, end, payload);
7078
+ } // Parse optional settings.
7079
+
7080
+
7081
+ text[0].split(/\s+/g).slice(3).forEach(word => {
7082
+ if (!word.trim()) {
7083
+ return;
7084
+ }
7085
+
7086
+ if (!VttTextParser.parseCueSetting(cue, word, regions)) {
7087
+ shaka.log.warning('VTT parser encountered an invalid VTT setting: ', word, ' The setting will be ignored.');
7088
+ }
7089
+ });
7090
+ shaka.text.Cue.parseCuePayload(cue, styles);
7091
+
7092
+ if (id != null) {
7093
+ cue.id = id;
7094
+ }
7095
+
7096
+ return cue;
7097
+ }
7098
+ /**
7099
+ * Parses a WebVTT setting from the given word.
7100
+ *
7101
+ * @param {!shaka.text.Cue} cue
7102
+ * @param {string} word
7103
+ * @param {!Array<!shaka.text.CueRegion>} regions
7104
+ * @return {boolean} True on success.
7105
+ */
7106
+
7107
+
7108
+ static parseCueSetting(cue, word, regions) {
7109
+ let results = null;
7110
+
7111
+ if (results = /^align:(start|middle|center|end|left|right)$/.exec(word)) {
7112
+ VttTextParser.setTextAlign_(cue, results[1]);
7113
+ } else if (results = /^vertical:(lr|rl)$/.exec(word)) {
7114
+ VttTextParser.setVerticalWritingMode_(cue, results[1]);
7115
+ } else if (results = /^size:([\d.]+)%$/.exec(word)) {
7116
+ cue.size = Number(results[1]);
7117
+ } else if (results = /^position:([\d.]+)%(?:,(line-left|line-right|middle|center|start|end|auto))?$/.exec(word)) {
7118
+ cue.position = Number(results[1]);
7119
+
7120
+ if (results[2]) {
7121
+ VttTextParser.setPositionAlign_(cue, results[2]);
7122
+ }
7123
+ } else if (results = /^region:(.*)$/.exec(word)) {
7124
+ const region = VttTextParser.getRegionById_(regions, results[1]);
7125
+
7126
+ if (region) {
7127
+ cue.region = region;
7128
+ }
7129
+ } else {
7130
+ return VttTextParser.parsedLineValueAndInterpretation_(cue, word);
7131
+ }
7132
+
7133
+ return true;
7134
+ }
7135
+ /**
7136
+ *
7137
+ * @param {!Array<!shaka.text.CueRegion>} regions
7138
+ * @param {string} id
7139
+ * @return {?shaka.text.CueRegion}
7140
+ * @private
7141
+ */
7142
+
7143
+
7144
+ static getRegionById_(regions, id) {
7145
+ const regionsWithId = regions.filter(region => region.id == id);
7146
+
7147
+ if (!regionsWithId.length) {
7148
+ shaka.log.warning('VTT parser could not find a region with id: ', id, ' The region will be ignored.');
7149
+ return null;
7150
+ }
7151
+
7152
+ goog$1.asserts.assert(regionsWithId.length == 1, 'VTTRegion ids should be unique!');
7153
+ return regionsWithId[0];
7154
+ }
7155
+ /**
7156
+ * @param {!shaka.text.Cue} cue
7157
+ * @param {string} align
7158
+ * @private
7159
+ */
7160
+
7161
+
7162
+ static setTextAlign_(cue, align) {
7163
+ const Cue = shaka.text.Cue;
7164
+
7165
+ if (align == 'middle') {
7166
+ cue.textAlign = Cue.textAlign.CENTER;
7167
+ } else {
7168
+ goog$1.asserts.assert(align.toUpperCase() in Cue.textAlign, `${align.toUpperCase()} Should be in Cue.textAlign values!`);
7169
+ cue.textAlign = Cue.textAlign[align.toUpperCase()];
7170
+ }
7171
+ }
7172
+ /**
7173
+ * @param {!shaka.text.Cue} cue
7174
+ * @param {string} align
7175
+ * @private
7176
+ */
7177
+
7178
+
7179
+ static setPositionAlign_(cue, align) {
7180
+ const Cue = shaka.text.Cue;
7181
+
7182
+ if (align == 'line-left' || align == 'start') {
7183
+ cue.positionAlign = Cue.positionAlign.LEFT;
7184
+ } else if (align == 'line-right' || align == 'end') {
7185
+ cue.positionAlign = Cue.positionAlign.RIGHT;
7186
+ } else if (align == 'center' || align == 'middle') {
7187
+ cue.positionAlign = Cue.positionAlign.CENTER;
7188
+ } else {
7189
+ cue.positionAlign = Cue.positionAlign.AUTO;
7190
+ }
7191
+ }
7192
+ /**
7193
+ * @param {!shaka.text.Cue} cue
7194
+ * @param {string} value
7195
+ * @private
7196
+ */
7197
+
7198
+
7199
+ static setVerticalWritingMode_(cue, value) {
7200
+ const Cue = shaka.text.Cue;
7201
+
7202
+ if (value == 'lr') {
7203
+ cue.writingMode = Cue.writingMode.VERTICAL_LEFT_TO_RIGHT;
7204
+ } else {
7205
+ cue.writingMode = Cue.writingMode.VERTICAL_RIGHT_TO_LEFT;
7206
+ }
7207
+ }
7208
+ /**
7209
+ * @param {!shaka.text.Cue} cue
7210
+ * @param {string} word
7211
+ * @return {boolean}
7212
+ * @private
7213
+ */
7214
+
7215
+
7216
+ static parsedLineValueAndInterpretation_(cue, word) {
7217
+ const Cue = shaka.text.Cue;
7218
+ let results = null;
7219
+
7220
+ if (results = /^line:([\d.]+)%(?:,(start|end|center))?$/.exec(word)) {
7221
+ cue.lineInterpretation = Cue.lineInterpretation.PERCENTAGE;
7222
+ cue.line = Number(results[1]);
7223
+
7224
+ if (results[2]) {
7225
+ goog$1.asserts.assert(results[2].toUpperCase() in Cue.lineAlign, `${results[2].toUpperCase()} Should be in Cue.lineAlign values!`);
7226
+ cue.lineAlign = Cue.lineAlign[results[2].toUpperCase()];
7227
+ }
7228
+ } else if (results = /^line:(-?\d+)(?:,(start|end|center))?$/.exec(word)) {
7229
+ cue.lineInterpretation = Cue.lineInterpretation.LINE_NUMBER;
7230
+ cue.line = Number(results[1]);
7231
+
7232
+ if (results[2]) {
7233
+ goog$1.asserts.assert(results[2].toUpperCase() in Cue.lineAlign, `${results[2].toUpperCase()} Should be in Cue.lineAlign values!`);
7234
+ cue.lineAlign = Cue.lineAlign[results[2].toUpperCase()];
7235
+ }
7236
+ } else {
7237
+ return false;
7238
+ }
7239
+
7240
+ return true;
7241
+ }
7242
+
7243
+ }
7244
+ /**
7245
+ * @const {number}
7246
+ * @private
7247
+ */
7248
+
7249
+
7250
+ VttTextParser.MPEG_TIMESCALE_ = 90000;
7251
+ /**
7252
+ * At this value, timestamps roll over in TS content.
7253
+ * @const {number}
7254
+ * @private
7255
+ */
7256
+
7257
+ VttTextParser.TS_ROLLOVER_ = 0x200000000;
7258
+
7259
+ VttTextParser.register = shakaNameSpace => {
7260
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt', () => new VttTextParser());
7261
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt; codecs="vtt"', () => new VttTextParser());
7262
+ shakaNameSpace.text.TextEngine.registerParser('text/vtt; codecs="wvtt"', () => new VttTextParser());
7263
+ };
7264
+
6610
7265
  /*! @license
6611
7266
  * Shaka Player
6612
7267
  * Copyright 2016 Google LLC
@@ -7496,9 +8151,13 @@ class UITextDisplayer {
7496
8151
  } else if (cue.textAlign == Cue.textAlign.RIGHT || cue.textAlign == Cue.textAlign.END) {
7497
8152
  style.width = '100%';
7498
8153
  style.alignItems = 'end';
7499
- }
8154
+ } // in VTT displayAlign can't be set, it defaults to 'after',
8155
+ // but for vertical, it should be 'before'
8156
+
7500
8157
 
7501
- if (cue.displayAlign == Cue.displayAlign.BEFORE) {
8158
+ if (/vertical/.test(cue.writingMode)) {
8159
+ style.justifyContent = 'flex-start';
8160
+ } else if (cue.displayAlign == Cue.displayAlign.BEFORE) {
7502
8161
  style.justifyContent = 'flex-start';
7503
8162
  } else if (cue.displayAlign == Cue.displayAlign.CENTER) {
7504
8163
  style.justifyContent = 'center';
@@ -7871,6 +8530,7 @@ const loadShaka = async (videoElement, config = {}, options = {}) => {
7871
8530
  return getQualityItem(activeTrack);
7872
8531
  };
7873
8532
 
8533
+ VttTextParser.register(shaka);
7874
8534
  HttpFetchPlugin.register(shaka);
7875
8535
  const networkEngine = player.getNetworkingEngine();
7876
8536
  networkEngine.registerRequestFilter((type, request) => extensionOptions.requestHandlers.reduce((merged, handler) => handler(type, merged, player, extensionOptions), request));
@@ -8418,11 +9078,26 @@ const getSettingsData = ({
8418
9078
  const matchTracks = (tracks, sorted) => {
8419
9079
  var _tracks$;
8420
9080
 
8421
- return ((_tracks$ = tracks[0]) === null || _tracks$ === void 0 ? void 0 : _tracks$.type) === 'audio' && (sorted === null || sorted === void 0 ? void 0 : sorted.length) === 1 ? [{ ...tracks[0],
8422
- ...sorted[0]
8423
- }] : (sorted === null || sorted === void 0 ? void 0 : sorted.map(track => ({ ...tracks.find(t => t.language === track.language),
8424
- ...track
8425
- })).filter(Boolean)) || tracks;
9081
+ const lookup = {};
9082
+ tracks.forEach(track => {
9083
+ lookup[`${track.language}|${track.label}`] = track;
9084
+ lookup[`${track.language}|`] = track;
9085
+ lookup[`|${track.label}`] = track;
9086
+ });
9087
+ const matched = sorted.map(info => {
9088
+ const track = lookup[`${info.language}|${info.label}`] || lookup[`${info.language}|`];
9089
+ return track && { ...track,
9090
+ ...info
9091
+ };
9092
+ }).filter(Boolean);
9093
+
9094
+ if (((_tracks$ = tracks[0]) === null || _tracks$ === void 0 ? void 0 : _tracks$.type) === 'audio' && matched.length === 0) {
9095
+ return [{ ...tracks[0],
9096
+ ...sorted[0]
9097
+ }];
9098
+ }
9099
+
9100
+ return matched;
8426
9101
  };
8427
9102
 
8428
9103
  const getLanguageOptions = (player, sorted) => {
@@ -11158,7 +11833,7 @@ const PremiumPlusPlayer = ({
11158
11833
  const restPlayerName = ['shaka', 'bitmovin'].find(name => name in rest);
11159
11834
  logTarget.current = mapLogEvents({
11160
11835
  playerName: restPlayerName || 'shaka',
11161
- version: "2.25.0-canary.17",
11836
+ version: "2.25.0-canary.19",
11162
11837
  video: videoRef.current,
11163
11838
  getPlaybackStatus: () => getMediaTime(videoRef.current, {
11164
11839
  player: corePlayerRef.current,