shaka-player 3.2.0 → 3.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.
Files changed (162) hide show
  1. package/.github/workflows/build_and_test.yaml +73 -0
  2. package/.github/workflows/release.yaml +53 -0
  3. package/AUTHORS +3 -0
  4. package/CHANGELOG.md +182 -1
  5. package/CONTRIBUTORS +3 -0
  6. package/README.md +4 -4
  7. package/build/checkversion.py +1 -1
  8. package/build/generateExterns.js +1 -1
  9. package/build/misspellings.txt +1 -0
  10. package/build/shakaBuildHelpers.py +6 -5
  11. package/build/subprocessWindowsPatch.py +103 -0
  12. package/build/test.py +6 -0
  13. package/demo/common/assets.js +1 -1
  14. package/demo/index.html +1 -1
  15. package/dist/controls.css +2 -2
  16. package/dist/controls.css.map +1 -1
  17. package/dist/demo.compiled.debug.js +1 -1
  18. package/dist/demo.compiled.js +1 -1
  19. package/dist/deps.js +8 -8
  20. package/dist/locales.js +37 -37
  21. package/dist/receiver.compiled.debug.js +1 -1
  22. package/dist/receiver.compiled.js +1 -1
  23. package/dist/shaka-player.compiled.d.ts +195 -5
  24. package/dist/shaka-player.compiled.debug.d.ts +195 -5
  25. package/dist/shaka-player.compiled.debug.externs.js +226 -14
  26. package/dist/shaka-player.compiled.debug.js +424 -399
  27. package/dist/shaka-player.compiled.debug.map +4 -4
  28. package/dist/shaka-player.compiled.externs.js +226 -14
  29. package/dist/shaka-player.compiled.js +826 -812
  30. package/dist/shaka-player.compiled.map +4 -4
  31. package/dist/shaka-player.ui.d.ts +197 -16
  32. package/dist/shaka-player.ui.debug.d.ts +197 -16
  33. package/dist/shaka-player.ui.debug.externs.js +230 -27
  34. package/dist/shaka-player.ui.debug.js +466 -442
  35. package/dist/shaka-player.ui.debug.map +4 -4
  36. package/dist/shaka-player.ui.externs.js +230 -27
  37. package/dist/shaka-player.ui.js +946 -932
  38. package/dist/shaka-player.ui.map +4 -4
  39. package/docs/tutorials/fairplay.md +1 -1
  40. package/docs/tutorials/faq.md +14 -0
  41. package/docs/tutorials/ui.md +5 -5
  42. package/externs/ima.js +4 -0
  43. package/externs/shaka/ads.js +25 -0
  44. package/externs/shaka/player.js +8 -0
  45. package/externs/shaka/text.js +10 -0
  46. package/karma.conf.js +20 -15
  47. package/lib/ads/ad_manager.js +46 -26
  48. package/lib/ads/client_side_ad_manager.js +82 -88
  49. package/lib/ads/server_side_ad_manager.js +45 -13
  50. package/lib/cast/cast_proxy.js +6 -2
  51. package/lib/cast/cast_receiver.js +5 -1
  52. package/lib/cast/cast_sender.js +2 -2
  53. package/lib/cea/sei_processor.js +24 -17
  54. package/lib/dash/dash_parser.js +131 -24
  55. package/lib/dash/segment_list.js +1 -1
  56. package/lib/dash/segment_template.js +1 -1
  57. package/lib/hls/hls_parser.js +74 -17
  58. package/lib/hls/manifest_text_parser.js +1 -0
  59. package/lib/media/closed_caption_parser.js +3 -1
  60. package/lib/media/content_workarounds.js +12 -0
  61. package/lib/media/drm_engine.js +20 -1
  62. package/lib/media/gap_jumping_controller.js +8 -4
  63. package/lib/media/media_source_engine.js +1 -2
  64. package/lib/media/playhead.js +1 -1
  65. package/lib/media/region_observer.js +39 -33
  66. package/lib/media/region_timeline.js +17 -19
  67. package/lib/media/segment_index.js +2 -1
  68. package/lib/media/segment_reference.js +19 -1
  69. package/lib/media/streaming_engine.js +8 -4
  70. package/lib/net/networking_engine.js +6 -1
  71. package/lib/offline/download_manager.js +1 -2
  72. package/lib/offline/storage.js +8 -9
  73. package/lib/player.js +129 -59
  74. package/lib/polyfill/aria.js +12 -2
  75. package/lib/polyfill/encryption_scheme.js +2 -0
  76. package/lib/polyfill/fullscreen.js +2 -0
  77. package/lib/polyfill/mathround.js +2 -0
  78. package/lib/polyfill/media_capabilities.js +73 -21
  79. package/lib/polyfill/mediasource.js +8 -0
  80. package/lib/polyfill/orientation.js +3 -1
  81. package/lib/polyfill/patchedmediakeys_apple.js +6 -4
  82. package/lib/polyfill/patchedmediakeys_ms.js +6 -4
  83. package/lib/polyfill/patchedmediakeys_nop.js +2 -0
  84. package/lib/polyfill/patchedmediakeys_webkit.js +6 -4
  85. package/lib/polyfill/pip_webkit.js +2 -0
  86. package/lib/polyfill/storage_estimate.js +2 -0
  87. package/lib/polyfill/video_play_promise.js +2 -0
  88. package/lib/polyfill/videoplaybackquality.js +2 -0
  89. package/lib/polyfill/vttcue.js +2 -0
  90. package/lib/text/cue.js +6 -0
  91. package/lib/text/mp4_ttml_parser.js +3 -0
  92. package/lib/text/text_engine.js +14 -2
  93. package/lib/text/ttml_text_parser.js +135 -87
  94. package/lib/text/ui_text_displayer.js +213 -80
  95. package/lib/text/vtt_text_parser.js +4 -2
  96. package/lib/text/web_vtt_generator.js +21 -12
  97. package/lib/util/fake_event.js +53 -7
  98. package/lib/util/fake_event_target.js +21 -1
  99. package/lib/util/mp4_box_parsers.js +1 -1
  100. package/lib/util/periods.js +4 -1
  101. package/lib/util/platform.js +13 -1
  102. package/lib/util/stream_utils.js +105 -13
  103. package/lib/util/xml_utils.js +50 -12
  104. package/package.json +3 -6
  105. package/roadmap.md +24 -22
  106. package/test/cast/cast_proxy_unit.js +12 -6
  107. package/test/cast/cast_receiver_integration.js +1 -1
  108. package/test/cast/cast_utils_unit.js +1 -1
  109. package/test/cea/mp4_cea_parser_unit.js +26 -0
  110. package/test/dash/dash_parser_live_unit.js +43 -0
  111. package/test/dash/dash_parser_manifest_unit.js +222 -3
  112. package/test/hls/hls_parser_unit.js +79 -1
  113. package/test/media/closed_caption_parser_unit.js +20 -0
  114. package/test/media/drm_engine_integration.js +86 -2
  115. package/test/media/drm_engine_unit.js +57 -0
  116. package/test/media/playhead_unit.js +27 -1
  117. package/test/media/region_observer_unit.js +40 -5
  118. package/test/media/region_timeline_unit.js +40 -22
  119. package/test/media/streaming_engine_integration.js +2 -1
  120. package/test/media/streaming_engine_unit.js +145 -0
  121. package/test/player_integration.js +79 -8
  122. package/test/player_src_equals_integration.js +41 -8
  123. package/test/player_unit.js +14 -4
  124. package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
  125. package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
  126. package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
  127. package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
  128. package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
  129. package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
  130. package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
  131. package/test/test/assets/3675/dash_0.mpd +30 -0
  132. package/test/test/assets/3675/dash_1.mpd +30 -0
  133. package/test/test/assets/3675/dash_2.mpd +30 -0
  134. package/test/test/assets/3675/dash_3.mpd +30 -0
  135. package/test/test/assets/3675/dash_4.mpd +30 -0
  136. package/test/test/assets/3675/dash_5.mpd +26 -0
  137. package/test/test/assets/3675/init-stream0.m4s +0 -0
  138. package/test/test/assets/chapters.vtt +2 -2
  139. package/test/test/assets/chapters2.vtt +10 -0
  140. package/test/test/assets/empty_caption_video_init.mp4 +0 -0
  141. package/test/test/assets/empty_caption_video_segment.mp4 +0 -0
  142. package/test/test/util/fake_ad_manager.js +11 -1
  143. package/test/test/util/ttml_utils.js +81 -0
  144. package/test/test/util/util.js +10 -7
  145. package/test/text/mp4_ttml_parser_unit.js +11 -18
  146. package/test/text/ttml_text_parser_unit.js +542 -220
  147. package/test/text/ui_text_displayer_unit.js +93 -20
  148. package/test/text/vtt_text_parser_unit.js +17 -1
  149. package/test/text/web_vtt_generator_unit.js +58 -3
  150. package/test/ui/localization_unit.js +15 -14
  151. package/test/ui/text_displayer_layout_unit.js +21 -8
  152. package/test/util/mp4_box_parsers_unit.js +28 -0
  153. package/test/util/stream_utils_unit.js +60 -3
  154. package/ui/cast_button.js +2 -3
  155. package/ui/controls.js +11 -6
  156. package/ui/less/buttons.less +0 -4
  157. package/ui/less/containers.less +6 -7
  158. package/ui/locales/ru.json +6 -6
  159. package/ui/localization.js +40 -87
  160. package/ui/pip_button.js +2 -3
  161. package/ui/seek_bar.js +1 -2
  162. package/ui/text_selection.js +1 -0
