shaka-player 3.3.4 → 3.3.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.
Files changed (63) hide show
  1. package/.github/workflows/build-and-test.yaml +0 -1
  2. package/.github/workflows/release-please.yaml +1 -1
  3. package/.github/workflows/selenium-lab-tests.yaml +0 -1
  4. package/CHANGELOG.md +18 -0
  5. package/build/README.md +2 -2
  6. package/build/checkversion.py +1 -1
  7. package/build/generateTsDefs.py +0 -2
  8. package/build/test.py +7 -1
  9. package/build/types/core +0 -1
  10. package/dist/controls.css +1 -1
  11. package/dist/deps.js +1 -2
  12. package/dist/locales.js +30 -30
  13. package/dist/shaka-player.compiled.d.ts +238 -239
  14. package/dist/shaka-player.compiled.debug.d.ts +238 -239
  15. package/dist/shaka-player.compiled.debug.externs.js +1 -0
  16. package/dist/shaka-player.compiled.debug.js +149 -147
  17. package/dist/shaka-player.compiled.debug.map +4 -4
  18. package/dist/shaka-player.compiled.externs.js +1 -0
  19. package/dist/shaka-player.compiled.js +844 -842
  20. package/dist/shaka-player.compiled.map +4 -4
  21. package/dist/shaka-player.ui.d.ts +282 -283
  22. package/dist/shaka-player.ui.debug.d.ts +282 -283
  23. package/dist/shaka-player.ui.debug.externs.js +1 -0
  24. package/dist/shaka-player.ui.debug.js +222 -220
  25. package/dist/shaka-player.ui.debug.map +4 -4
  26. package/dist/shaka-player.ui.externs.js +1 -0
  27. package/dist/shaka-player.ui.js +956 -954
  28. package/dist/shaka-player.ui.map +4 -4
  29. package/karma.conf.js +4 -0
  30. package/lib/dash/dash_parser.js +2 -3
  31. package/lib/hls/hls_parser.js +23 -11
  32. package/lib/media/media_source_engine.js +7 -1
  33. package/lib/offline/indexeddb/storage_mechanism.js +4 -2
  34. package/lib/offline/storage.js +92 -91
  35. package/lib/player.js +165 -107
  36. package/lib/util/config_utils.js +25 -0
  37. package/lib/util/error.js +7 -0
  38. package/lib/util/manifest_parser_utils.js +1 -1
  39. package/lib/util/mime_utils.js +48 -1
  40. package/lib/util/periods.js +5 -4
  41. package/lib/util/player_configuration.js +9 -14
  42. package/lib/util/stream_utils.js +4 -2
  43. package/package.json +1 -1
  44. package/test/cast/cast_utils_unit.js +1 -0
  45. package/test/dash/dash_parser_manifest_unit.js +0 -24
  46. package/test/hls/hls_live_unit.js +26 -0
  47. package/test/hls/manifest_text_parser_unit.js +19 -0
  48. package/test/media/media_source_engine_integration.js +1 -0
  49. package/test/media/media_source_engine_unit.js +4 -4
  50. package/test/media/streaming_engine_integration.js +2 -0
  51. package/test/offline/indexeddb_storage_unit.js +1 -1
  52. package/test/offline/storage_compatibility_unit.js +1 -1
  53. package/test/player_external.js +7 -1
  54. package/test/player_integration.js +6 -10
  55. package/test/player_src_equals_integration.js +81 -83
  56. package/test/player_unit.js +98 -1
  57. package/test/test/boot.js +9 -0
  58. package/test/test/externs/filters.js +4 -0
  59. package/test/test/util/simple_fakes.js +31 -2
  60. package/test/util/mime_utils_unit.js +54 -0
  61. package/test/util/periods_unit.js +79 -0
  62. package/docs/tutorials/gsoc-ideas-list.md +0 -3
  63. package/lib/util/mutex.js +0 -52
@@ -17,14 +17,6 @@ goog.require('shaka.util.ManifestParserUtils');
17
17
  goog.require('shaka.util.Platform');
18
18
 
19
19
 
