shaka-player 4.3.3 → 4.3.4

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.
@@ -102,11 +102,23 @@ shaka.dash.SegmentTemplate = class {
102
102
  const periodEnd = context.periodInfo.duration ?
103
103
  context.periodInfo.start + context.periodInfo.duration : Infinity;
104
104
 
105
- // Don't fit live content, since it might receive more segments.
106
- // Unless that live content is multi-period; it's safe to fit every period
107
- // but the last one, since only the last period might receive new
108
- // segments.
109
- const shouldFit = periodEnd != Infinity;
105
+ /* When to fit segments. All refactors should honor/update this table:
106
+ *
107
+ * | dynamic | infinite | last | should | notes |
108
+ * | | period | period | fit | |
109
+ * | ------- | -------- | ------ | ------ | ------------------------- |
110
+ * | F | F | X | T | typical VOD |
111
+ * | F | T | X | X | impossible: infinite VOD |
112
+ * | T | F | F | T | typical live, old period |
113
+ * | T | F | T | F | typical IPR |
114
+ * | T | T | F | X | impossible: old, infinite |
115
+ * | T | T | T | F | typical live, new period |
116
+ */
117
+
118
+ // We never fit the final period of dynamic content, which could be
119
+ // infinite live (with no limit to fit to) or IPR (which would expand the
120
+ // most recent segment to the end of the presentation).
121
+ const shouldFit = !(context.dynamic && context.periodInfo.isLastPeriod);
110
122
 
111
123
  if (segmentIndex) {
112
124
  if (shouldFit) {
@@ -945,6 +945,8 @@ shaka.hls.HlsParser = class {
945
945
  }
946
946
  });
947
947
 
948
+ const type = shaka.util.ManifestParserUtils.ContentType.TEXT;
949
+
948
950
  // Set the codecs for text streams.
949
951
  for (const tag of subtitleTags) {
950
952
  const groupId = tag.getRequiredAttrValue('GROUP-ID');
@@ -954,6 +956,9 @@ shaka.hls.HlsParser = class {
954
956
  if (textStreamInfos) {
955
957
  for (const textStreamInfo of textStreamInfos) {
956
958
  textStreamInfo.stream.codecs = codecs;
959
+ textStreamInfo.stream.mimeType =
960
+ this.guessMimeTypeBeforeLoading_(type, codecs) ||
961
+ this.guessMimeTypeFallback_(type);
957
962
  }
958
963
  }
959
964
  }
@@ -3342,7 +3347,7 @@ shaka.hls.HlsParser.TEXT_EXTENSIONS_TO_MIME_TYPES_ = {
3342
3347
  'm4f': 'application/mp4',
3343
3348
  'cmft': 'application/mp4',
3344
3349
  'vtt': 'text/vtt',
3345
- 'webvtt': 'txt/vtt',
3350
+ 'webvtt': 'text/vtt',
3346
3351
  'ttml': 'application/ttml+xml',
3347
3352
  };
3348
3353
 
package/lib/player.js CHANGED
@@ -6984,7 +6984,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
6984
6984
  * @define {string} A version number taken from git at compile time.
6985
6985
  * @export
6986
6986
  */
6987
- shaka.Player.version = 'v4.3.3-uncompiled';
6987
+ shaka.Player.version = 'v4.3.4-uncompiled';
6988
6988
 
6989
6989
  // Initialize the deprecation system using the version string we just set
6990
6990
  // on the player.
@@ -48,6 +48,8 @@ shaka.polyfill.MediaCapabilities = class {
48
48
  // should always install polyfill for WebOS browsers.
49
49
  // Since MediaCapabilities implementation is buggy in EOS browsers, we
50
50
  // should always install polyfill for EOS browsers.
51
+ // Since MediaCapabilities implementation is buggy in Hisense browsers, we
52
+ // should always install polyfill for Hisense browsers.
51
53
  let canUseNativeMCap = true;
52
54
  if (shaka.util.Platform.isApple() ||
53
55
  shaka.util.Platform.isPS5() ||
@@ -55,7 +57,8 @@ shaka.polyfill.MediaCapabilities = class {
55
57
  shaka.util.Platform.isWebOS() ||
56
58
  shaka.util.Platform.isTizen() ||
57
59
  shaka.util.Platform.isChromecast() ||
58
- shaka.util.Platform.isEOS()) {
60
+ shaka.util.Platform.isEOS() ||
61
+ shaka.util.Platform.isHisense()) {
59
62
  canUseNativeMCap = false;
60
63
  }
61
64
  if (canUseNativeMCap && navigator.mediaCapabilities) {
@@ -14,6 +14,7 @@ goog.provide('shaka.text.SimpleTextDisplayer');
14
14
  goog.require('goog.asserts');
15
15
  goog.require('shaka.log');
16
16
  goog.require('shaka.text.Cue');
17
+ goog.require('shaka.text.Utils');
17
18
 
18
19
 
19
20
  /**
@@ -79,70 +80,7 @@ shaka.text.SimpleTextDisplayer = class {
79
80
  * @export
80
81
  */
81
82
  append(cues) {
82
- // Flatten nested cue payloads recursively. If a cue has nested cues,
83
- // their contents should be combined and replace the payload of the parent.
84
- const flattenPayload = (cue) => {
85
- // Handle styles (currently bold/italics/underline).
86
- // TODO add support for color rendering.
87
- const openStyleTags = [];
88
- const bold = cue.fontWeight >= shaka.text.Cue.fontWeight.BOLD;
89
- const italics = cue.fontStyle == shaka.text.Cue.fontStyle.ITALIC;
90
- const underline = cue.textDecoration.includes(
91
- shaka.text.Cue.textDecoration.UNDERLINE);
92
- if (bold) {
93
- openStyleTags.push('b');
94
- }
95
- if (italics) {
96
- openStyleTags.push('i');
97
- }
98
- if (underline) {
99
- openStyleTags.push('u');
100
- }
101
-
102
- // Prefix opens tags, suffix closes tags in reverse order of opening.
103
- const prefixStyleTags = openStyleTags.reduce((acc, tag) => {
104
- return `${acc}<${tag}>`;
105
- }, '');
106
- const suffixStyleTags = openStyleTags.reduceRight((acc, tag) => {
107
- return `${acc}</${tag}>`;
108
- }, '');
109
-
110
- if (cue.lineBreak) {
111
- // This is a vertical lineBreak, so insert a newline.
112
- return '\n';
113
- } else if (cue.nestedCues.length) {
114
- return cue.nestedCues.map(flattenPayload).join('');
115
- } else {
116
- // This is a real cue.
117
- return prefixStyleTags + cue.payload + suffixStyleTags;
118
- }
119
- };
120
-
121
- // We don't want to modify the array or objects passed in, since we don't
122
- // technically own them. So we build a new array and replace certain items
123
- // in it if they need to be flattened.
124
- // We also don't want to flatten the text payloads starting at a container
125
- // element; otherwise, for containers encapsulating multiple caption lines,
126
- // the lines would merge into a single cue. This is undesirable when a
127
- // subset of the captions are outside of the append time window. To fix
128
- // this, we only call flattenPayload() starting at elements marked as
129
- // isContainer = false.
130
- const getCuesToFlatten = (cues, result) => {
131
- for (const cue of cues) {
132
- if (cue.isContainer) {
133
- // Recurse to find the actual text payload cues.
134
- getCuesToFlatten(cue.nestedCues, result);
135
- } else {
136
- // Flatten the payload.
137
- const flatCue = cue.clone();
138
- flatCue.nestedCues = [];
139
- flatCue.payload = flattenPayload(cue);
140
- result.push(flatCue);
141
- }
142
- }
143
- return result;
144
- };
145
- const flattenedCues = getCuesToFlatten(cues, []);
83
+ const flattenedCues = shaka.text.Utils.getCuesToFlatten(cues, []);
146
84
 
147
85
  // Convert cues.
148
86
  const textTrackCues = [];
@@ -0,0 +1,88 @@
1
+ /*! @license
2
+ * Shaka Player
3
+ * Copyright 2016 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ goog.provide('shaka.text.Utils');
8
+
9
+ goog.require('shaka.text.Cue');
10
+
11
+
12
+ shaka.text.Utils = class {
13
+ /**
14
+ * Flatten nested cue payloads recursively. If a cue has nested cues,
15
+ * their contents should be combined and replace the payload of the parent.
16
+ *
17
+ * @param {!shaka.text.Cue} cue
18
+ * @return {string}
19
+ * @private
20
+ */
21
+ static flattenPayload_(cue) {
22
+ // Handle styles (currently bold/italics/underline).
23
+ // TODO: add support for color rendering.
24
+ const openStyleTags = [];
25
+ const bold = cue.fontWeight >= shaka.text.Cue.fontWeight.BOLD;
26
+ const italics = cue.fontStyle == shaka.text.Cue.fontStyle.ITALIC;
27
+ const underline = cue.textDecoration.includes(
28
+ shaka.text.Cue.textDecoration.UNDERLINE);
29
+ if (bold) {
30
+ openStyleTags.push('b');
31
+ }
32
+ if (italics) {
33
+ openStyleTags.push('i');
34
+ }
35
+ if (underline) {
36
+ openStyleTags.push('u');
37
+ }
38
+
39
+ // Prefix opens tags, suffix closes tags in reverse order of opening.
40
+ const prefixStyleTags = openStyleTags.reduce((acc, tag) => {
41
+ return `${acc}<${tag}>`;
42
+ }, '');
43
+ const suffixStyleTags = openStyleTags.reduceRight((acc, tag) => {
44
+ return `${acc}</${tag}>`;
45
+ }, '');
46
+
47
+ if (cue.lineBreak) {
48
+ // This is a vertical lineBreak, so insert a newline.
49
+ return '\n';
50
+ } else if (cue.nestedCues.length) {
51
+ return cue.nestedCues.map(shaka.text.Utils.flattenPayload_).join('');
52
+ } else {
53
+ // This is a real cue.
54
+ return prefixStyleTags + cue.payload + suffixStyleTags;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * We don't want to modify the array or objects passed in, since we don't
60
+ * technically own them. So we build a new array and replace certain items
61
+ * in it if they need to be flattened.
62
+ * We also don't want to flatten the text payloads starting at a container
63
+ * element; otherwise, for containers encapsulating multiple caption lines,
64
+ * the lines would merge into a single cue. This is undesirable when a
65
+ * subset of the captions are outside of the append time window. To fix
66
+ * this, we only call flattenPayload() starting at elements marked as
67
+ * isContainer = false.
68
+ *
69
+ * @param {!Array.<!shaka.text.Cue>} cues
70
+ * @param {!Array.<!shaka.text.Cue>} result
71
+ * @return {!Array.<!shaka.text.Cue>}
72
+ */
73
+ static getCuesToFlatten(cues, result) {
74
+ for (const cue of cues) {
75
+ if (cue.isContainer) {
76
+ // Recurse to find the actual text payload cues.
77
+ shaka.text.Utils.getCuesToFlatten(cue.nestedCues, result);
78
+ } else {
79
+ // Flatten the payload.
80
+ const flatCue = cue.clone();
81
+ flatCue.nestedCues = [];
82
+ flatCue.payload = shaka.text.Utils.flattenPayload_(cue);
83
+ result.push(flatCue);
84
+ }
85
+ }
86
+ return result;
87
+ }
88
+ };
@@ -617,12 +617,7 @@ shaka.text.UITextDisplayer = class {
617
617
  // TODO: Implement lineAlignment of 'CENTER'.
618
618
  if (cue.line != null) {
619
619
  if (cue.lineInterpretation == Cue.lineInterpretation.PERCENTAGE) {
620
- // When setting absolute positioning, you need to set x/y/width/height
621
- // so the element is positioned correctly. Set these as default and
622
- // other settings will override them.
623
620
  style.position = 'absolute';
624
- style.left = '0';
625
- style.top = '0';
626
621
  if (cue.writingMode == Cue.writingMode.HORIZONTAL_TOP_TO_BOTTOM) {
627
622
  style.width = '100%';
628
623
  if (cue.lineAlign == Cue.lineAlign.START) {