shaka-player 3.2.17 → 3.2.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/CHANGELOG.md +11 -0
- package/dist/locales.js +29 -29
- package/dist/shaka-player.compiled.debug.js +59 -58
- package/dist/shaka-player.compiled.debug.map +3 -3
- package/dist/shaka-player.compiled.js +182 -182
- package/dist/shaka-player.compiled.map +2 -2
- package/dist/shaka-player.ui.debug.js +73 -72
- package/dist/shaka-player.ui.debug.map +3 -3
- package/dist/shaka-player.ui.js +164 -163
- package/dist/shaka-player.ui.map +3 -3
- package/lib/player.js +7 -1
- package/lib/text/ui_text_displayer.js +24 -4
- package/lib/text/web_vtt_generator.js +21 -9
- package/lib/util/dom_utils.js +3 -1
- package/lib/util/stream_utils.js +6 -0
- package/package.json +1 -1
- package/test/player_unit.js +4 -2
- package/test/text/ui_text_displayer_unit.js +70 -0
package/lib/player.js
CHANGED
|
@@ -1342,6 +1342,12 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
1342
1342
|
has.startTime = null;
|
|
1343
1343
|
has.uri = null;
|
|
1344
1344
|
|
|
1345
|
+
// Release the region timeline, which is created when parsing the manifest.
|
|
1346
|
+
if (this.regionTimeline_) {
|
|
1347
|
+
this.regionTimeline_.release();
|
|
1348
|
+
this.regionTimeline_ = null;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1345
1351
|
// In most cases we should have a media element. The one exception would
|
|
1346
1352
|
// be if there was an error and we, by chance, did not have a media element.
|
|
1347
1353
|
if (has.mediaElement) {
|
|
@@ -6453,7 +6459,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
|
|
|
6453
6459
|
* @define {string} A version number taken from git at compile time.
|
|
6454
6460
|
* @export
|
|
6455
6461
|
*/
|
|
6456
|
-
shaka.Player.version = 'v3.2.
|
|
6462
|
+
shaka.Player.version = 'v3.2.18-uncompiled';
|
|
6457
6463
|
|
|
6458
6464
|
// Initialize the deprecation system using the version string we just set
|
|
6459
6465
|
// on the player.
|
|
@@ -372,6 +372,25 @@ shaka.text.UITextDisplayer = class {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Compute a unique internal id:
|
|
377
|
+
* Regions can reuse the id but have different dimensions, we need to
|
|
378
|
+
* consider those differences
|
|
379
|
+
* @param {shaka.extern.CueRegion} region
|
|
380
|
+
* @private
|
|
381
|
+
*/
|
|
382
|
+
generateRegionId_(region) {
|
|
383
|
+
const percentageUnit = shaka.text.CueRegion.units.PERCENTAGE;
|
|
384
|
+
const heightUnit = region.heightUnits == percentageUnit ? '%' : 'px';
|
|
385
|
+
const viewportAnchorUnit =
|
|
386
|
+
region.viewportAnchorUnits == percentageUnit ? '%' : 'px';
|
|
387
|
+
const uniqueRegionId = `${region.id}_${
|
|
388
|
+
region.width}x${region.height}${heightUnit}-${
|
|
389
|
+
region.viewportAnchorX}x${region.viewportAnchorY}${viewportAnchorUnit}`;
|
|
390
|
+
|
|
391
|
+
return uniqueRegionId;
|
|
392
|
+
}
|
|
393
|
+
|
|
375
394
|
/**
|
|
376
395
|
* Get or create a region element corresponding to the cue region. These are
|
|
377
396
|
* cached by ID.
|
|
@@ -383,8 +402,9 @@ shaka.text.UITextDisplayer = class {
|
|
|
383
402
|
getRegionElement_(cue) {
|
|
384
403
|
const region = cue.region;
|
|
385
404
|
|
|
386
|
-
|
|
387
|
-
|
|
405
|
+
const regionId = this.generateRegionId_(region);
|
|
406
|
+
if (this.regionElements_.has(regionId)) {
|
|
407
|
+
return this.regionElements_.get(regionId);
|
|
388
408
|
}
|
|
389
409
|
|
|
390
410
|
const regionElement = shaka.util.Dom.createHTMLElement('span');
|
|
@@ -395,7 +415,7 @@ shaka.text.UITextDisplayer = class {
|
|
|
395
415
|
const viewportAnchorUnit =
|
|
396
416
|
region.viewportAnchorUnits == percentageUnit ? '%' : 'px';
|
|
397
417
|
|
|
398
|
-
regionElement.id = 'shaka-text-region---' +
|
|
418
|
+
regionElement.id = 'shaka-text-region---' + regionId;
|
|
399
419
|
regionElement.classList.add('shaka-text-region');
|
|
400
420
|
|
|
401
421
|
regionElement.style.height = region.height + heightUnit;
|
|
@@ -416,7 +436,7 @@ shaka.text.UITextDisplayer = class {
|
|
|
416
436
|
regionElement.style.justifyContent = 'flex-end';
|
|
417
437
|
}
|
|
418
438
|
|
|
419
|
-
this.regionElements_.set(
|
|
439
|
+
this.regionElements_.set(regionId, regionElement);
|
|
420
440
|
return regionElement;
|
|
421
441
|
}
|
|
422
442
|
|
|
@@ -87,16 +87,28 @@ shaka.text.WebVttGenerator = class {
|
|
|
87
87
|
// We don't want to modify the array or objects passed in, since we don't
|
|
88
88
|
// technically own them. So we build a new array and replace certain items
|
|
89
89
|
// in it if they need to be flattened.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
// We also don't want to flatten the text payloads starting at a container
|
|
91
|
+
// element; otherwise, for containers encapsulating multiple caption lines,
|
|
92
|
+
// the lines would merge into a single cue. This is undesirable when a
|
|
93
|
+
// subset of the captions are outside of the append time window. To fix
|
|
94
|
+
// this, we only call flattenPayload() starting at elements marked as
|
|
95
|
+
// isContainer = false.
|
|
96
|
+
const getCuesToFlatten = (cues, result) => {
|
|
97
|
+
for (const cue of cues) {
|
|
98
|
+
if (cue.isContainer) {
|
|
99
|
+
// Recurse to find the actual text payload cues.
|
|
100
|
+
getCuesToFlatten(cue.nestedCues, result);
|
|
101
|
+
} else {
|
|
102
|
+
// Flatten the payload.
|
|
103
|
+
const flatCue = cue.clone();
|
|
104
|
+
flatCue.nestedCues = [];
|
|
105
|
+
flatCue.payload = flattenPayload(cue);
|
|
106
|
+
result.push(flatCue);
|
|
107
|
+
}
|
|
98
108
|
}
|
|
99
|
-
|
|
109
|
+
return result;
|
|
110
|
+
};
|
|
111
|
+
const flattenedCues = getCuesToFlatten(cues, []);
|
|
100
112
|
|
|
101
113
|
let webvttString = 'WEBVTT\n\n';
|
|
102
114
|
for (const cue of flattenedCues) {
|
package/lib/util/dom_utils.js
CHANGED
|
@@ -36,7 +36,9 @@ shaka.util.Dom = class {
|
|
|
36
36
|
* @return {!HTMLButtonElement}
|
|
37
37
|
*/
|
|
38
38
|
static createButton() {
|
|
39
|
-
|
|
39
|
+
const button = document.createElement('button');
|
|
40
|
+
button.setAttribute('type', 'button');
|
|
41
|
+
return /** @type {!HTMLButtonElement} */ (button);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
|
package/lib/util/stream_utils.js
CHANGED
|
@@ -450,12 +450,16 @@ shaka.util.StreamUtils = class {
|
|
|
450
450
|
if (!MediaSource.isTypeSupported(audioFullType)) {
|
|
451
451
|
return false;
|
|
452
452
|
}
|
|
453
|
+
// Update the codec string with the (possibly) converted codecs.
|
|
454
|
+
videoCodecs = [videoCodecs, audioCodecs].join(',');
|
|
453
455
|
}
|
|
454
456
|
const fullType = shaka.util.MimeUtils.getFullOrConvertedType(
|
|
455
457
|
video.mimeType, videoCodecs, ContentType.VIDEO);
|
|
456
458
|
if (!MediaSource.isTypeSupported(fullType)) {
|
|
457
459
|
return false;
|
|
458
460
|
}
|
|
461
|
+
// Update the codec string with the (possibly) converted codecs.
|
|
462
|
+
video.codecs = videoCodecs;
|
|
459
463
|
}
|
|
460
464
|
const audio = variant.audio;
|
|
461
465
|
if (audio) {
|
|
@@ -466,6 +470,8 @@ shaka.util.StreamUtils = class {
|
|
|
466
470
|
if (!MediaSource.isTypeSupported(fullType)) {
|
|
467
471
|
return false;
|
|
468
472
|
}
|
|
473
|
+
// Update the codec string with the (possibly) converted codecs.
|
|
474
|
+
audio.codecs = codecs;
|
|
469
475
|
}
|
|
470
476
|
|
|
471
477
|
// See: https://github.com/shaka-project/shaka-player/issues/3380
|
package/package.json
CHANGED
package/test/player_unit.js
CHANGED
|
@@ -3185,7 +3185,9 @@ describe('Player', () => {
|
|
|
3185
3185
|
variant.addAudio(0, (stream) => {
|
|
3186
3186
|
stream.channelsCount = 6;
|
|
3187
3187
|
stream.audioSamplingRate = 48000;
|
|
3188
|
-
|
|
3188
|
+
// ac-3 is rewritten as ec-3 on Tizen, so for the stability of this
|
|
3189
|
+
// test case, use ec-3.
|
|
3190
|
+
stream.codecs = 'ec-3';
|
|
3189
3191
|
});
|
|
3190
3192
|
});
|
|
3191
3193
|
|
|
@@ -3210,7 +3212,7 @@ describe('Player', () => {
|
|
|
3210
3212
|
expect(abrManager.variants.length).toBe(1);
|
|
3211
3213
|
// It should be the 6-channel variant, based on our preference.
|
|
3212
3214
|
expect(abrManager.variants[0].audio.channelsCount).toBe(6);
|
|
3213
|
-
expect(abrManager.variants[0].audio.codecs).toBe('
|
|
3215
|
+
expect(abrManager.variants[0].audio.codecs).toBe('ec-3');
|
|
3214
3216
|
});
|
|
3215
3217
|
});
|
|
3216
3218
|
|
|
@@ -537,4 +537,74 @@ describe('UITextDisplayer', () => {
|
|
|
537
537
|
'.shaka-text-region');
|
|
538
538
|
expect(allRegionElements.length).toBe(1);
|
|
539
539
|
});
|
|
540
|
+
|
|
541
|
+
it('creates separate regions when dimensions differ but id same', () => {
|
|
542
|
+
const identicalRegionId = 'regionId';
|
|
543
|
+
|
|
544
|
+
const cueRegion1 = new shaka.text.CueRegion();
|
|
545
|
+
const cueRegion2 = new shaka.text.CueRegion();
|
|
546
|
+
cueRegion1.id = identicalRegionId;
|
|
547
|
+
cueRegion2.id = identicalRegionId;
|
|
548
|
+
|
|
549
|
+
cueRegion1.height = 80;
|
|
550
|
+
cueRegion1.heightUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
551
|
+
cueRegion1.width = 80;
|
|
552
|
+
cueRegion1.widthUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
553
|
+
|
|
554
|
+
cueRegion2.height = 160; // the only difference!
|
|
555
|
+
cueRegion2.heightUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
556
|
+
cueRegion2.width = 80;
|
|
557
|
+
cueRegion2.widthUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
558
|
+
|
|
559
|
+
cueRegion1.viewportAnchorX = 10;
|
|
560
|
+
cueRegion1.viewportAnchorY = 10;
|
|
561
|
+
cueRegion1.viewportAnchorUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
562
|
+
|
|
563
|
+
cueRegion2.viewportAnchorX = 10;
|
|
564
|
+
cueRegion2.viewportAnchorY = 10;
|
|
565
|
+
cueRegion2.viewportAnchorUnits = shaka.text.CueRegion.units.PERCENTAGE;
|
|
566
|
+
|
|
567
|
+
// These all attach to the same region, but only one region element should
|
|
568
|
+
// be created.
|
|
569
|
+
const firstBatchOfCues = [
|
|
570
|
+
new shaka.text.Cue(0, 100, ''),
|
|
571
|
+
new shaka.text.Cue(0, 100, ''),
|
|
572
|
+
new shaka.text.Cue(0, 100, ''),
|
|
573
|
+
];
|
|
574
|
+
for (const cue of firstBatchOfCues) {
|
|
575
|
+
cue.displayAlign = shaka.text.Cue.displayAlign.CENTER;
|
|
576
|
+
cue.region = cueRegion1;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Another batch for the other region
|
|
580
|
+
const secondBatchOfCues = [
|
|
581
|
+
new shaka.text.Cue(0, 100, ''),
|
|
582
|
+
new shaka.text.Cue(0, 100, ''),
|
|
583
|
+
new shaka.text.Cue(0, 100, ''),
|
|
584
|
+
];
|
|
585
|
+
for (const cue of secondBatchOfCues) {
|
|
586
|
+
cue.displayAlign = shaka.text.Cue.displayAlign.CENTER;
|
|
587
|
+
cue.region = cueRegion2;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
textDisplayer.setTextVisibility(true);
|
|
591
|
+
textDisplayer.append(firstBatchOfCues);
|
|
592
|
+
textDisplayer.append(secondBatchOfCues);
|
|
593
|
+
updateCaptions();
|
|
594
|
+
|
|
595
|
+
const textContainer = videoContainer.querySelector('.shaka-text-container');
|
|
596
|
+
const allRegionElements = textContainer.querySelectorAll(
|
|
597
|
+
'.shaka-text-region');
|
|
598
|
+
|
|
599
|
+
// Verify that the nested cues are attached to respective region element.
|
|
600
|
+
expect(allRegionElements.length).toBe(2);
|
|
601
|
+
|
|
602
|
+
const childrenOfOne = Array.from(allRegionElements[0].childNodes).filter(
|
|
603
|
+
(e) => e.nodeType == Node.ELEMENT_NODE);
|
|
604
|
+
expect(childrenOfOne.length).toBe(3);
|
|
605
|
+
|
|
606
|
+
const childrenOfTwo = Array.from(allRegionElements[1].childNodes).filter(
|
|
607
|
+
(e) => e.nodeType == Node.ELEMENT_NODE);
|
|
608
|
+
expect(childrenOfTwo.length).toBe(3);
|
|
609
|
+
});
|
|
540
610
|
});
|