shaka-player 3.1.4 → 3.1.5
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/CHANGELOG.md +39 -0
- package/dist/controls.css +2 -2
- package/dist/controls.css.map +1 -1
- package/dist/locales.js +29 -29
- package/dist/shaka-player.compiled.d.ts +14 -0
- package/dist/shaka-player.compiled.debug.d.ts +14 -0
- package/dist/shaka-player.compiled.debug.externs.js +11 -0
- package/dist/shaka-player.compiled.debug.js +170 -168
- package/dist/shaka-player.compiled.debug.map +3 -3
- package/dist/shaka-player.compiled.externs.js +11 -0
- package/dist/shaka-player.compiled.js +650 -650
- package/dist/shaka-player.compiled.map +2 -2
- package/dist/shaka-player.ui.d.ts +14 -0
- package/dist/shaka-player.ui.debug.d.ts +14 -0
- package/dist/shaka-player.ui.debug.externs.js +11 -0
- package/dist/shaka-player.ui.debug.js +178 -176
- package/dist/shaka-player.ui.debug.map +3 -3
- package/dist/shaka-player.ui.externs.js +11 -0
- package/dist/shaka-player.ui.js +792 -792
- package/dist/shaka-player.ui.map +2 -2
- package/externs/shaka/text.js +10 -0
- package/lib/dash/dash_parser.js +4 -2
- package/lib/media/streaming_engine.js +5 -2
- package/lib/player.js +1 -1
- package/lib/polyfill/media_capabilities.js +30 -15
- package/lib/text/cue.js +6 -0
- package/lib/text/ttml_text_parser.js +84 -58
- package/lib/text/ui_text_displayer.js +17 -11
- package/lib/util/stream_utils.js +58 -7
- package/lib/util/xml_utils.js +19 -0
- package/package.json +2 -2
- package/test/dash/dash_parser_manifest_unit.js +33 -1
- package/test/media/drm_engine_unit.js +3 -3
- package/test/media/streaming_engine_integration.js +2 -1
- package/test/media/streaming_engine_unit.js +145 -0
- package/test/player_unit.js +5 -5
- package/test/test/util/ttml_utils.js +81 -0
- package/test/text/mp4_ttml_parser_unit.js +11 -18
- package/test/text/ttml_text_parser_unit.js +495 -228
- package/test/util/stream_utils_unit.js +35 -29
- package/ui/less/buttons.less +0 -4
- package/ui/text_selection.js +1 -0
- package/externs/media_capabilities.js +0 -16
package/externs/shaka/text.js
CHANGED
|
@@ -349,6 +349,16 @@ shaka.extern.Cue = class {
|
|
|
349
349
|
*/
|
|
350
350
|
this.nestedCues;
|
|
351
351
|
|
|
352
|
+
/**
|
|
353
|
+
* If true, this represents a container element that is "above" the main
|
|
354
|
+
* cues. For example, the <body> and <div> tags that contain the <p> tags
|
|
355
|
+
* in a TTML file. This controls the flow of the final cues; any nested cues
|
|
356
|
+
* within an "isContainer" cue will be laid out as separate lines.
|
|
357
|
+
* @type {boolean}
|
|
358
|
+
* @exportDoc
|
|
359
|
+
*/
|
|
360
|
+
this.isContainer;
|
|
361
|
+
|
|
352
362
|
/**
|
|
353
363
|
* Whether or not the cue only acts as a line break between two nested cues.
|
|
354
364
|
* Should only appear in nested cues.
|
package/lib/dash/dash_parser.js
CHANGED
|
@@ -1215,8 +1215,10 @@ shaka.dash.DashParser = class {
|
|
|
1215
1215
|
|
|
1216
1216
|
let forced = false;
|
|
1217
1217
|
if (isText) {
|
|
1218
|
-
// See: https://github.com/google/shaka-player/issues/2122
|
|
1219
|
-
|
|
1218
|
+
// See: https://github.com/google/shaka-player/issues/2122 and
|
|
1219
|
+
// https://github.com/Dash-Industry-Forum/DASH-IF-IOP/issues/165
|
|
1220
|
+
forced = roles.includes('forced_subtitle') ||
|
|
1221
|
+
roles.includes('forced-subtitle');
|
|
1220
1222
|
}
|
|
1221
1223
|
|
|
1222
1224
|
let tilesLayout;
|
|
@@ -623,7 +623,7 @@ shaka.media.StreamingEngine = class {
|
|
|
623
623
|
|
|
624
624
|
// Don't clear the buffer unless something is buffered. This extra
|
|
625
625
|
// check prevents extra, useless calls to clear the buffer.
|
|
626
|
-
if (somethingBuffered) {
|
|
626
|
+
if (somethingBuffered || mediaState.performingUpdate) {
|
|
627
627
|
this.forceClearBuffer_(mediaState);
|
|
628
628
|
streamCleared = true;
|
|
629
629
|
}
|
|
@@ -977,7 +977,10 @@ shaka.media.StreamingEngine = class {
|
|
|
977
977
|
unscaledBufferingGoal * this.bufferingGoalScale_;
|
|
978
978
|
|
|
979
979
|
// Check if we've buffered to the end of the presentation.
|
|
980
|
-
|
|
980
|
+
const timeUntilEnd =
|
|
981
|
+
this.manifest_.presentationTimeline.getDuration() - timeNeeded;
|
|
982
|
+
const oneMicrosecond = 1e-6;
|
|
983
|
+
if (timeUntilEnd < oneMicrosecond) {
|
|
981
984
|
// We shouldn't rebuffer if the playhead is close to the end of the
|
|
982
985
|
// presentation.
|
|
983
986
|
shaka.log.debug(logPrefix, 'buffered to end of presentation');
|
package/lib/player.js
CHANGED
|
@@ -6102,7 +6102,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
|
|
|
6102
6102
|
* @define {string} A version number taken from git at compile time.
|
|
6103
6103
|
* @export
|
|
6104
6104
|
*/
|
|
6105
|
-
shaka.Player.version = 'v3.1.
|
|
6105
|
+
shaka.Player.version = 'v3.1.5-uncompiled';
|
|
6106
6106
|
|
|
6107
6107
|
// Initialize the deprecation system using the version string we just set
|
|
6108
6108
|
// on the player.
|
|
@@ -24,8 +24,6 @@ shaka.polyfill.MediaCapabilities = class {
|
|
|
24
24
|
* @export
|
|
25
25
|
*/
|
|
26
26
|
static install() {
|
|
27
|
-
shaka.log.debug('MediaCapabilities: install');
|
|
28
|
-
|
|
29
27
|
// Since MediaCapabilities is not fully supported on Chromecast yet, we
|
|
30
28
|
// should always install polyfill for Chromecast.
|
|
31
29
|
// TODO: re-evaluate MediaCapabilities in the future versions of Chromecast.
|
|
@@ -40,21 +38,28 @@ shaka.polyfill.MediaCapabilities = class {
|
|
|
40
38
|
// TODO: re-evaluate MediaCapabilities in the future versions of PS5
|
|
41
39
|
// Browsers.
|
|
42
40
|
if (!shaka.util.Platform.isChromecast() &&
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
shaka.log.
|
|
41
|
+
!shaka.util.Platform.isApple() &&
|
|
42
|
+
!shaka.util.Platform.isPS5() &&
|
|
43
|
+
navigator.mediaCapabilities) {
|
|
44
|
+
shaka.log.info(
|
|
47
45
|
'MediaCapabilities: Native mediaCapabilities support found.');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
shaka.log.info('MediaCapabilities: install');
|
|
50
|
+
|
|
51
|
+
if (!navigator.mediaCapabilities) {
|
|
52
|
+
navigator.mediaCapabilities = /** @type {!MediaCapabilities} */ ({});
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
// MediaCapabilities
|
|
57
|
-
|
|
54
|
+
|
|
55
|
+
// Keep the patched MediaCapabilities object from being garbage-collected in
|
|
56
|
+
// Safari.
|
|
57
|
+
// See https://github.com/google/shaka-player/issues/3696#issuecomment-1009472718
|
|
58
|
+
shaka.polyfill.MediaCapabilities.originalMcap =
|
|
59
|
+
navigator.mediaCapabilities;
|
|
60
|
+
|
|
61
|
+
navigator.mediaCapabilities.decodingInfo =
|
|
62
|
+
shaka.polyfill.MediaCapabilities.decodingInfo_;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
/**
|
|
@@ -182,6 +187,16 @@ shaka.polyfill.MediaCapabilities = class {
|
|
|
182
187
|
}
|
|
183
188
|
};
|
|
184
189
|
|
|
190
|
+
/**
|
|
191
|
+
* A copy of the MediaCapabilities instance, to prevent Safari from
|
|
192
|
+
* garbage-collecting the polyfilled method on it. We make it public and export
|
|
193
|
+
* it to ensure that it is not stripped out by the compiler.
|
|
194
|
+
*
|
|
195
|
+
* @type {MediaCapabilities}
|
|
196
|
+
* @export
|
|
197
|
+
*/
|
|
198
|
+
shaka.polyfill.MediaCapabilities.originalMcap = null;
|
|
199
|
+
|
|
185
200
|
// Install at a lower priority than MediaSource polyfill, so that we have
|
|
186
201
|
// MediaSource available first.
|
|
187
202
|
shaka.polyfill.register(shaka.polyfill.MediaCapabilities.install, -1);
|
package/lib/text/cue.js
CHANGED
|
@@ -86,16 +86,17 @@ shaka.text.TtmlTextParser = class {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// Get the framerate, subFrameRate and frameRateMultiplier if applicable.
|
|
89
|
-
const frameRate = XmlUtils.
|
|
90
|
-
const subFrameRate = XmlUtils.
|
|
89
|
+
const frameRate = XmlUtils.getAttributeNSList(tt, ttpNs, 'frameRate');
|
|
90
|
+
const subFrameRate = XmlUtils.getAttributeNSList(
|
|
91
|
+
tt, ttpNs, 'subFrameRate');
|
|
91
92
|
const frameRateMultiplier =
|
|
92
|
-
XmlUtils.
|
|
93
|
-
const tickRate = XmlUtils.
|
|
93
|
+
XmlUtils.getAttributeNSList(tt, ttpNs, 'frameRateMultiplier');
|
|
94
|
+
const tickRate = XmlUtils.getAttributeNSList(tt, ttpNs, 'tickRate');
|
|
94
95
|
|
|
95
|
-
const cellResolution = XmlUtils.
|
|
96
|
+
const cellResolution = XmlUtils.getAttributeNSList(
|
|
96
97
|
tt, ttpNs, 'cellResolution');
|
|
97
98
|
const spaceStyle = tt.getAttribute('xml:space') || 'default';
|
|
98
|
-
const extent = XmlUtils.
|
|
99
|
+
const extent = XmlUtils.getAttributeNSList(tt, ttsNs, 'extent');
|
|
99
100
|
|
|
100
101
|
if (spaceStyle != 'default' && spaceStyle != 'preserve') {
|
|
101
102
|
throw new shaka.util.Error(
|
|
@@ -147,28 +148,15 @@ shaka.text.TtmlTextParser = class {
|
|
|
147
148
|
shaka.util.Error.Code.INVALID_TEXT_CUE,
|
|
148
149
|
'<span> can only be inside <p> in TTML');
|
|
149
150
|
}
|
|
151
|
+
}
|
|
150
152
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (cue) {
|
|
159
|
-
cues.push(cue);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
// Only used for parsing the background image
|
|
164
|
-
const cue = TtmlTextParser.parseCue_(
|
|
165
|
-
div, time.periodStart, rateInfo, metadataElements, styles,
|
|
166
|
-
regionElements, cueRegions, whitespaceTrim,
|
|
167
|
-
/* isNested= */ false, cellResolutionInfo);
|
|
168
|
-
if (cue) {
|
|
169
|
-
cues.push(cue);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
153
|
+
const cue = TtmlTextParser.parseCue_(
|
|
154
|
+
body, time.periodStart, rateInfo, metadataElements, styles,
|
|
155
|
+
regionElements, cueRegions, whitespaceTrim,
|
|
156
|
+
cellResolutionInfo, /* parentCueElement= */ null,
|
|
157
|
+
/* isContent= */ false);
|
|
158
|
+
if (cue) {
|
|
159
|
+
cues.push(cue);
|
|
172
160
|
}
|
|
173
161
|
}
|
|
174
162
|
|
|
@@ -186,18 +174,19 @@ shaka.text.TtmlTextParser = class {
|
|
|
186
174
|
* @param {!Array.<!Element>} regionElements
|
|
187
175
|
* @param {!Array.<!shaka.text.CueRegion>} cueRegions
|
|
188
176
|
* @param {boolean} whitespaceTrim
|
|
189
|
-
* @param {boolean} isNested
|
|
190
177
|
* @param {?{columns: number, rows: number}} cellResolution
|
|
178
|
+
* @param {?Element} parentCueElement
|
|
179
|
+
* @param {boolean} isContent
|
|
191
180
|
* @return {shaka.text.Cue}
|
|
192
181
|
* @private
|
|
193
182
|
*/
|
|
194
183
|
static parseCue_(
|
|
195
184
|
cueNode, offset, rateInfo, metadataElements, styles, regionElements,
|
|
196
|
-
cueRegions, whitespaceTrim,
|
|
185
|
+
cueRegions, whitespaceTrim, cellResolution, parentCueElement, isContent) {
|
|
197
186
|
/** @type {Element} */
|
|
198
187
|
let cueElement;
|
|
199
188
|
/** @type {Element} */
|
|
200
|
-
let parentElement = /** @type {Element} */(cueNode.parentNode);
|
|
189
|
+
let parentElement = /** @type {Element} */ (cueNode.parentNode);
|
|
201
190
|
|
|
202
191
|
if (cueNode.nodeType == Node.COMMENT_NODE) {
|
|
203
192
|
// The comments do not contain information that interests us here.
|
|
@@ -205,6 +194,12 @@ shaka.text.TtmlTextParser = class {
|
|
|
205
194
|
}
|
|
206
195
|
|
|
207
196
|
if (cueNode.nodeType == Node.TEXT_NODE) {
|
|
197
|
+
if (!isContent) {
|
|
198
|
+
// Ignore text elements outside the content. For example, whitespace
|
|
199
|
+
// on the same lexical level as the <p> elements, in a document with
|
|
200
|
+
// xml:space="preserve", should not be renderer.
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
208
203
|
// This should generate an "anonymous span" according to the TTML spec.
|
|
209
204
|
// So pretend the element was a <span>. parentElement was set above, so
|
|
210
205
|
// we should still be able to correctly traverse up for timing
|
|
@@ -219,6 +214,21 @@ shaka.text.TtmlTextParser = class {
|
|
|
219
214
|
}
|
|
220
215
|
goog.asserts.assert(cueElement, 'cueElement should be non-null!');
|
|
221
216
|
|
|
217
|
+
let imageElement = null;
|
|
218
|
+
for (const nameSpace of shaka.text.TtmlTextParser.smpteNsList_) {
|
|
219
|
+
imageElement = shaka.text.TtmlTextParser.getElementsFromCollection_(
|
|
220
|
+
cueElement, 'backgroundImage', metadataElements, '#',
|
|
221
|
+
nameSpace)[0];
|
|
222
|
+
if (imageElement) {
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const parentIsContent = isContent;
|
|
228
|
+
if (cueNode.nodeName == 'p' || imageElement) {
|
|
229
|
+
isContent = true;
|
|
230
|
+
}
|
|
231
|
+
|
|
222
232
|
const spaceStyle = cueElement.getAttribute('xml:space') ||
|
|
223
233
|
(whitespaceTrim ? 'default' : 'preserve');
|
|
224
234
|
|
|
@@ -243,8 +253,9 @@ shaka.text.TtmlTextParser = class {
|
|
|
243
253
|
regionElements,
|
|
244
254
|
cueRegions,
|
|
245
255
|
localWhitespaceTrim,
|
|
246
|
-
/* isNested= */ true,
|
|
247
256
|
cellResolution,
|
|
257
|
+
cueElement,
|
|
258
|
+
isContent,
|
|
248
259
|
);
|
|
249
260
|
|
|
250
261
|
// This node may or may not generate a nested cue.
|
|
@@ -254,6 +265,8 @@ shaka.text.TtmlTextParser = class {
|
|
|
254
265
|
}
|
|
255
266
|
}
|
|
256
267
|
|
|
268
|
+
const isNested = /** @type {boolean} */ (parentCueElement != null);
|
|
269
|
+
|
|
257
270
|
// In this regex, "\S" means "non-whitespace character".
|
|
258
271
|
const hasTextContent = /\S/.test(cueElement.textContent);
|
|
259
272
|
const hasTimeAttributes =
|
|
@@ -334,6 +347,13 @@ shaka.text.TtmlTextParser = class {
|
|
|
334
347
|
const cue = new shaka.text.Cue(start, end, payload);
|
|
335
348
|
cue.nestedCues = nestedCues;
|
|
336
349
|
|
|
350
|
+
if (!isContent) {
|
|
351
|
+
// If this is not a <p> element or a <div> with images, and it has no
|
|
352
|
+
// parent that was a <p> element, then it's part of the outer containers
|
|
353
|
+
// (e.g. the <body> or a normal <div> element within it).
|
|
354
|
+
cue.isContainer = true;
|
|
355
|
+
}
|
|
356
|
+
|
|
337
357
|
if (cellResolution) {
|
|
338
358
|
cue.cellResolution = cellResolution;
|
|
339
359
|
}
|
|
@@ -341,31 +361,32 @@ shaka.text.TtmlTextParser = class {
|
|
|
341
361
|
// Get other properties if available.
|
|
342
362
|
const regionElement = shaka.text.TtmlTextParser.getElementsFromCollection_(
|
|
343
363
|
cueElement, 'region', regionElements, /* prefix= */ '')[0];
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
imageElement = shaka.text.TtmlTextParser.getElementsFromCollection_(
|
|
352
|
-
cueElement, 'backgroundImage', metadataElements, '#',
|
|
353
|
-
nameSpace)[0];
|
|
354
|
-
if (imageElement) {
|
|
355
|
-
break;
|
|
364
|
+
// Do not actually apply that region unless it is non-inherited, though.
|
|
365
|
+
// This makes it so that, if a parent element has a region, the children
|
|
366
|
+
// don't also all independently apply the positioning of that region.
|
|
367
|
+
if (cueElement.hasAttribute('region')) {
|
|
368
|
+
if (regionElement && regionElement.getAttribute('xml:id')) {
|
|
369
|
+
const regionId = regionElement.getAttribute('xml:id');
|
|
370
|
+
cue.region = cueRegions.filter((region) => region.id == regionId)[0];
|
|
356
371
|
}
|
|
357
372
|
}
|
|
358
373
|
|
|
359
|
-
|
|
374
|
+
let regionElementForStyle = regionElement;
|
|
375
|
+
if (parentCueElement && isNested && !cueElement.getAttribute('region') &&
|
|
376
|
+
!cueElement.getAttribute('style')) {
|
|
377
|
+
regionElementForStyle =
|
|
378
|
+
shaka.text.TtmlTextParser.getElementsFromCollection_(
|
|
379
|
+
parentCueElement, 'region', regionElements, /* prefix= */ '')[0];
|
|
380
|
+
}
|
|
360
381
|
|
|
361
382
|
shaka.text.TtmlTextParser.addStyle_(
|
|
362
383
|
cue,
|
|
363
384
|
cueElement,
|
|
364
|
-
|
|
385
|
+
regionElementForStyle,
|
|
365
386
|
imageElement,
|
|
366
387
|
styles,
|
|
367
|
-
isNested,
|
|
368
|
-
isLeaf);
|
|
388
|
+
/** isNested= */ parentIsContent, // "nested in a <div>" doesn't count.
|
|
389
|
+
/** isLeaf= */ (nestedCues.length == 0));
|
|
369
390
|
|
|
370
391
|
return cue;
|
|
371
392
|
}
|
|
@@ -505,14 +526,13 @@ shaka.text.TtmlTextParser = class {
|
|
|
505
526
|
}
|
|
506
527
|
|
|
507
528
|
const align = TtmlTextParser.getStyleAttribute_(
|
|
508
|
-
cueElement, region, styles, 'textAlign',
|
|
529
|
+
cueElement, region, styles, 'textAlign', true);
|
|
509
530
|
if (align) {
|
|
510
531
|
cue.positionAlign = TtmlTextParser.textAlignToPositionAlign_[align];
|
|
511
532
|
cue.lineAlign = TtmlTextParser.textAlignToLineAlign_[align];
|
|
512
533
|
|
|
513
534
|
goog.asserts.assert(align.toUpperCase() in Cue.textAlign,
|
|
514
|
-
align.toUpperCase() +
|
|
515
|
-
' Should be in Cue.textAlign values!');
|
|
535
|
+
align.toUpperCase() + ' Should be in Cue.textAlign values!');
|
|
516
536
|
|
|
517
537
|
cue.textAlign = Cue.textAlign[align.toUpperCase()];
|
|
518
538
|
} else {
|
|
@@ -521,7 +541,7 @@ shaka.text.TtmlTextParser = class {
|
|
|
521
541
|
}
|
|
522
542
|
|
|
523
543
|
const displayAlign = TtmlTextParser.getStyleAttribute_(
|
|
524
|
-
cueElement, region, styles, 'displayAlign',
|
|
544
|
+
cueElement, region, styles, 'displayAlign', true);
|
|
525
545
|
if (displayAlign) {
|
|
526
546
|
goog.asserts.assert(displayAlign.toUpperCase() in Cue.displayAlign,
|
|
527
547
|
displayAlign.toUpperCase() +
|
|
@@ -753,7 +773,7 @@ shaka.text.TtmlTextParser = class {
|
|
|
753
773
|
return null;
|
|
754
774
|
}
|
|
755
775
|
|
|
756
|
-
const attr = XmlUtils.
|
|
776
|
+
const attr = XmlUtils.getAttributeNSList(region, ttsNs, attribute);
|
|
757
777
|
if (attr) {
|
|
758
778
|
return attr;
|
|
759
779
|
}
|
|
@@ -778,7 +798,7 @@ shaka.text.TtmlTextParser = class {
|
|
|
778
798
|
|
|
779
799
|
// Styling on elements should take precedence
|
|
780
800
|
// over the main styling attributes
|
|
781
|
-
const elementAttribute = XmlUtils.
|
|
801
|
+
const elementAttribute = XmlUtils.getAttributeNSList(
|
|
782
802
|
cueElement,
|
|
783
803
|
ttsNs,
|
|
784
804
|
attribute);
|
|
@@ -821,7 +841,7 @@ shaka.text.TtmlTextParser = class {
|
|
|
821
841
|
|
|
822
842
|
if (!styleAttributeValue) {
|
|
823
843
|
// Fall back to tts namespace.
|
|
824
|
-
styleAttributeValue = XmlUtils.
|
|
844
|
+
styleAttributeValue = XmlUtils.getAttributeNSList(
|
|
825
845
|
inheritedStyles[i],
|
|
826
846
|
ttsNs,
|
|
827
847
|
attribute);
|
|
@@ -1276,20 +1296,26 @@ shaka.text.TtmlTextParser.textAlignToPositionAlign_ = {
|
|
|
1276
1296
|
* document, not just "ttp:", so we use this with getAttributeNS() to ensure
|
|
1277
1297
|
* that we support arbitrary namespace names.
|
|
1278
1298
|
*
|
|
1279
|
-
* @const {string}
|
|
1299
|
+
* @const {!Array.<string>}
|
|
1280
1300
|
* @private
|
|
1281
1301
|
*/
|
|
1282
|
-
shaka.text.TtmlTextParser.parameterNs_ =
|
|
1302
|
+
shaka.text.TtmlTextParser.parameterNs_ = [
|
|
1303
|
+
'http://www.w3.org/ns/ttml#parameter',
|
|
1304
|
+
'http://www.w3.org/2006/10/ttaf1#parameter',
|
|
1305
|
+
];
|
|
1283
1306
|
|
|
1284
1307
|
/**
|
|
1285
1308
|
* The namespace URL for TTML styles. Can be assigned any name in the TTML
|
|
1286
1309
|
* document, not just "tts:", so we use this with getAttributeNS() to ensure
|
|
1287
1310
|
* that we support arbitrary namespace names.
|
|
1288
1311
|
*
|
|
1289
|
-
* @const {string}
|
|
1312
|
+
* @const {!Array.<string>}
|
|
1290
1313
|
* @private
|
|
1291
1314
|
*/
|
|
1292
|
-
shaka.text.TtmlTextParser.styleNs_ =
|
|
1315
|
+
shaka.text.TtmlTextParser.styleNs_ = [
|
|
1316
|
+
'http://www.w3.org/ns/ttml#styling',
|
|
1317
|
+
'http://www.w3.org/2006/10/ttaf1#styling',
|
|
1318
|
+
];
|
|
1293
1319
|
|
|
1294
1320
|
/**
|
|
1295
1321
|
* The namespace URL for EBU TTML styles. Can be assigned any name in the TTML
|
|
@@ -352,19 +352,22 @@ shaka.text.UITextDisplayer = class {
|
|
|
352
352
|
type = 'br';
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
const needWrapper = !isNested && cue.nestedCues.length > 0;
|
|
356
|
+
|
|
355
357
|
// Nested cues are inline elements. Top-level cues are block elements.
|
|
356
358
|
const cueElement = shaka.util.Dom.createHTMLElement(type);
|
|
357
359
|
if (type != 'br') {
|
|
358
|
-
this.setCaptionStyles_(cueElement, cue, parents);
|
|
360
|
+
this.setCaptionStyles_(cueElement, cue, parents, needWrapper);
|
|
359
361
|
}
|
|
360
362
|
|
|
361
363
|
let wrapper = cueElement;
|
|
362
|
-
if (
|
|
364
|
+
if (needWrapper) {
|
|
363
365
|
// Create a wrapper element which will serve to contain all children into
|
|
364
366
|
// a single item. This ensures that nested span elements appear
|
|
365
367
|
// horizontally and br elements occupy no vertical space.
|
|
366
368
|
wrapper = shaka.util.Dom.createHTMLElement('span');
|
|
367
369
|
wrapper.classList.add('shaka-text-wrapper');
|
|
370
|
+
wrapper.style.backgroundColor = cue.backgroundColor;
|
|
368
371
|
cueElement.appendChild(wrapper);
|
|
369
372
|
}
|
|
370
373
|
|
|
@@ -375,9 +378,10 @@ shaka.text.UITextDisplayer = class {
|
|
|
375
378
|
* @param {!HTMLElement} cueElement
|
|
376
379
|
* @param {!shaka.extern.Cue} cue
|
|
377
380
|
* @param {!Array.<!shaka.extern.Cue>} parents
|
|
381
|
+
* @param {boolean} hasWrapper
|
|
378
382
|
* @private
|
|
379
383
|
*/
|
|
380
|
-
setCaptionStyles_(cueElement, cue, parents) {
|
|
384
|
+
setCaptionStyles_(cueElement, cue, parents, hasWrapper) {
|
|
381
385
|
const Cue = shaka.text.Cue;
|
|
382
386
|
const inherit =
|
|
383
387
|
(cb) => shaka.text.UITextDisplayer.inheritProperty_(parents, cb);
|
|
@@ -434,13 +438,15 @@ shaka.text.UITextDisplayer = class {
|
|
|
434
438
|
if (cue.border) {
|
|
435
439
|
elem.style.border = cue.border;
|
|
436
440
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
if (!hasWrapper) {
|
|
442
|
+
const bgColor = inherit((c) => c.backgroundColor);
|
|
443
|
+
if (bgColor) {
|
|
444
|
+
elem.style.backgroundColor = bgColor;
|
|
445
|
+
} else if (text) {
|
|
446
|
+
// If there is no background, default to a semi-transparent black.
|
|
447
|
+
// Only do this for the text itself.
|
|
448
|
+
elem.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
|
|
449
|
+
}
|
|
444
450
|
}
|
|
445
451
|
if (text) {
|
|
446
452
|
elem.textContent = text;
|
|
@@ -450,7 +456,7 @@ shaka.text.UITextDisplayer = class {
|
|
|
450
456
|
// The displayAlign attribute specifies the vertical alignment of the
|
|
451
457
|
// captions inside the text container. Before means at the top of the
|
|
452
458
|
// text container, and after means at the bottom.
|
|
453
|
-
if (isNested) {
|
|
459
|
+
if (isNested && !parents[parents.length - 1].isContainer) {
|
|
454
460
|
style.display = 'inline';
|
|
455
461
|
} else {
|
|
456
462
|
style.display = 'flex';
|
package/lib/util/stream_utils.js
CHANGED
|
@@ -333,13 +333,48 @@ shaka.util.StreamUtils = class {
|
|
|
333
333
|
*/
|
|
334
334
|
static async filterManifestByMediaCapabilities(
|
|
335
335
|
manifest, usePersistentLicenses) {
|
|
336
|
-
goog.asserts.assert(
|
|
336
|
+
goog.asserts.assert(navigator.mediaCapabilities,
|
|
337
337
|
'MediaCapabilities should be valid.');
|
|
338
338
|
|
|
339
339
|
await shaka.util.StreamUtils.getDecodingInfosForVariants(
|
|
340
340
|
manifest.variants, usePersistentLicenses, /* srcEquals= */ false);
|
|
341
341
|
manifest.variants = manifest.variants.filter((variant) => {
|
|
342
|
+
// See: https://github.com/google/shaka-player/issues/3860
|
|
342
343
|
const video = variant.video;
|
|
344
|
+
const ContentType = shaka.util.ManifestParserUtils.ContentType;
|
|
345
|
+
if (video) {
|
|
346
|
+
let videoCodecs = shaka.util.StreamUtils.patchVp9(video.codecs);
|
|
347
|
+
// For multiplexed streams. Here we must check the audio of the
|
|
348
|
+
// stream to see if it is compatible.
|
|
349
|
+
if (video.codecs.includes(',')) {
|
|
350
|
+
const allCodecs = video.codecs.split(',');
|
|
351
|
+
videoCodecs = shaka.util.ManifestParserUtils.guessCodecs(
|
|
352
|
+
ContentType.VIDEO, allCodecs);
|
|
353
|
+
const audioCodecs = shaka.util.ManifestParserUtils.guessCodecs(
|
|
354
|
+
ContentType.AUDIO, allCodecs);
|
|
355
|
+
const audioFullType = shaka.util.MimeUtils.getFullOrConvertedType(
|
|
356
|
+
video.mimeType, audioCodecs, ContentType.AUDIO);
|
|
357
|
+
if (!MediaSource.isTypeSupported(audioFullType)) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const fullType = shaka.util.MimeUtils.getFullOrConvertedType(
|
|
362
|
+
video.mimeType, videoCodecs, ContentType.VIDEO);
|
|
363
|
+
if (!MediaSource.isTypeSupported(fullType)) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const audio = variant.audio;
|
|
368
|
+
if (audio) {
|
|
369
|
+
const codecs =
|
|
370
|
+
shaka.util.StreamUtils.getCorrectAudioCodecs_(audio.codecs);
|
|
371
|
+
const fullType = shaka.util.MimeUtils.getFullOrConvertedType(
|
|
372
|
+
audio.mimeType, codecs, ContentType.AUDIO);
|
|
373
|
+
if (!MediaSource.isTypeSupported(fullType)) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
343
378
|
// See: https://github.com/google/shaka-player/issues/3380
|
|
344
379
|
if (shaka.util.Platform.isXboxOne() && video &&
|
|
345
380
|
((video.width && video.width > 1920) ||
|
|
@@ -422,7 +457,7 @@ shaka.util.StreamUtils = class {
|
|
|
422
457
|
return;
|
|
423
458
|
}
|
|
424
459
|
|
|
425
|
-
const mediaCapabilities =
|
|
460
|
+
const mediaCapabilities = navigator.mediaCapabilities;
|
|
426
461
|
|
|
427
462
|
const operations = [];
|
|
428
463
|
const getVariantDecodingInfos = (async (variant, decodingConfig) => {
|
|
@@ -516,12 +551,8 @@ shaka.util.StreamUtils = class {
|
|
|
516
551
|
}
|
|
517
552
|
}
|
|
518
553
|
if (audio) {
|
|
519
|
-
// Some Tizen devices seem to misreport AC-3 support, but correctly
|
|
520
|
-
// report EC-3 support. So query EC-3 as a fallback for AC-3.
|
|
521
|
-
// See https://github.com/google/shaka-player/issues/2989 for details.
|
|
522
554
|
const codecs =
|
|
523
|
-
(audio.codecs
|
|
524
|
-
shaka.util.Platform.isTizen()) ? 'ec-3' : audio.codecs;
|
|
555
|
+
shaka.util.StreamUtils.getCorrectAudioCodecs_(audio.codecs);
|
|
525
556
|
const fullType = shaka.util.MimeUtils.getFullOrConvertedType(
|
|
526
557
|
audio.mimeType, codecs, ContentType.AUDIO);
|
|
527
558
|
|
|
@@ -632,6 +663,26 @@ shaka.util.StreamUtils = class {
|
|
|
632
663
|
return configs;
|
|
633
664
|
}
|
|
634
665
|
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Generates the correct audio codec for MediaDecodingConfiguration and
|
|
669
|
+
* for MediaSource.isTypeSupported.
|
|
670
|
+
* @param {string} codecs
|
|
671
|
+
* @return {string}
|
|
672
|
+
* @private
|
|
673
|
+
*/
|
|
674
|
+
static getCorrectAudioCodecs_(codecs) {
|
|
675
|
+
// Some Tizen devices seem to misreport AC-3 support, but correctly
|
|
676
|
+
// report EC-3 support. So query EC-3 as a fallback for AC-3.
|
|
677
|
+
// See https://github.com/google/shaka-player/issues/2989 for details.
|
|
678
|
+
if (shaka.util.Platform.isTizen()) {
|
|
679
|
+
return codecs.toLowerCase() == 'ac-3' ? 'ec-3' : codecs;
|
|
680
|
+
} else {
|
|
681
|
+
return codecs;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
|
|
635
686
|
/**
|
|
636
687
|
* MediaCapabilities supports 'vp09...' codecs, but not 'vp9'. Translate vp9
|
|
637
688
|
* codec strings into 'vp09...', to allow such content to play with
|
package/lib/util/xml_utils.js
CHANGED
|
@@ -102,6 +102,25 @@ shaka.util.XmlUtils = class {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Gets a namespace-qualified attribute.
|
|
107
|
+
* @param {!Element} elem The element to get from.
|
|
108
|
+
* @param {!Array.<string>} nsList The lis of namespace URIs.
|
|
109
|
+
* @param {string} name The local name of the attribute.
|
|
110
|
+
* @return {?string} The attribute's value, or null if not present.
|
|
111
|
+
*/
|
|
112
|
+
static getAttributeNSList(elem, nsList, name) {
|
|
113
|
+
// Some browsers return the empty string when the attribute is missing,
|
|
114
|
+
// so check if it exists first. See: https://mzl.la/2L7F0UK
|
|
115
|
+
for (const ns of nsList) {
|
|
116
|
+
if (elem.hasAttributeNS(ns, name)) {
|
|
117
|
+
return elem.getAttributeNS(ns, name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
105
124
|
/**
|
|
106
125
|
* Gets the text contents of a node.
|
|
107
126
|
* @param {!Node} elem The XML element.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaka-player",
|
|
3
3
|
"description": "DASH/EME video player library",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.5",
|
|
5
5
|
"homepage": "https://github.com/google/shaka-player",
|
|
6
6
|
"author": "Google",
|
|
7
7
|
"maintainers": [
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@chiragrupani/karma-chromium-edge-launcher": "^2.1.0",
|
|
15
|
+
"@onslip/karma-safari-launcher": "^1.0.1",
|
|
15
16
|
"@teppeis/clutz": "^1.0.29-4c95e12.v20190929",
|
|
16
17
|
"awesomplete": "^1.1.4",
|
|
17
18
|
"babel-core": "^6.26.3",
|
|
@@ -44,7 +45,6 @@
|
|
|
44
45
|
"karma-jasmine": "^3.3.1",
|
|
45
46
|
"karma-jasmine-ajax": "^0.1.13",
|
|
46
47
|
"karma-opera-launcher": "^1.0.0",
|
|
47
|
-
"karma-safari-launcher": "^1.0.0",
|
|
48
48
|
"karma-sourcemap-loader": "^0.3.7",
|
|
49
49
|
"karma-spec-reporter": "0.0.32",
|
|
50
50
|
"karma-webdriver-launcher": "^1.0.8",
|