@@ -32,9 +32,9 @@ shaka.offline = {};
32
32
  /** @const */
33
33
  shaka.text = {};
34
34
  /** @const */
35
- shaka.util = {};
36
- /** @const */
37
35
  shaka.ui = {};
36
+ /** @const */
37
+ shaka.util = {};
38
38
 
39
39
  /**
40
40
  * @summary Create an Event work-alike object based on the provided dictionary.
@@ -44,15 +44,28 @@ shaka.ui = {};
44
44
  shaka.util.FakeEvent = class {
45
45
  /**
46
46
  * @param {string} type
47
- * @param {Object=} dict
47
+ * @param {Map.<string, Object>=} dict
48
48
  */
49
49
  constructor(type, dict) {}
50
50
  };
51
+ /**
52
+ * An interface to standardize how objects release internal references
53
+ * synchronously. If an object needs to asynchronously release references, then
54
+ * it should use 'shaka.util.IDestroyable'.
55
+ * @interface
56
+ */
57
+ shaka.util.IReleasable = class {
58
+ /**
59
+ * Request that this object release all internal references.
60
+ */
61
+ release() {}
62
+ };
51
63
  /**
52
64
  * @summary A work-alike for EventTarget. Only DOM elements may be true
53
65
  * EventTargets, but this can be used as a base class to provide event dispatch
54
66
  * to non-DOM classes. Only FakeEvents should be dispatched.
55
67
  * @implements {EventTarget}
68
+ * @implements {shaka.util.IReleasable}
56
69
  */