20
- // TODO(vaage): Many times in our configs, we need to create an empty
21
- // implementation of a method, but to avoid closure from removing unused
22
- // parameters (and breaking our merge config code) we need to use each
23
- // parameter. Is there a better solution to this problem than what we are
24
- // doing now?
25
- //
26
- // NOTE: Chrome App Content Security Policy prohibits usage of new Function()
27
-
28
20
  /**
29
21
  * @final
30
22
  * @export
@@ -109,11 +101,10 @@ shaka.util.PlayerConfiguration = class {
109
101
  'urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb':
110
102
  'com.adobe.primetime',
111
103
  },
112
- // Need some operation in the callback or else closure may remove calls
113
- // to the function as it would be a no-op. The operation can't just be
114
- // a log message, because those are stripped in the compiled build.
115
104
  manifestPreprocessor: (element) => {
116
- return element;
105
+ return shaka.util.ConfigUtils.referenceParametersAndReturn(
106
+ [element],
107
+ element);
117
108
  },
118
109
  },
119
110
  hls: {
@@ -132,7 +123,9 @@ shaka.util.PlayerConfiguration = class {
132
123
  // log message, because those are stripped in the compiled build.
133
124
  failureCallback: (error) => {
134
125
  shaka.log.error('Unhandled streaming error', error);
135
- return [error];
126
+ return shaka.util.ConfigUtils.referenceParametersAndReturn(
127
+ [error],
128
+ undefined);
136
129
  },
137
130
  // When low latency streaming is enabled, rebufferingGoal will default to
138
131
  // 0.01 if not specified.
@@ -210,7 +203,9 @@ shaka.util.PlayerConfiguration = class {
210
203
  // to the function as it would be a no-op. The operation can't just be a
211
204
  // log message, because those are stripped in the compiled build.
212
205
  progressCallback: (content, progress) => {
213
- return [content, progress];
206
+ return shaka.util.ConfigUtils.referenceParametersAndReturn(
207
+ [content, progress],
208
+ undefined);
214
209
  },
215
210
 
216
211
  // By default we use persistent licenses as forces errors to surface if
@@ -283,12 +283,14 @@ shaka.util.StreamUtils = class {
283
283
  // both be considered the same codec: avc1.42c01e, avc1.4d401f
284
284
  let baseVideoCodec = '';
285
285
  if (variant.video) {
286
- baseVideoCodec = shaka.util.MimeUtils.getCodecBase(variant.video.codecs);
286
+ baseVideoCodec =
287
+ shaka.util.MimeUtils.getNormalizedCodec(variant.video.codecs);
287
288
  }
288
289
 
289
290
  let baseAudioCodec = '';
290
291
  if (variant.audio) {
291
- baseAudioCodec = shaka.util.MimeUtils.getCodecBase(variant.audio.codecs);
292
+ baseAudioCodec =
293
+ shaka.util.MimeUtils.getNormalizedCodec(variant.audio.codecs);
292
294
  }
293
295
 
294
296
  return baseVideoCodec + '-' + baseAudioCodec;
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.3.4",
4
+ "version": "3.3.5",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
@@ -189,6 +189,7 @@ describe('CastUtils', () => {
189
189
  const fakeVideoStream = {
190
190
  mimeType: 'video/mp4',
191
191
  codecs: 'avc1.42c01e',
192
+ drmInfos: [],
192
193
  };
193
194
  const initSegmentUrl = '/base/test/test/assets/sintel-video-init.mp4';
194
195
  const videoSegmentUrl =
@@ -447,30 +447,6 @@ describe('DashParser Manifest', () => {
447
447
  expect(stream.closedCaptions).toEqual(expectedClosedCaptions);
448
448
  });
449
449
 
450
- it('Detects E-AC3 JOC content by SupplementalProperty', async () => {
451
- const idUri = 'tag:dolby.com,2018:dash:EC3_ExtensionType:2018';
452
- const source = [
453
- '<MPD>',
454
- ' <Period duration="PT30M">',
455
- ' <AdaptationSet mimeType="audio/mp4" lang="\u2603">',
456
- ' <Representation bandwidth="500">',
457
- ' <SupplementalProperty schemeIdUri="' + idUri + '" value="JOC"/>',
458
- ' <BaseURL>http://example.com</BaseURL>',
459
- ' <SegmentTemplate media="2.mp4" duration="1" />',
460
- ' </Representation>',
461
- ' </AdaptationSet>',
462
- ' </Period>',
463
- '</MPD>',
464
- ].join('\n');
465
-
466
- fakeNetEngine.setResponseText('dummy://foo', source);
467
-
468
- /** @type {shaka.extern.Manifest} */
469
- const manifest = await parser.start('dummy://foo', playerInterface);
470
- const stream = manifest.variants[0].audio;
471
- expect(stream.mimeType).toBe('audio/eac3-joc');
472
- });
473
-
474
450
  it('Detects spatial audio', async () => {
475
451
  const idUri = 'tag:dolby.com,2018:dash:EC3_ExtensionType:2018';
476
452
  const source = [
@@ -699,6 +699,32 @@ describe('HlsParser live', () => {
699
699
  ManifestParser.verifySegmentIndex(video, [ref, ref2]);
700
700
  });
701
701
 
702
+ // Test for https://github.com/shaka-project/shaka-player/issues/4185
703
+ it('does not fail on preload hints with LL mode off', async () => {
704
+ // LL mode must be off for this test!
705
+ playerInterface.isLowLatencyMode = () => false;
706
+
707
+ const mediaWithPartialSegments = [
708
+ '#EXTM3U\n',
709
+ '#EXT-X-TARGETDURATION:5\n',
710
+ '#EXT-X-MAP:URI="init.mp4",BYTERANGE="616@0"\n',
711
+ '#EXTINF:4,\n',
712
+ 'main.mp4\n',
713
+ '#EXT-X-PART:DURATION=2,URI="partial.mp4",BYTERANGE=210@0\n',
714
+ '#EXT-X-PRELOAD-HINT:TYPE=PART,URI="partial.mp4",BYTERANGE-START=210\n',
715
+ ].join('');
716
+
717
+ fakeNetEngine
718
+ .setResponseText('test:/master', master)
719
+ .setResponseText('test:/video', mediaWithPartialSegments)
720
+ .setResponseValue('test:/init.mp4', initSegmentData)
721
+ .setResponseValue('test:/main.mp4', segmentData)
722
+ .setResponseValue('test:/partial.mp4', segmentData);
723
+
724
+ // If this throws, the test fails. Otherwise, it passes.
725
+ await parser.start('test:/master', playerInterface);
726
+ });
727
+
702
728
  describe('update', () => {
703
729
  it('adds new segments when they appear', async () => {
704
730
  const ref1 = ManifestParser.makeReference('test:/main.mp4', 2, 4);
@@ -238,6 +238,25 @@ describe('ManifestTextParser', () => {
238
238
  '#EXTM3U\n' +
239
239
  '#EXT-X-MEDIA:CODECS="avc1.64002a,mp4a.40.2",AUDIO="a1,a2"',
240
240
 
241
+ // manifest URI:
242
+ 'https://test/manifest.m3u8');
243
+
244
+ verifyPlaylist(
245
+ {
246
+ type: shaka.hls.PlaylistType.MASTER,
247
+ tags: [
248
+ new shaka.hls.Tag(/* id= */ 3, 'EXT-X-MEDIA',
249
+ [
250
+ new shaka.hls.Attribute('CODECS',
251
+ 'av01.0.08M.08,mp4a.40.2'),
252
+ ]),
253
+ ],
254
+ },
255
+
256
+ // playlist text:
257
+ '#EXTM3U\n' +
258
+ '#EXT-X-MEDIA:CODECS="av01.0.08M.08,mp4a.40.2"',
259
+
241
260
  // manifest URI:
242
261
  'https://test/manifest.m3u8');
243
262
  });
@@ -103,6 +103,7 @@ describe('MediaSourceEngine', () => {
103
103
  return {
104
104
  mimeType: streamMetadata.mimeType,
105
105
  codecs: streamMetadata.codecs,
106
+ drmInfos: [],
106
107
  };
107
108
  }
108
109
 
@@ -49,10 +49,10 @@ describe('MediaSourceEngine', () => {
49
49
  const buffer2 = /** @type {!ArrayBuffer} */ (/** @type {?} */ (2));
50
50
  const buffer3 = /** @type {!ArrayBuffer} */ (/** @type {?} */ (3));
51
51
 
52
- const fakeVideoStream = {mimeType: 'video/foo'};
53
- const fakeAudioStream = {mimeType: 'audio/foo'};
54
- const fakeTextStream = {mimeType: 'text/foo'};
55
- const fakeTransportStream = {mimeType: 'tsMimetype'};
52
+ const fakeVideoStream = {mimeType: 'video/foo', drmInfos: []};
53
+ const fakeAudioStream = {mimeType: 'audio/foo', drmInfos: []};
54
+ const fakeTextStream = {mimeType: 'text/foo', drmInfos: []};
55
+ const fakeTransportStream = {mimeType: 'tsMimetype', drmInfos: []};
56
56
 
57
57
  let audioSourceBuffer;
58
58
  let videoSourceBuffer;
@@ -622,6 +622,7 @@ describe('StreamingEngine', () => {
622
622
  width: 600,
623
623
  height: 400,
624
624
  type: shaka.util.ManifestParserUtils.ContentType.VIDEO,
625
+ drmInfos: [],
625
626
  },
626
627
  audio: {
627
628
  id: 3,
@@ -631,6 +632,7 @@ describe('StreamingEngine', () => {
631
632
  codecs: 'mp4a.40.2',
632
633
  bandwidth: 192000,
633
634
  type: shaka.util.ManifestParserUtils.ContentType.AUDIO,
635
+ drmInfos: [],
634
636
  },
635
637
  }],
636
638
  };
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- filterDescribe('IndexeddbStorageCell', () => window.indexedDB, () => {
7
+ filterDescribe('IndexeddbStorageCell', offlineSupported, () => {
8
8
  const IndexedDBUtils = shaka.test.IndexedDBUtils;
9
9
  const OfflineUtils = shaka.test.OfflineUtils;
10
10
  const Util = shaka.test.Util;
@@ -91,7 +91,7 @@ const compatibilityTestsMetadata = [
91
91
  },
92
92
  ];
93
93
 
94
- filterDescribe('Storage Compatibility', () => window.indexedDB, () => {
94
+ filterDescribe('Storage Compatibility', offlineSupported, () => {
95
95
  for (const metadata of compatibilityTestsMetadata) {
96
96
  describe(metadata.name, () => {
97
97
  makeTests(metadata);
@@ -120,7 +120,13 @@ describe('Player', () => {
120
120
  const networkingEngine = player.getNetworkingEngine();
121
121
  asset.applyFilters(networkingEngine);
122
122
 
123
- await player.load(asset.manifestUri);
123
+ // Rather than awaiting the load() method, catch any load() errors and
124
+ // wait on the 'canplay' event. This has the advantage that we will
125
+ // get better logging of the media state on a timeout, since that
126
+ // capabilitiy is built into the waiter for media element events.
127
+ player.load(asset.manifestUri).catch(fail);
128
+ await waiter.timeoutAfter(60).waitForEvent(video, 'canplay');
129
+
124
130
  if (asset.features) {
125
131
  const isLive = asset.features.includes(Feature.LIVE);
126
132
  expect(player.isLive()).toBe(isLive);
@@ -1053,16 +1053,16 @@ describe('Player', () => {
1053
1053
  });
1054
1054
  }); // describe('unloading')
1055
1055
 
1056
- describe('chapters', () => {
1057
- it('add external chapters in vtt format', async () => {
1056
+ describe('addChaptersTrack', () => {
1057
+ it('adds external chapters in vtt format', async () => {
1058
1058
  await player.load('test:sintel_no_text_compiled');
1059
1059
  const locationUri = new goog.Uri(location.href);
1060
1060
  const partialUri1 = new goog.Uri('/base/test/test/assets/chapters.vtt');
1061
1061
  const absoluteUri1 = locationUri.resolve(partialUri1);
1062
1062
  await player.addChaptersTrack(absoluteUri1.toString(), 'en');
1063
1063
 
1064
- await shaka.test.Util.delay(1.5);
1065
-
1064
+ // Data should be available as soon as addChaptersTrack resolves.
1065
+ // See https://github.com/shaka-project/shaka-player/issues/4186
1066
1066
  const chapters = player.getChapters('en');
1067
1067
  expect(chapters.length).toBe(3);
1068
1068
  const chapter1 = chapters[0];
@@ -1082,8 +1082,6 @@ describe('Player', () => {
1082
1082
  const absoluteUri2 = locationUri.resolve(partialUri2);
1083
1083
  await player.addChaptersTrack(absoluteUri2.toString(), 'en');
1084
1084
 
1085
- await shaka.test.Util.delay(1.5);
1086
-
1087
1085
  const chaptersUpdated = player.getChapters('en');
1088
1086
  expect(chaptersUpdated.length).toBe(6);
1089
1087
  const chapterUpdated1 = chaptersUpdated[0];
@@ -1112,15 +1110,13 @@ describe('Player', () => {
1112
1110
  expect(chapterUpdated6.endTime).toBe(61.349);
1113
1111
  });
1114
1112
 
1115
- it('add external chapters in srt format', async () => {
1113
+ it('adds external chapters in srt format', async () => {
1116
1114
  await player.load('test:sintel_no_text_compiled');
1117
1115
  const locationUri = new goog.Uri(location.href);
1118
1116
  const partialUri = new goog.Uri('/base/test/test/assets/chapters.srt');
1119
1117
  const absoluteUri = locationUri.resolve(partialUri);
1120
1118
  await player.addChaptersTrack(absoluteUri.toString(), 'es');
1121
1119
 
1122
- await shaka.test.Util.delay(1.5);
1123
-
1124
1120
  const chapters = player.getChapters('es');
1125
1121
  expect(chapters.length).toBe(3);
1126
1122
  const chapter1 = chapters[0];
@@ -1136,5 +1132,5 @@ describe('Player', () => {
1136
1132
  expect(chapter3.startTime).toBe(30);
1137
1133
  expect(chapter3.endTime).toBe(61.349);
1138
1134
  });
1139
- }); // describe('chapters')
1135
+ }); // describe('addChaptersTrack')
1140
1136
  });
@@ -319,90 +319,88 @@ describe('Player Src Equals', () => {
319
319
  expect(newTrack).toBeTruthy();
320
320
  });
321
321
 
322
- it('add external chapters in vtt format', async () => {
323
- await loadWithSrcEquals(SMALL_MP4_CONTENT_URI, /* startTime= */ null);
324
-
325
- const locationUri = new goog.Uri(location.href);
326
- const partialUri1 = new goog.Uri('/base/test/test/assets/chapters.vtt');
327
- const absoluteUri1 = locationUri.resolve(partialUri1);
328
- await player.addChaptersTrack(absoluteUri1.toString(), 'en');
329
-
330
- await shaka.test.Util.delay(1.5);
331
-
332
- const chapters = player.getChapters('en');
333
- expect(chapters.length).toBe(3);
334
- const chapter1 = chapters[0];
335
- expect(chapter1.title).toBe('Chapter 1');
336
- expect(chapter1.startTime).toBe(0);
337
- expect(chapter1.endTime).toBe(5);
338
- const chapter2 = chapters[1];
339
- expect(chapter2.title).toBe('Chapter 2');
340
- expect(chapter2.startTime).toBe(5);
341
- expect(chapter2.endTime).toBe(10);
342
- const chapter3 = chapters[2];
343
- expect(chapter3.title).toBe('Chapter 3');
344
- expect(chapter3.startTime).toBe(10);
345
- expect(chapter3.endTime).toBe(20);
346
-
347
- const partialUri2 = new goog.Uri('/base/test/test/assets/chapters2.vtt');
348
- const absoluteUri2 = locationUri.resolve(partialUri2);
349
- await player.addChaptersTrack(absoluteUri2.toString(), 'en');
350
-
351
- await shaka.test.Util.delay(1.5);
352
-
353
- const chaptersUpdated = player.getChapters('en');
354
- expect(chaptersUpdated.length).toBe(6);
355
- const chapterUpdated1 = chaptersUpdated[0];
356
- expect(chapterUpdated1.title).toBe('Chapter 1');
357
- expect(chapterUpdated1.startTime).toBe(0);
358
- expect(chapterUpdated1.endTime).toBe(5);
359
- const chapterUpdated2 = chaptersUpdated[1];
360
- expect(chapterUpdated2.title).toBe('Chapter 2');
361
- expect(chapterUpdated2.startTime).toBe(5);
362
- expect(chapterUpdated2.endTime).toBe(10);
363
- const chapterUpdated3 = chaptersUpdated[2];
364
- expect(chapterUpdated3.title).toBe('Chapter 3');
365
- expect(chapterUpdated3.startTime).toBe(10);
366
- expect(chapterUpdated3.endTime).toBe(20);
367
- const chapterUpdated4 = chaptersUpdated[3];
368
- expect(chapterUpdated4.title).toBe('Chapter 4');
369
- expect(chapterUpdated4.startTime).toBe(20);
370
- expect(chapterUpdated4.endTime).toBe(30);
371
- const chapterUpdated5 = chaptersUpdated[4];
372
- expect(chapterUpdated5.title).toBe('Chapter 5');
373
- expect(chapterUpdated5.startTime).toBe(30);
374
- expect(chapterUpdated5.endTime).toBe(40);
375
- const chapterUpdated6 = chaptersUpdated[5];
376
- expect(chapterUpdated6.title).toBe('Chapter 6');
377
- expect(chapterUpdated6.startTime).toBe(40);
378
- expect(chapterUpdated6.endTime).toBe(61.349);
379
- });
380
-
381
- it('add external chapters in srt format', async () => {
382
- await loadWithSrcEquals(SMALL_MP4_CONTENT_URI, /* startTime= */ null);
383
-
384
- const locationUri = new goog.Uri(location.href);
385
- const partialUri = new goog.Uri('/base/test/test/assets/chapters.srt');
386
- const absoluteUri = locationUri.resolve(partialUri);
387
- await player.addChaptersTrack(absoluteUri.toString(), 'es');
388
-
389
- await shaka.test.Util.delay(1.5);
322
+ describe('addChaptersTrack', () => {
323
+ it('adds external chapters in vtt format', async () => {
324
+ await loadWithSrcEquals(SMALL_MP4_CONTENT_URI, /* startTime= */ null);
325
+
326
+ const locationUri = new goog.Uri(location.href);
327
+ const partialUri1 = new goog.Uri('/base/test/test/assets/chapters.vtt');
328
+ const absoluteUri1 = locationUri.resolve(partialUri1);
329
+ await player.addChaptersTrack(absoluteUri1.toString(), 'en');
330
+
331
+ // Data should be available as soon as addChaptersTrack resolves.
332
+ // See https://github.com/shaka-project/shaka-player/issues/4186
333
+ const chapters = player.getChapters('en');
334
+ expect(chapters.length).toBe(3);
335
+ const chapter1 = chapters[0];
336
+ expect(chapter1.title).toBe('Chapter 1');
337
+ expect(chapter1.startTime).toBe(0);
338
+ expect(chapter1.endTime).toBe(5);
339
+ const chapter2 = chapters[1];
340
+ expect(chapter2.title).toBe('Chapter 2');
341
+ expect(chapter2.startTime).toBe(5);
342
+ expect(chapter2.endTime).toBe(10);
343
+ const chapter3 = chapters[2];
344
+ expect(chapter3.title).toBe('Chapter 3');
345
+ expect(chapter3.startTime).toBe(10);
346
+ expect(chapter3.endTime).toBe(20);
347
+
348
+ const partialUri2 = new goog.Uri('/base/test/test/assets/chapters2.vtt');
349
+ const absoluteUri2 = locationUri.resolve(partialUri2);
350
+ await player.addChaptersTrack(absoluteUri2.toString(), 'en');
351
+
352
+ const chaptersUpdated = player.getChapters('en');
353
+ expect(chaptersUpdated.length).toBe(6);
354
+ const chapterUpdated1 = chaptersUpdated[0];
355
+ expect(chapterUpdated1.title).toBe('Chapter 1');
356
+ expect(chapterUpdated1.startTime).toBe(0);
357
+ expect(chapterUpdated1.endTime).toBe(5);
358
+ const chapterUpdated2 = chaptersUpdated[1];
359
+ expect(chapterUpdated2.title).toBe('Chapter 2');
360
+ expect(chapterUpdated2.startTime).toBe(5);
361
+ expect(chapterUpdated2.endTime).toBe(10);
362
+ const chapterUpdated3 = chaptersUpdated[2];
363
+ expect(chapterUpdated3.title).toBe('Chapter 3');
364
+ expect(chapterUpdated3.startTime).toBe(10);
365
+ expect(chapterUpdated3.endTime).toBe(20);
366
+ const chapterUpdated4 = chaptersUpdated[3];
367
+ expect(chapterUpdated4.title).toBe('Chapter 4');
368
+ expect(chapterUpdated4.startTime).toBe(20);
369
+ expect(chapterUpdated4.endTime).toBe(30);
370
+ const chapterUpdated5 = chaptersUpdated[4];
371
+ expect(chapterUpdated5.title).toBe('Chapter 5');
372
+ expect(chapterUpdated5.startTime).toBe(30);
373
+ expect(chapterUpdated5.endTime).toBe(40);
374
+ const chapterUpdated6 = chaptersUpdated[5];
375
+ expect(chapterUpdated6.title).toBe('Chapter 6');
376
+ expect(chapterUpdated6.startTime).toBe(40);
377
+ expect(chapterUpdated6.endTime).toBe(61.349);
378
+ });
390
379
 
391
- const chapters = player.getChapters('es');
392
- expect(chapters.length).toBe(3);
393
- const chapter1 = chapters[0];
394
- expect(chapter1.title).toBe('Chapter 1');
395
- expect(chapter1.startTime).toBe(0);
396
- expect(chapter1.endTime).toBe(5);
397
- const chapter2 = chapters[1];
398
- expect(chapter2.title).toBe('Chapter 2');
399
- expect(chapter2.startTime).toBe(5);
400
- expect(chapter2.endTime).toBe(30);
401
- const chapter3 = chapters[2];
402
- expect(chapter3.title).toBe('Chapter 3');
403
- expect(chapter3.startTime).toBe(30);
404
- expect(chapter3.endTime).toBe(61.349);
405
- });
380
+ it('add external chapters in srt format', async () => {
381
+ await loadWithSrcEquals(SMALL_MP4_CONTENT_URI, /* startTime= */ null);
382
+
383
+ const locationUri = new goog.Uri(location.href);
384
+ const partialUri = new goog.Uri('/base/test/test/assets/chapters.srt');
385
+ const absoluteUri = locationUri.resolve(partialUri);
386
+ await player.addChaptersTrack(absoluteUri.toString(), 'es');
387
+
388
+ const chapters = player.getChapters('es');
389
+ expect(chapters.length).toBe(3);
390
+ const chapter1 = chapters[0];
391
+ expect(chapter1.title).toBe('Chapter 1');
392
+ expect(chapter1.startTime).toBe(0);
393
+ expect(chapter1.endTime).toBe(5);
394
+ const chapter2 = chapters[1];
395
+ expect(chapter2.title).toBe('Chapter 2');
396
+ expect(chapter2.startTime).toBe(5);
397
+ expect(chapter2.endTime).toBe(30);
398
+ const chapter3 = chapters[2];
399
+ expect(chapter3.title).toBe('Chapter 3');
400
+ expect(chapter3.startTime).toBe(30);
401
+ expect(chapter3.endTime).toBe(61.349);
402
+ });
403
+ }); // describe('addChaptersTrack')
406
404
 
407
405
  // Since we are not in-charge of streaming, calling |retryStreaming| should
408
406
  // have no effect.
@@ -122,7 +122,13 @@ describe('Player', () => {
122
122
 
123
123
  player.createDrmEngine = () => drmEngine;
124
124
  player.createNetworkingEngine = () => networkingEngine;
125
- player.createPlayhead = () => playhead;
125
+ player.createPlayhead = (startTime) => {
126
+ const callableSetStartTime =
127
+ shaka.test.Util.spyFunc(playhead.setStartTime);
128
+ callableSetStartTime(startTime);
129
+ playhead.setStartTime.calls.reset();
130
+ return playhead;
131
+ };
126
132
  player.createMediaSourceEngine = () => mediaSourceEngine;
127
133
  player.createStreamingEngine = () => streamingEngine;
128
134
  }
@@ -154,6 +160,7 @@ describe('Player', () => {
154
160
  window.MediaSource.isTypeSupported = originalIsTypeSupported;
155
161
  shaka.media.ManifestParser.unregisterParserByMime(fakeMimeType);
156
162
  navigator.mediaCapabilities.decodingInfo = originalDecodingInfo;
163
+ onError.calls.reset();
157
164
  }
158
165
  });
159
166
 
@@ -2632,6 +2639,51 @@ describe('Player', () => {
2632
2639
  expect(activeVariant.id).toBe(1);
2633
2640
  });
2634
2641
 
2642
+ // Regression test for https://github.com/shaka-project/shaka-player/issues/4190
2643
+ it('throws only one RESTRICTIONS_CANNOT_BE_MET error', async () => {
2644
+ manifest = shaka.test.ManifestGenerator.generate((manifest) => {
2645
+ manifest.addVariant(0, (variant) => {
2646
+ variant.addVideo(1, (stream) => {
2647
+ stream.keyIds = new Set(['abc']);
2648
+ });
2649
+ });
2650
+ });
2651
+
2652
+ // Check that error is RESTRICTIONS_CANNOT_BE_MET
2653
+ onError.and.callFake((e) => {
2654
+ const error = e.detail;
2655
+ shaka.test.Util.expectToEqualError(
2656
+ error,
2657
+ new shaka.util.Error(
2658
+ shaka.util.Error.Severity.CRITICAL,
2659
+ shaka.util.Error.Category.MANIFEST,
2660
+ shaka.util.Error.Code.RESTRICTIONS_CANNOT_BE_MET, {
2661
+ hasAppRestrictions: false,
2662
+ missingKeys: ['abc'],
2663
+ restrictedKeyStatuses: [],
2664
+ }));
2665
+ });
2666
+
2667
+ await player.load(fakeManifestUri, 0, fakeMimeType);
2668
+ const activeVariant = getActiveVariantTrack();
2669
+ expect(activeVariant.id).toBe(0);
2670
+
2671
+ abrManager.chooseIndex = 0;
2672
+ abrManager.chooseVariant.calls.reset();
2673
+
2674
+ onKeyStatus({'abc': 'output-restricted'});
2675
+
2676
+ // Ensure that RESTRICTIONS_CANNOT_BE_MET is thrown once
2677
+ expect(onError).toHaveBeenCalledTimes(1);
2678
+
2679
+ // It does not call chooseVariant
2680
+ expect(abrManager.chooseVariant).not.toHaveBeenCalled();
2681
+
2682
+ // The first variant is disallowed.
2683
+ expect(manifest.variants[0].id).toBe(0);
2684
+ expect(manifest.variants[0].allowedByKeySystem).toBe(false);
2685
+ });
2686
+
2635
2687
  it('doesn\'t switch if the active stream isn\'t restricted', async () => {
2636
2688
  manifest = shaka.test.ManifestGenerator.generate((manifest) => {
2637
2689
  manifest.addVariant(0, (variant) => {
@@ -3638,6 +3690,51 @@ describe('Player', () => {
3638
3690
  });
3639
3691
  });
3640
3692
 
3693
+ describe('config streaming.startAtSegmentBoundary', () => {
3694
+ // Test for https://github.com/shaka-project/shaka-player/issues/4188
3695
+ // In that issue, using streaming.startAtSegmentBoundary in v4.0.0 caused
3696
+ // an exception due to the use of a removed method.
3697
+ it('adjusts start time', async () => {
3698
+ player.configure('streaming.startAtSegmentBoundary', true);
3699
+
3700
+ // In order to adjust the start time to a segment boundary, we need
3701
+ // segment descriptions in the segment index. So create a non-default
3702
+ // fake manifest.
3703
+ const timeline = new shaka.media.PresentationTimeline(300, 0);
3704
+ timeline.setStatic(true);
3705
+ // This duration is used by useSegmentTemplate below to decide how many
3706
+ // references to generate.
3707
+ timeline.setDuration(300);
3708
+ manifest = shaka.test.ManifestGenerator.generate((manifest) => {
3709
+ manifest.presentationTimeline = timeline;
3710
+ manifest.addVariant(0, (variant) => {
3711
+ variant.addVideo(1, (stream) => {
3712
+ stream.useSegmentTemplate(
3713
+ '$Number$.mp4', /* segmentDuration= */ 10);
3714
+ });
3715
+ });
3716
+ });
3717
+
3718
+ await player.load(fakeManifestUri, 12, fakeMimeType);
3719
+
3720
+ expect(playhead.setStartTime).toHaveBeenCalledWith(10);
3721
+ });
3722
+
3723
+ it('does not fail with no segments', async () => {
3724
+ player.configure('streaming.startAtSegmentBoundary', true);
3725
+
3726
+ // Without useSegmentTemplate in the fake manifest, the call to
3727
+ // getIteratorForTime() in Player produces a null iterator. Using the
3728
+ // default fake manifest should cover that case. But just to make sure,
3729
+ // verify that we have no segments before calling load().
3730
+ const variant = manifest.variants[0];
3731
+ expect(variant.video.segmentIndex.getIteratorForTime(0)).toBeNull();
3732
+ expect(variant.audio.segmentIndex.getIteratorForTime(0)).toBeNull();
3733
+
3734
+ await player.load(fakeManifestUri, 0, fakeMimeType);
3735
+ });
3736
+ });
3737
+
3641
3738
  /**
3642
3739
  * Gets the currently active variant track.
3643
3740
  * @return {shaka.extern.Track}
package/test/test/boot.js CHANGED
@@ -242,6 +242,15 @@ window.xfilterDescribe = (describeName, cond, describeBody) => {
242
242
  window['describe'] = oldDescribe;
243
243
  };
244
244
 
245
+ /**
246
+ * A very short alias for filtering offline integration tests.
247
+ *
248
+ * @return {boolean}
249
+ */
250
+ window.offlineSupported = () => {
251
+ return shaka.offline.StorageMuxer.support();
252
+ };
253
+
245
254
  /**
246
255
  * Load node modules used in testing and install them into window.
247
256
  * @return {!Promise}
@@ -38,3 +38,7 @@ var filterDescribe = function(name, cond, callback) {};
38
38
  * @param {function()} callback
39
39
  */
40
40
  var xfilterDescribe = function(name, cond, callback) {};
41
+
42
+
43
+ /** @return {boolean} */
44
+ var offlineSupported = function() {};