shaka-player 4.2.2 → 4.2.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.
- package/.github/workflows/build-and-test.yaml +11 -6
- package/.github/workflows/compute-incremental-coverage.py +14 -3
- package/.github/workflows/demo-version-index.yaml +1 -1
- package/.github/workflows/nightly-demo.yaml +1 -1
- package/.github/workflows/release-please.yaml +5 -5
- package/.github/workflows/report-incremental-coverage.yaml +1 -1
- package/.github/workflows/selenium-lab-tests.yaml +8 -6
- package/AUTHORS +2 -0
- package/CHANGELOG.md +32 -0
- package/CONTRIBUTORS +2 -0
- package/dist/deps.js +5 -5
- package/dist/locales.js +33 -33
- package/dist/shaka-player.compiled.d.ts +6 -1
- package/dist/shaka-player.compiled.debug.d.ts +6 -1
- package/dist/shaka-player.compiled.debug.externs.js +3 -1
- package/dist/shaka-player.compiled.debug.js +119 -115
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +3 -1
- package/dist/shaka-player.compiled.js +719 -716
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +6 -1
- package/dist/shaka-player.ui.debug.d.ts +6 -1
- package/dist/shaka-player.ui.debug.externs.js +3 -1
- package/dist/shaka-player.ui.debug.js +135 -132
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +3 -1
- package/dist/shaka-player.ui.js +846 -843
- package/dist/shaka-player.ui.map +4 -4
- package/docs/tutorials/welcome.md +2 -2
- package/externs/mux.js +3 -0
- package/lib/ads/client_side_ad_manager.js +5 -2
- package/lib/cast/cast_proxy.js +2 -1
- package/lib/cast/cast_receiver.js +19 -5
- package/lib/cast/cast_sender.js +2 -1
- package/lib/cast/cast_utils.js +16 -6
- package/lib/hls/hls_parser.js +27 -9
- package/lib/media/drm_engine.js +7 -6
- package/lib/media/media_source_engine.js +6 -0
- package/lib/media/playhead.js +24 -2
- package/lib/media/streaming_engine.js +3 -12
- package/lib/media/transmuxer.js +6 -0
- package/lib/offline/indexeddb/storage_mechanism.js +24 -0
- package/lib/player.js +24 -11
- package/lib/polyfill/media_capabilities.js +7 -6
- package/lib/text/ttml_text_parser.js +69 -93
- package/lib/text/vtt_text_parser.js +1 -1
- package/lib/util/error.js +7 -0
- package/lib/util/manifest_parser_utils.js +4 -0
- package/lib/util/periods.js +9 -9
- package/lib/util/platform.js +0 -10
- package/lib/util/xml_utils.js +45 -6
- package/package.json +1 -1
- package/roadmap.md +24 -6
- package/test/cast/cast_receiver_integration.js +97 -16
- package/test/cast/cast_receiver_unit.js +17 -12
- package/test/cast/cast_utils_unit.js +1 -0
- package/test/media/media_source_engine_integration.js +31 -0
- package/test/media/playhead_unit.js +41 -0
- package/test/media/streaming_engine_integration.js +13 -0
- package/test/media/streaming_engine_unit.js +36 -23
- package/test/offline/storage_integration.js +30 -0
- package/test/player_unit.js +87 -0
- package/test/test/util/simple_fakes.js +3 -0
- package/test/text/vtt_text_parser_unit.js +23 -1
- package/test/util/periods_unit.js +149 -11
- package/test/util/xml_utils_unit.js +64 -0
- package/ui/controls.js +4 -1
- package/ui/settings_menu.js +11 -2
|
@@ -12,6 +12,14 @@ describe('PeriodCombiner', () => {
|
|
|
12
12
|
/** @type {shaka.util.PeriodCombiner} */
|
|
13
13
|
let combiner;
|
|
14
14
|
|
|
15
|
+
const makeAudioStreamWithRoles = (id, roles, primary = true) => {
|
|
16
|
+
const stream = makeAudioStream('en');
|
|
17
|
+
stream.originalId = id;
|
|
18
|
+
stream.roles = roles;
|
|
19
|
+
stream.primary = primary;
|
|
20
|
+
return stream;
|
|
21
|
+
};
|
|
22
|
+
|
|
15
23
|
beforeEach(() => {
|
|
16
24
|
combiner = new shaka.util.PeriodCombiner();
|
|
17
25
|
});
|
|
@@ -1127,20 +1135,149 @@ describe('PeriodCombiner', () => {
|
|
|
1127
1135
|
const variants = combiner.getVariants();
|
|
1128
1136
|
|
|
1129
1137
|
expect(variants).toEqual(jasmine.arrayWithExactContents([
|
|
1130
|
-
makeAVVariant(1080, 'en'),
|
|
1131
|
-
makeAVVariant(1080, 'en'),
|
|
1138
|
+
makeAVVariant(1080, 'en', 2, ['role1', 'role2']),
|
|
1139
|
+
makeAVVariant(1080, 'en', 2, ['role1']),
|
|
1132
1140
|
]));
|
|
1133
1141
|
|
|
1134
1142
|
// We can use the originalId field to see what each track is composed of.
|
|
1135
|
-
|
|
1136
|
-
expect(
|
|
1137
|
-
|
|
1143
|
+
expect(variants[0].audio.originalId).toBe('stream1,stream3');
|
|
1144
|
+
expect(variants[1].audio.originalId).toBe('stream2,stream4');
|
|
1145
|
+
});
|
|
1138
1146
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1147
|
+
it('Matches streams with roles in common', async () => {
|
|
1148
|
+
/** @type {!Array.<shaka.util.PeriodCombiner.Period>} */
|
|
1149
|
+
const periods = [
|
|
1150
|
+
{
|
|
1151
|
+
id: '1',
|
|
1152
|
+
videoStreams: [
|
|
1153
|
+
makeVideoStream(720),
|
|
1154
|
+
makeVideoStream(1080),
|
|
1155
|
+
],
|
|
1156
|
+
audioStreams: [
|
|
1157
|
+
makeAudioStreamWithRoles('stream1', ['main']),
|
|
1158
|
+
makeAudioStreamWithRoles('stream2', ['description'], false),
|
|
1159
|
+
],
|
|
1160
|
+
textStreams: [],
|
|
1161
|
+
imageStreams: [],
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
id: '2',
|
|
1165
|
+
videoStreams: [
|
|
1166
|
+
makeVideoStream(720),
|
|
1167
|
+
makeVideoStream(1080),
|
|
1168
|
+
],
|
|
1169
|
+
audioStreams: [
|
|
1170
|
+
makeAudioStreamWithRoles('stream1', ['main']),
|
|
1171
|
+
makeAudioStreamWithRoles('stream2', ['description'], false),
|
|
1172
|
+
],
|
|
1173
|
+
textStreams: [],
|
|
1174
|
+
imageStreams: [],
|
|
1175
|
+
},
|
|
1176
|
+
];
|
|
1177
|
+
|
|
1178
|
+
await combiner.combinePeriods(periods, /* isDynamic= */ false);
|
|
1179
|
+
const variants = combiner.getVariants();
|
|
1180
|
+
|
|
1181
|
+
console.log(variants);
|
|
1182
|
+
|
|
1183
|
+
expect(variants.length).toBe(4);
|
|
1184
|
+
|
|
1185
|
+
expect(variants).toEqual(jasmine.arrayWithExactContents([
|
|
1186
|
+
makeAVVariant(720, 'en', 2, ['main']),
|
|
1187
|
+
makeAVVariant(1080, 'en', 2, ['main']),
|
|
1188
|
+
makeAVVariant(720, 'en', 2, ['description']),
|
|
1189
|
+
makeAVVariant(1080, 'en', 2, ['description']),
|
|
1190
|
+
]));
|
|
1191
|
+
|
|
1192
|
+
// We can use the originalId field to see what each track is composed of.
|
|
1193
|
+
expect(variants[0].audio.originalId).toBe('stream1,stream1');
|
|
1194
|
+
expect(variants[1].audio.originalId).toBe('stream1,stream1');
|
|
1195
|
+
expect(variants[2].audio.originalId).toBe('stream2,stream2');
|
|
1196
|
+
expect(variants[3].audio.originalId).toBe('stream2,stream2');
|
|
1142
1197
|
});
|
|
1143
1198
|
|
|
1199
|
+
it('Matches streams with mismatched roles', async () => {
|
|
1200
|
+
/** @type {!Array.<shaka.util.PeriodCombiner.Period>} */
|
|
1201
|
+
const periods = [
|
|
1202
|
+
{
|
|
1203
|
+
id: '0',
|
|
1204
|
+
videoStreams: [
|
|
1205
|
+
makeVideoStream(720),
|
|
1206
|
+
makeVideoStream(1080),
|
|
1207
|
+
],
|
|
1208
|
+
audioStreams: [
|
|
1209
|
+
makeAudioStreamWithRoles('stream1', ['main']),
|
|
1210
|
+
],
|
|
1211
|
+
textStreams: [],
|
|
1212
|
+
imageStreams: [],
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
id: '1',
|
|
1216
|
+
videoStreams: [
|
|
1217
|
+
makeVideoStream(720),
|
|
1218
|
+
makeVideoStream(1080),
|
|
1219
|
+
],
|
|
1220
|
+
audioStreams: [
|
|
1221
|
+
makeAudioStreamWithRoles('stream1', ['main']),
|
|
1222
|
+
makeAudioStreamWithRoles('stream2', ['description'], false),
|
|
1223
|
+
],
|
|
1224
|
+
textStreams: [],
|
|
1225
|
+
imageStreams: [],
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
id: '2',
|
|
1229
|
+
videoStreams: [
|
|
1230
|
+
makeVideoStream(720),
|
|
1231
|
+
makeVideoStream(1080),
|
|
1232
|
+
],
|
|
1233
|
+
audioStreams: [
|
|
1234
|
+
makeAudioStreamWithRoles('stream1', ['main']),
|
|
1235
|
+
],
|
|
1236
|
+
textStreams: [],
|
|
1237
|
+
imageStreams: [],
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
id: '3',
|
|
1241
|
+
videoStreams: [
|
|
1242
|
+
makeVideoStream(720),
|
|
1243
|
+
makeVideoStream(1080),
|
|
1244
|
+
],
|
|
1245
|
+
audioStreams: [
|
|
1246
|
+
makeAudioStreamWithRoles('stream1', ['main']),
|
|
1247
|
+
makeAudioStreamWithRoles('stream2', ['description'], false),
|
|
1248
|
+
],
|
|
1249
|
+
textStreams: [],
|
|
1250
|
+
imageStreams: [],
|
|
1251
|
+
},
|
|
1252
|
+
];
|
|
1253
|
+
|
|
1254
|
+
await combiner.combinePeriods(periods, /* isDynamic= */ false);
|
|
1255
|
+
const variants = combiner.getVariants();
|
|
1256
|
+
|
|
1257
|
+
console.log(variants);
|
|
1258
|
+
|
|
1259
|
+
expect(variants.length).toBe(4);
|
|
1260
|
+
|
|
1261
|
+
expect(variants).toEqual(jasmine.arrayWithExactContents([
|
|
1262
|
+
makeAVVariant(720, 'en', 2, ['main']),
|
|
1263
|
+
makeAVVariant(1080, 'en', 2, ['main']),
|
|
1264
|
+
makeAVVariant(720, 'en', 2, ['description', 'main']),
|
|
1265
|
+
makeAVVariant(1080, 'en', 2, ['description', 'main']),
|
|
1266
|
+
]));
|
|
1267
|
+
|
|
1268
|
+
// We can use the originalId field to see what each track is composed of.
|
|
1269
|
+
expect(variants[0].audio.originalId)
|
|
1270
|
+
.toBe('stream1,stream1,stream1,stream1');
|
|
1271
|
+
|
|
1272
|
+
expect(variants[1].audio.originalId)
|
|
1273
|
+
.toBe('stream1,stream1,stream1,stream1');
|
|
1274
|
+
|
|
1275
|
+
expect(variants[2].audio.originalId)
|
|
1276
|
+
.toBe('stream1,stream2,stream1,stream2');
|
|
1277
|
+
|
|
1278
|
+
expect(variants[3].audio.originalId)
|
|
1279
|
+
.toBe('stream1,stream2,stream1,stream2');
|
|
1280
|
+
});
|
|
1144
1281
|
|
|
1145
1282
|
it('The number of variants stays stable after many periods ' +
|
|
1146
1283
|
'when going between similar content and varying ads', async () => {
|
|
@@ -1148,7 +1285,7 @@ describe('PeriodCombiner', () => {
|
|
|
1148
1285
|
// https://github.com/shaka-project/shaka-player/issues/2716
|
|
1149
1286
|
// that used to cause our period flattening logic to keep
|
|
1150
1287
|
// creating new variants for every new period added.
|
|
1151
|
-
// It's ok to create a few additional
|
|
1288
|
+
// It's ok to create a few additional variants/streams,
|
|
1152
1289
|
// but we should stabilize eventually and keep the number
|
|
1153
1290
|
// of variants from growing indefinitely.
|
|
1154
1291
|
|
|
@@ -1334,7 +1471,7 @@ describe('PeriodCombiner', () => {
|
|
|
1334
1471
|
expect(isCandidateBetter).toBe(WORSE);
|
|
1335
1472
|
|
|
1336
1473
|
// Make sure it works correctly whether it's the candidate or the best
|
|
1337
|
-
// value that is
|
|
1474
|
+
// value that is equal to the output.
|
|
1338
1475
|
isCandidateBetter = PeriodCombiner.compareClosestPreferLower(
|
|
1339
1476
|
/* output= */ 5, /* bestValue= */ 3, /* candidateValue= */ 5);
|
|
1340
1477
|
expect(isCandidateBetter).toBe(BETTER);
|
|
@@ -1461,11 +1598,12 @@ describe('PeriodCombiner', () => {
|
|
|
1461
1598
|
* @param {number=} channels
|
|
1462
1599
|
* @return {shaka.extern.Variant}
|
|
1463
1600
|
*/
|
|
1464
|
-
function makeAVVariant(height, language, channels = 2) {
|
|
1601
|
+
function makeAVVariant(height, language, channels = 2, roles = []) {
|
|
1465
1602
|
const variant = jasmine.objectContaining({
|
|
1466
1603
|
language,
|
|
1467
1604
|
audio: jasmine.objectContaining({
|
|
1468
1605
|
language,
|
|
1606
|
+
roles,
|
|
1469
1607
|
channelsCount: channels,
|
|
1470
1608
|
}),
|
|
1471
1609
|
video: jasmine.objectContaining({
|
|
@@ -371,5 +371,69 @@ describe('XmlUtils', () => {
|
|
|
371
371
|
expect(XmlUtils.parseFloat(HUGE_NUMBER_STRING)).toBe(Infinity);
|
|
372
372
|
expect(XmlUtils.parseFloat('-' + HUGE_NUMBER_STRING)).toBe(-Infinity);
|
|
373
373
|
});
|
|
374
|
+
|
|
375
|
+
describe('parseXmlString', () => {
|
|
376
|
+
it('parses a simple XML document', () => {
|
|
377
|
+
const xmlString = [
|
|
378
|
+
'<?xml version="1.0"?>',
|
|
379
|
+
'<Root>',
|
|
380
|
+
' <Child></Child>',
|
|
381
|
+
'</Root>',
|
|
382
|
+
].join('\n');
|
|
383
|
+
const doc = XmlUtils.parseXmlString(xmlString, 'Root');
|
|
384
|
+
expect(doc).not.toBeNull();
|
|
385
|
+
expect(doc.tagName).toBe('Root');
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('returns null on an empty XML document', () => {
|
|
389
|
+
const xmlString = '';
|
|
390
|
+
const doc = XmlUtils.parseXmlString(xmlString, 'Root');
|
|
391
|
+
expect(doc).toBeNull();
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('returns null on malformed XML', () => {
|
|
395
|
+
const xmlString = [
|
|
396
|
+
'<?xml version="1.0"?>',
|
|
397
|
+
'<Root>',
|
|
398
|
+
' <Child</Child>',
|
|
399
|
+
'</Root>',
|
|
400
|
+
].join('\n');
|
|
401
|
+
const doc = XmlUtils.parseXmlString(xmlString, 'Root');
|
|
402
|
+
expect(doc).toBeNull();
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('returns null on root element mismatch', () => {
|
|
406
|
+
const xmlString = [
|
|
407
|
+
'<?xml version="1.0"?>',
|
|
408
|
+
'<Root>',
|
|
409
|
+
' <Child></Child>',
|
|
410
|
+
'</Root>',
|
|
411
|
+
].join('\n');
|
|
412
|
+
const doc = XmlUtils.parseXmlString(xmlString, 'Document');
|
|
413
|
+
expect(doc).toBeNull();
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('returns null on XML that embeds HTML', () => {
|
|
417
|
+
const xmlString = [
|
|
418
|
+
'<?xml version="1.0"?>',
|
|
419
|
+
'<Root>',
|
|
420
|
+
' <Child xmlns="http://www.w3.org/1999/xhtml"></Child>',
|
|
421
|
+
'</Root>',
|
|
422
|
+
].join('\n');
|
|
423
|
+
const doc = XmlUtils.parseXmlString(xmlString, 'Root');
|
|
424
|
+
expect(doc).toBeNull();
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('returns null on XML that embeds SVG', () => {
|
|
428
|
+
const xmlString = [
|
|
429
|
+
'<?xml version="1.0"?>',
|
|
430
|
+
'<Root>',
|
|
431
|
+
' <Child xmlns="http://www.w3.org/2000/svg"></Child>',
|
|
432
|
+
'</Root>',
|
|
433
|
+
].join('\n');
|
|
434
|
+
const doc = XmlUtils.parseXmlString(xmlString, 'Root');
|
|
435
|
+
expect(doc).toBeNull();
|
|
436
|
+
});
|
|
437
|
+
});
|
|
374
438
|
});
|
|
375
439
|
|
package/ui/controls.js
CHANGED
|
@@ -1024,7 +1024,10 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
|
|
|
1024
1024
|
if (!this.video_ ||
|
|
1025
1025
|
this.video_.readyState == 0 ||
|
|
1026
1026
|
this.castProxy_.isCasting() ||
|
|
1027
|
-
!this.config_.enableFullscreenOnRotation
|
|
1027
|
+
!this.config_.enableFullscreenOnRotation ||
|
|
1028
|
+
!this.isFullScreenSupported()) {
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1028
1031
|
|
|
1029
1032
|
if (screen.orientation.type.includes('landscape') &&
|
|
1030
1033
|
!document.fullscreenElement) {
|
package/ui/settings_menu.js
CHANGED
|
@@ -12,6 +12,7 @@ goog.require('shaka.ui.Enums');
|
|
|
12
12
|
goog.require('shaka.ui.Utils');
|
|
13
13
|
goog.require('shaka.util.Dom');
|
|
14
14
|
goog.require('shaka.util.FakeEvent');
|
|
15
|
+
goog.require('shaka.util.Iterables');
|
|
15
16
|
goog.requireType('shaka.ui.Controls');
|
|
16
17
|
|
|
17
18
|
|
|
@@ -116,8 +117,16 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
|
|
|
116
117
|
this.eventManager.listen(this.backButton, 'click', () => {
|
|
117
118
|
shaka.ui.Utils.setDisplay(this.parent, true);
|
|
118
119
|
|
|
119
|
-
|
|
120
|
-
(
|
|
120
|
+
const isDisplayed =
|
|
121
|
+
(element) => element.classList.contains('shaka-hidden') == false;
|
|
122
|
+
|
|
123
|
+
const Iterables = shaka.util.Iterables;
|
|
124
|
+
if (Iterables.some(this.parent.childNodes, isDisplayed)) {
|
|
125
|
+
// Focus on the first visible child of the overflow menu
|
|
126
|
+
const visibleElements =
|
|
127
|
+
Iterables.filter(this.parent.childNodes, isDisplayed);
|
|
128
|
+
/** @type {!HTMLElement} */ (visibleElements[0]).focus();
|
|
129
|
+
}
|
|
121
130
|
|
|
122
131
|
// Make sure controls are displayed
|
|
123
132
|
this.controls.computeOpacity();
|