57
70
  shaka.util.FakeEventTarget = class {
58
71
  /** */
@@ -90,6 +103,10 @@ shaka.util.FakeEventTarget = class {
90
103
  * @override
91
104
  */
92
105
  dispatchEvent(event) {}
106
+ /**
107
+ * @override
108
+ */
109
+ release() {}
93
110
  };
94
111
  /**
95
112
  * These are the listener types defined in the closure extern for EventTarget.
@@ -299,10 +316,9 @@ shaka.util.Error.Code = {
299
316
  * strings that are expected to be displayed to the user.
300
317
  * If a string is not available, it will return the localized
301
318
  * form in the closest related locale.
302
- * @implements {EventTarget}
303
319
  * @final
304
320
  */
305
- shaka.ui.Localization = class {
321
+ shaka.ui.Localization = class extends shaka.util.FakeEventTarget {
306
322
  /**
307
323
  * @param {string} fallbackLocale
308
324
  * The fallback locale that should be used. It will be assumed that this
@@ -312,15 +328,7 @@ shaka.ui.Localization = class {
312
328
  /**
313
329
  * @override
314
330
  */
315
- addEventListener(type, listener, options) {}
316
- /**
317
- * @override
318
- */
319
- removeEventListener(type, listener, options) {}
320
- /**
321
- * @override
322
- */
323
- dispatchEvent(event) {}
331
+ release() {}
324
332
  /**
325
333
  * Request the localization system to change which locale it serves. If any of
326
334
  * of the preferred locales cannot be found, the localization system will fire
@@ -541,6 +549,10 @@ shaka.text.Cue.prototype.id;
541
549
  * @override
542
550
  */
543
551
  shaka.text.Cue.prototype.nestedCues;
552
+ /**
553
+ * @override
554
+ */
555
+ shaka.text.Cue.prototype.isContainer;
544
556
  /**
545
557
  * @override
546
558
  */
@@ -1277,18 +1289,6 @@ shaka.net.NetworkingEngine.PluginPriority = {
1277
1289
  'PREFERRED': 2,
1278
1290
  'APPLICATION': 3
1279
1291
  };
1280
- /**
1281
- * An interface to standardize how objects release internal references
1282
- * synchronously. If an object needs to asynchronously release references, then
1283
- * it should use 'shaka.util.IDestroyable'.
1284
- * @interface
1285
- */
1286
- shaka.util.IReleasable = class {
1287
- /**
1288
- * Request that this object release all internal references.
1289
- */
1290
- release() {}
1291
- };
1292
1292
  /**
1293
1293
  * @summary
1294
1294
  * An EventManager maintains a collection of "event
@@ -1640,8 +1640,12 @@ shaka.media.SegmentReference = class {
1640
1640
  * The value is a grid-item-dimension consisting of two positive decimal
1641
1641
  * integers in the format: column-x-row ('4x3'). It describes the
1642
1642
  * arrangement of Images in a Grid. The minimum valid LAYOUT is '1x1'.
1643
+ * @param {?number=} tileDuration
1644
+ * The explicit duration of an individual tile within the tiles grid.
1645
+ * If not provided, the duration should be automatically calculated based on
1646
+ * the duration of the reference.
1643
1647
  */
1644
- constructor(startTime, endTime, uris, startByte, endByte, initSegmentReference, timestampOffset, appendWindowStart, appendWindowEnd, partialReferences, tilesLayout) {}
1648
+ constructor(startTime, endTime, uris, startByte, endByte, initSegmentReference, timestampOffset, appendWindowStart, appendWindowEnd, partialReferences, tilesLayout, tileDuration) {}
1645
1649
  /**
1646
1650
  * Creates and returns the URIs of the resource containing the segment.
1647
1651
  * @return {!Array.<string>}
@@ -1675,6 +1679,12 @@ shaka.media.SegmentReference = class {
1675
1679
  * @return {?string}
1676
1680
  */
1677
1681
  getTilesLayout() {}
1682
+ /**
1683
+ * Returns the segment's explicit tile duration.
1684
+ * Only defined in image segments.
1685
+ * @return {?number}
1686
+ */
1687
+ getTileDuration() {}
1678
1688
  };
1679
1689
  /**
1680
1690
  * PresentationTimeline.
@@ -2864,6 +2874,7 @@ shaka.ads.ServerSideAd = class {
2864
2874
  /**
2865
2875
  * A class responsible for ad-related interactions.
2866
2876
  * @implements {shaka.extern.IAdManager}
2877
+ * @implements {shaka.util.IReleasable}
2867
2878
  */
2868
2879
  shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
2869
2880
  /** */
@@ -2876,6 +2887,10 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
2876
2887
  * @override
2877
2888
  */
2878
2889
  initClientSide(adContainer, video) {}
2890
+ /**
2891
+ * @override
2892
+ */
2893
+ release() {}
2879
2894
  /**
2880
2895
  * @override
2881
2896
  */
@@ -2899,6 +2914,11 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
2899
2914
  * @override
2900
2915
  */
2901
2916
  replaceServerSideAdTagParameters(adTagParameters) {}
2917
+ /**
2918
+ * @return {!Array.<!shaka.extern.AdCuePoint>}
2919
+ * @override
2920
+ */
2921
+ getServerSideCuePoints() {}
2902
2922
  /**
2903
2923
  * @return {shaka.extern.AdsStats}
2904
2924
  * @override
@@ -3514,6 +3534,189 @@ shaka.polyfill = class {
3514
3534
  */
3515
3535
  static register(polyfill, priority) {}
3516
3536
  };
3537
+ /**
3538
+ * @summary A polyfill to add support for the ARIAMixin interface mixin, for
3539
+ * browsers that do not implement it (e.g. Firefox).
3540
+ * Note that IE also does not support ARIAMixin, but this polyfill does not work
3541
+ * for that platform, as it relies on getters and setters.
3542
+ * @see https://w3c.github.io/aria/#ARIAMixin
3543
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element
3544
+ */
3545
+ shaka.polyfill.Aria = class {
3546
+ /**
3547
+ * Install the polyfill if needed.
3548
+ */
3549
+ static install() {}
3550
+ };
3551
+ /**
3552
+ * @summary A polyfill to add support for EncryptionScheme queries in EME.
3553
+ * @see https://wicg.github.io/encrypted-media-encryption-scheme/
3554
+ * @see https://github.com/w3c/encrypted-media/pull/457
3555
+ * @see https://github.com/google/eme-encryption-scheme-polyfill
3556
+ */
3557
+ shaka.polyfill.EncryptionScheme = class {
3558
+ /**
3559
+ * Install the polyfill if needed.
3560
+ * @suppress {missingRequire}
3561
+ */
3562
+ static install() {}
3563
+ };
3564
+ /**
3565
+ * @summary A polyfill to unify fullscreen APIs across browsers.
3566
+ * Many browsers have prefixed fullscreen methods on Element and document.
3567
+ * See {@link https://mzl.la/2K0xcHo Using fullscreen mode} on MDN for more
3568
+ * information.
3569
+ */
3570
+ shaka.polyfill.Fullscreen = class {
3571
+ /**
3572
+ * Install the polyfill if needed.
3573
+ */
3574
+ static install() {}
3575
+ };
3576
+ /**
3577
+ * @summary A polyfill to patch math round bug on some browsers.
3578
+ * @see https://stackoverflow.com/q/12830742
3579
+ */
3580
+ shaka.polyfill.MathRound = class {
3581
+ /**
3582
+ * Install the polyfill if needed.
3583
+ */
3584
+ static install() {}
3585
+ };
3586
+ /**
3587
+ * @summary A polyfill to provide navigator.mediaCapabilities on all browsers.
3588
+ * This is necessary for Tizen 3, Xbox One and possibly others we have yet to
3589
+ * discover.
3590
+ */
3591
+ shaka.polyfill.MediaCapabilities = class {
3592
+ /**
3593
+ * Install the polyfill if needed.
3594
+ * @suppress {const}
3595
+ */
3596
+ static install() {}
3597
+ };
3598
+ /**
3599
+ * A copy of the MediaCapabilities instance, to prevent Safari from
3600
+ * garbage-collecting the polyfilled method on it. We make it public and export
3601
+ * it to ensure that it is not stripped out by the compiler.
3602
+ * @type {MediaCapabilities}
3603
+ */
3604
+ shaka.polyfill.MediaCapabilities.originalMcap;
3605
+ /**
3606
+ * @summary A polyfill to patch MSE bugs.
3607
+ */
3608
+ shaka.polyfill.MediaSource = class {
3609
+ /**
3610
+ * Install the polyfill if needed.
3611
+ */
3612
+ static install() {}
3613
+ };
3614
+ /**
3615
+ * @summary A polyfill for systems that do not implement screen.orientation.
3616
+ * For now, this only handles systems that implement the deprecated
3617
+ * window.orientation feature... e.g. iPad.
3618
+ */
3619
+ shaka.polyfill.Orientation = class {
3620
+ /**
3621
+ * Install the polyfill if needed.
3622
+ */
3623
+ static install() {}
3624
+ };
3625
+ /**
3626
+ * @summary A polyfill to implement modern, standardized EME on top of Apple's
3627
+ * prefixed EME in Safari.
3628
+ */
3629
+ shaka.polyfill.PatchedMediaKeysApple = class {
3630
+ /**
3631
+ * Installs the polyfill if needed.
3632
+ */
3633
+ static install() {}
3634
+ };
3635
+ /**
3636
+ * @summary A polyfill to implement
3637
+ * {@link https://bit.ly/EmeMar15 EME draft 12 March 2015}
3638
+ * on top of ms-prefixed
3639
+ * {@link https://www.w3.org/TR/2014/WD-encrypted-media-20140218/ EME v20140218}
3640
+ */
3641
+ shaka.polyfill.PatchedMediaKeysMs = class {
3642
+ /**
3643
+ * Installs the polyfill if needed.
3644
+ */
3645
+ static install() {}
3646
+ };
3647
+ /**
3648
+ * @summary A polyfill to stub out
3649
+ * {@link https://bit.ly/EmeMar15 EME draft 12 March 2015} on browsers without
3650
+ * EME.
3651
+ * All methods will fail.
3652
+ */
3653
+ shaka.polyfill.PatchedMediaKeysNop = class {
3654
+ /**
3655
+ * Installs the polyfill if needed.
3656
+ */
3657
+ static install() {}
3658
+ };
3659
+ /**
3660
+ * @summary A polyfill to implement
3661
+ * {@link https://bit.ly/EmeMar15 EME draft 12 March 2015} on top of
3662
+ * webkit-prefixed {@link https://bit.ly/Eme01b EME v0.1b}.
3663
+ */
3664
+ shaka.polyfill.PatchedMediaKeysWebkit = class {
3665
+ /**
3666
+ * Installs the polyfill if needed.
3667
+ */
3668
+ static install() {}
3669
+ };
3670
+ /**
3671
+ * @summary A polyfill to provide PiP support in Safari.
3672
+ * Note that Safari only supports PiP on video elements, not audio.
3673
+ */
3674
+ shaka.polyfill.PiPWebkit = class {
3675
+ /**
3676
+ * Install the polyfill if needed.
3677
+ */
3678
+ static install() {}
3679
+ };
3680
+ /**
3681
+ * @summary A polyfill to provide navigator.storage.estimate in old
3682
+ * webkit browsers.
3683
+ * See: https://developers.google.com/web/updates/2017/08/estimating-available-storage-space#the-present
3684
+ */
3685
+ shaka.polyfill.StorageEstimate = class {
3686
+ /**
3687
+ * Install the polyfill if needed.
3688
+ */
3689
+ static install() {}
3690
+ };
3691
+ /**
3692
+ * @summary A polyfill to silence the play() Promise in HTML5 video.
3693
+ */
3694
+ shaka.polyfill.VideoPlayPromise = class {
3695
+ /**
3696
+ * Install the polyfill if needed.
3697
+ */
3698
+ static install() {}
3699
+ };
3700
+ /**
3701
+ * @summary A polyfill to provide MSE VideoPlaybackQuality metrics.
3702
+ * Many browsers do not yet provide this API, and Chrome currently provides
3703
+ * similar data through individual prefixed attributes on HTMLVideoElement.
3704
+ */
3705
+ shaka.polyfill.VideoPlaybackQuality = class {
3706
+ /**
3707
+ * Install the polyfill if needed.
3708
+ */
3709
+ static install() {}
3710
+ };
3711
+ /**
3712
+ * @summary A polyfill to provide VTTCue.
3713
+ */
3714
+ shaka.polyfill.VTTCue = class {
3715
+ /**
3716
+ * Install the polyfill if needed.
3717
+ */
3718
+ static install() {}
3719
+ };
3517
3720
  /**
3518
3721
  * LRC file format: https://en.wikipedia.org/wiki/LRC_(file_format)
3519
3722
  * @implements {shaka.extern.TextParser}