shaka-player 3.2.2 → 3.3.0

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 (156) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
  3. package/.github/ISSUE_TEMPLATE/question.md +1 -1
  4. package/AUTHORS +6 -5
  5. package/CHANGELOG.md +247 -0
  6. package/CONTRIBUTORS +4 -2
  7. package/build/types/core +3 -0
  8. package/build/types/offline +1 -0
  9. package/build/types/polyfill +1 -0
  10. package/build/types/ui +2 -0
  11. package/demo/common/assets.js +18 -0
  12. package/demo/common/message_ids.js +13 -1
  13. package/demo/config.js +31 -1
  14. package/demo/index.html +1 -1
  15. package/demo/locales/en.json +12 -0
  16. package/demo/locales/source.json +48 -0
  17. package/dist/controls.css +26 -2
  18. package/dist/controls.css.map +1 -1
  19. package/dist/demo.compiled.debug.js +19 -16
  20. package/dist/demo.compiled.debug.map +3 -3
  21. package/dist/demo.compiled.js +19 -16
  22. package/dist/demo.compiled.map +3 -3
  23. package/dist/deps.js +18 -11
  24. package/dist/locales.js +28 -26
  25. package/dist/receiver.compiled.debug.js +11 -9
  26. package/dist/receiver.compiled.debug.map +3 -3
  27. package/dist/receiver.compiled.js +11 -9
  28. package/dist/receiver.compiled.map +3 -3
  29. package/dist/shaka-player.compiled.d.ts +205 -15
  30. package/dist/shaka-player.compiled.debug.d.ts +205 -15
  31. package/dist/shaka-player.compiled.debug.externs.js +256 -6
  32. package/dist/shaka-player.compiled.debug.js +406 -354
  33. package/dist/shaka-player.compiled.debug.map +4 -4
  34. package/dist/shaka-player.compiled.externs.js +256 -6
  35. package/dist/shaka-player.compiled.js +826 -800
  36. package/dist/shaka-player.compiled.map +4 -4
  37. package/dist/shaka-player.ui.d.ts +221 -16
  38. package/dist/shaka-player.ui.debug.d.ts +221 -16
  39. package/dist/shaka-player.ui.debug.externs.js +283 -6
  40. package/dist/shaka-player.ui.debug.js +547 -476
  41. package/dist/shaka-player.ui.debug.map +4 -4
  42. package/dist/shaka-player.ui.externs.js +283 -6
  43. package/dist/shaka-player.ui.js +1019 -980
  44. package/dist/shaka-player.ui.map +4 -4
  45. package/docs/design/bg-fetch-after.gv +29 -0
  46. package/docs/design/bg-fetch-after.gv.png +0 -0
  47. package/docs/design/bg-fetch-before.gv +18 -0
  48. package/docs/design/bg-fetch-before.gv.png +0 -0
  49. package/docs/design/bg-fetch.md +134 -0
  50. package/docs/tutorials/blob-url.md +15 -0
  51. package/docs/tutorials/index.json +1 -0
  52. package/docs/tutorials/ui-customization.md +66 -0
  53. package/docs/tutorials/ui.md +5 -5
  54. package/externs/ima.js +3 -0
  55. package/externs/shaka/ads.js +5 -0
  56. package/externs/shaka/manifest.js +12 -1
  57. package/externs/shaka/manifest_parser.js +10 -1
  58. package/externs/shaka/net.js +20 -4
  59. package/externs/shaka/offline.js +31 -2
  60. package/externs/shaka/player.js +130 -5
  61. package/externs/shaka/text.js +14 -0
  62. package/externs/webcrypto.js +18 -0
  63. package/lib/abr/ewma.js +14 -0
  64. package/lib/abr/ewma_bandwidth_estimator.js +16 -2
  65. package/lib/abr/simple_abr_manager.js +6 -0
  66. package/lib/ads/client_side_ad.js +8 -0
  67. package/lib/ads/client_side_ad_manager.js +8 -4
  68. package/lib/ads/server_side_ad.js +7 -0
  69. package/lib/cast/cast_utils.js +1 -0
  70. package/lib/dash/dash_parser.js +48 -14
  71. package/lib/dash/segment_base.js +25 -1
  72. package/lib/dash/segment_list.js +18 -9
  73. package/lib/dash/segment_template.js +23 -10
  74. package/lib/hls/hls_parser.js +86 -23
  75. package/lib/media/quality_observer.js +291 -0
  76. package/lib/media/segment_index.js +6 -0
  77. package/lib/media/segment_reference.js +18 -3
  78. package/lib/media/streaming_engine.js +42 -4
  79. package/lib/net/http_fetch_plugin.js +31 -11
  80. package/lib/net/http_plugin_utils.js +1 -0
  81. package/lib/net/http_xhr_plugin.js +40 -14
  82. package/lib/net/networking_engine.js +81 -18
  83. package/lib/offline/download_info.js +68 -0
  84. package/lib/offline/download_manager.js +13 -5
  85. package/lib/offline/indexeddb/base_storage_cell.js +35 -0
  86. package/lib/offline/indexeddb/storage_mechanism.js +1 -1
  87. package/lib/offline/indexeddb/v5_storage_cell.js +5 -0
  88. package/lib/offline/storage.js +393 -284
  89. package/lib/offline/stored_content_utils.js +2 -0
  90. package/lib/player.js +206 -7
  91. package/lib/polyfill/random_uuid.js +52 -0
  92. package/lib/text/cue.js +12 -0
  93. package/lib/text/ttml_text_parser.js +25 -2
  94. package/lib/text/ui_text_displayer.js +2 -2
  95. package/lib/util/cmcd_manager.js +826 -0
  96. package/lib/util/error.js +6 -0
  97. package/lib/util/language_utils.js +12 -0
  98. package/lib/util/mutex.js +52 -0
  99. package/lib/util/periods.js +98 -64
  100. package/lib/util/player_configuration.js +18 -0
  101. package/package.json +1 -1
  102. package/shaka-player.uncompiled.js +3 -0
  103. package/test/dash/dash_parser_content_protection_unit.js +2 -0
  104. package/test/dash/dash_parser_live_unit.js +101 -1
  105. package/test/dash/dash_parser_manifest_unit.js +35 -1
  106. package/test/dash/dash_parser_segment_base_unit.js +2 -0
  107. package/test/dash/dash_parser_segment_list_unit.js +2 -1
  108. package/test/dash/dash_parser_segment_template_unit.js +2 -1
  109. package/test/hls/hls_live_unit.js +2 -0
  110. package/test/hls/hls_parser_unit.js +2 -0
  111. package/test/media/quality_observer_unit.js +139 -0
  112. package/test/media/segment_reference_unit.js +16 -1
  113. package/test/media/streaming_engine_integration.js +2 -1
  114. package/test/media/streaming_engine_unit.js +2 -0
  115. package/test/net/http_plugin_unit.js +20 -15
  116. package/test/offline/storage_integration.js +108 -4
  117. package/test/player_integration.js +99 -0
  118. package/test/test/util/dash_parser_util.js +4 -0
  119. package/test/test/util/fake_ad.js +7 -0
  120. package/test/test/util/fake_drm_engine.js +9 -2
  121. package/test/test/util/manifest_generator.js +3 -2
  122. package/test/test/util/test_scheme.js +14 -1
  123. package/test/text/ttml_text_parser_unit.js +47 -0
  124. package/test/ui/ui_unit.js +250 -0
  125. package/test/util/cmcd_manager_unit.js +277 -0
  126. package/ui/airplay_button.js +1 -0
  127. package/ui/audio_language_selection.js +7 -0
  128. package/ui/cast_button.js +1 -0
  129. package/ui/context_menu.js +109 -0
  130. package/ui/controls.js +41 -7
  131. package/ui/controls.less +1 -0
  132. package/ui/enums.js +4 -0
  133. package/ui/externs/ui.js +28 -1
  134. package/ui/fast_forward_button.js +14 -5
  135. package/ui/fullscreen_button.js +1 -0
  136. package/ui/less/buttons.less +0 -4
  137. package/ui/less/containers.less +74 -0
  138. package/ui/less/overflow_menu.less +0 -10
  139. package/ui/less/tooltip.less +97 -0
  140. package/ui/locales/en.json +1 -0
  141. package/ui/locales/source.json +4 -0
  142. package/ui/loop_button.js +5 -0
  143. package/ui/mute_button.js +2 -1
  144. package/ui/overflow_menu.js +5 -25
  145. package/ui/pip_button.js +5 -0
  146. package/ui/play_button.js +2 -2
  147. package/ui/playback_rate_selection.js +8 -9
  148. package/ui/resolution_selection.js +7 -0
  149. package/ui/rewind_button.js +15 -6
  150. package/ui/seek_bar.js +4 -2
  151. package/ui/settings_menu.js +36 -4
  152. package/ui/small_play_button.js +1 -0
  153. package/ui/statistics_button.js +253 -0
  154. package/ui/text_selection.js +11 -4
  155. package/ui/ui.js +30 -0
  156. package/ui/volume_bar.js +1 -1
@@ -32,11 +32,16 @@ shaka.ui.FastForwardButton = class extends shaka.ui.Element {
32
32
  this.button_ = shaka.util.Dom.createButton();
33
33
  this.button_.classList.add('material-icons-round');
34
34
  this.button_.classList.add('shaka-fast-forward-button');
35
+ this.button_.classList.add('shaka-tooltip-status');
36
+ this.button_.setAttribute('shaka-status', '1x');
35
37
  this.button_.textContent =
36
38
  shaka.ui.Enums.MaterialDesignIcons.FAST_FORWARD;
37
39
  this.parent.appendChild(this.button_);
38
40
  this.updateAriaLabel_();
39
41
 
42
+ /** @private {!Array.<number>} */
43
+ this.fastForwardRates_ = this.controls.getConfig().fastForwardRates;
44
+
40
45
  this.eventManager.listen(
41
46
  this.localization, shaka.ui.Localization.LOCALE_UPDATED, () => {
42
47
  this.updateAriaLabel_();
@@ -61,7 +66,7 @@ shaka.ui.FastForwardButton = class extends shaka.ui.Element {
61
66
  }
62
67
 
63
68
  /**
64
- * Cycles trick play rate between 1, 2, 4, and 8.
69
+ * Cycles trick play rate between the selected fast forward rates.
65
70
  * @private
66
71
  */
67
72
  fastForward_() {
@@ -70,11 +75,15 @@ shaka.ui.FastForwardButton = class extends shaka.ui.Element {
70
75
  }
71
76
 
72
77
  const trickPlayRate = this.player.getPlaybackRate();
73
- // Every time the button is clicked, the rate is multiplied by 2,
74
- // unless the rate is at max (8), in which case it is dropped back to 1.
75
- const newRate = (trickPlayRate < 0 || trickPlayRate > 4) ?
76
- 1 : trickPlayRate * 2;
78
+ const newRateIndex = this.fastForwardRates_.indexOf(trickPlayRate) + 1;
79
+
80
+ // When the button is clicked, the next rate in this.fastForwardRates_ is
81
+ // selected. If no more rates are available, the first one is set.
82
+ const newRate = (newRateIndex != this.fastForwardRates_.length) ?
83
+ this.fastForwardRates_[newRateIndex] : this.fastForwardRates_[0];
77
84
  this.player.trickPlay(newRate);
85
+
86
+ this.button_.setAttribute('shaka-status', newRate + 'x');
78
87
  }
79
88
  };
80
89
 
@@ -32,6 +32,7 @@ shaka.ui.FullscreenButton = class extends shaka.ui.Element {
32
32
  this.button_ = shaka.util.Dom.createButton();
33
33
  this.button_.classList.add('shaka-fullscreen-button');
34
34
  this.button_.classList.add('material-icons-round');
35
+ this.button_.classList.add('shaka-tooltip');
35
36
 
36
37
  // Don't show the button if fullscreen is not supported
37
38
  if (!document.fullscreenEnabled) {
@@ -75,10 +75,6 @@
75
75
  .shaka-current-time {
76
76
  font-size: 14px;
77
77
  color: rgb(255, 255, 255);
78
-
79
- /* Make the time element the right size for the text, instead of defaulting
80
- * to the same size as the rest of the controls. */
81
- height: auto;
82
78
  cursor: pointer;
83
79
 
84
80
  &[disabled] {
@@ -195,6 +195,80 @@
195
195
  align-items: center;
196
196
  }
197
197
 
198
+ .shaka-statistics-container {
199
+ overflow-x: hidden;
200
+ overflow-y: auto;
201
+
202
+ min-width: 300px;
203
+
204
+ color: white;
205
+ background-color: rgba(35, 35, 35, 0.9);
206
+
207
+ font-size: 14px;
208
+
209
+ padding: 5px 10px;
210
+ border-radius: 2px;
211
+
212
+ position: absolute;
213
+ z-index: 2;
214
+ left: 15px;
215
+ top: 15px;
216
+
217
+ /* Fades out with the other controls. */
218
+ .show-when-controls-shown();
219
+
220
+ div {
221
+ display: flex;
222
+ justify-content: space-between;
223
+ }
224
+
225
+ span {
226
+ color: rgb(150, 150, 150);
227
+ }
228
+ }
229
+
230
+ .shaka-context-menu {
231
+ background-color: rgba(35, 35, 35, 0.9);
232
+
233
+ border-radius: 2px;
234
+
235
+ position: absolute;
236
+ z-index: 3;
237
+
238
+ button {
239
+ padding: 5px 10px;
240
+
241
+ width: 100%;
242
+ display: flex;
243
+ align-items: center;
244
+
245
+ color: white;
246
+ background: transparent;
247
+ border: 0;
248
+ cursor: pointer;
249
+
250
+ &:hover {
251
+ background-color: rgba(50, 50, 50, 0.9);
252
+ }
253
+ }
254
+
255
+ label {
256
+ padding: 0 20px;
257
+
258
+ align-items: flex-start;
259
+
260
+ color: white;
261
+ cursor: pointer;
262
+ }
263
+
264
+ .shaka-current-selection-span {
265
+ align-items: flex-start;
266
+
267
+ color: white;
268
+ cursor: pointer;
269
+ }
270
+ }
271
+
198
272
  .shaka-scrim-container {
199
273
  margin: 0;
200
274
  .fill-container();
@@ -141,13 +141,3 @@
141
141
  /* TODO(b/116651454): eliminate hard-coded offsets */
142
142
  left: 17px;
143
143
  }
144
-
145
- /* The captions button, when captions are on. */
146
- .shaka-captions-on {
147
- color: black;
148
- }
149
-
150
- /* The captions button, when captions are off. */
151
- .shaka-captions-off {
152
- color: grey;
153
- }
@@ -0,0 +1,97 @@
1
+ /*!
2
+ * @license
3
+ * The tooltip is based on https://github.com/felipefialho/css-components/
4
+ * Local modifications have been performed.
5
+ *
6
+ * Copyright (c) 2017 Felipe Fialho
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ @material-icons-width: 32px;
28
+
29
+ .translateX(@percent) {
30
+ -webkit-transform: translateX(percentage(@percent));
31
+ -moz-transform: translateX(percentage(@percent));
32
+ -ms-transform: translateX(percentage(@percent));
33
+ -o-transform: translateX(percentage(@percent));
34
+ transform: translateX(percentage(@percent));
35
+ }
36
+
37
+ /* .shaka-tooltips-on enables the tooltips and is only added to the
38
+ * control panel when the 'enableTooltips' option is set to true */
39
+ .shaka-tooltips-on {
40
+ overflow: visible;
41
+
42
+ & > [class*="shaka-tooltip"] {
43
+ position: relative;
44
+
45
+ /* The :after pseudo-element contains the tooltip */
46
+ &:hover:after, &:focus-visible:after, &:active:after {
47
+ content: attr(aria-label);
48
+
49
+ /* Override .material-icons-round text styling */
50
+ font-family: Roboto-Regular, Roboto, sans-serif;
51
+ line-height: @material-icons-width / 2;
52
+ white-space: nowrap;
53
+ font-size: 13px;
54
+
55
+ /* Styling */
56
+ background: rgba(35, 35, 35, 0.9);
57
+ color: white;
58
+ border-radius: 3px;
59
+ padding: 5px 10px;
60
+
61
+ /* Positioning */
62
+ position: absolute;
63
+ bottom: @material-icons-width + 5px;
64
+
65
+ /* Left attribute is set to half of the width of the parent button */
66
+ left: @material-icons-width / 2;
67
+
68
+ /* The tooltip is also translated 50% to appear centered */
69
+ .translateX(-0.5);
70
+ }
71
+ }
72
+
73
+ /* Adds an additional attribute for the status in .shaka-tooltip-status */
74
+ & > .shaka-tooltip-status {
75
+ &:hover:after, &:focus-visible:after, &:active:after {
76
+ content: attr(aria-label) " (" attr(shaka-status) ")";
77
+ }
78
+ }
79
+
80
+ /* The first tooltip of the panel is not centered on top of the button
81
+ * but rather aligned with the left border of the control panel */
82
+ button:first-child {
83
+ &:hover:after, &:focus-visible:after, &:active:after {
84
+ left: 0;
85
+ .translateX(0);
86
+ }
87
+ }
88
+
89
+ /* The last tooltip of the panel is not centered on top of the button
90
+ * but rather aligned with the right border of the control panel */
91
+ button:last-child {
92
+ &:hover:after, &:focus-visible:after,&:active:after {
93
+ left: @material-icons-width;
94
+ .translateX(-1);
95
+ }
96
+ }
97
+ }
@@ -33,6 +33,7 @@
33
33
  "SEEK": "Seek",
34
34
  "SKIP_AD": "Skip Ad",
35
35
  "SKIP_TO_LIVE": "Skip ahead to live",
36
+ "STATISTICS": "Statistics",
36
37
  "SUBTITLE_FORCED": "Forced",
37
38
  "UNDETERMINED_LANGUAGE": "Undetermined",
38
39
  "UNMUTE": "Unmute",
@@ -138,6 +138,10 @@
138
138
  "description": "Label for a button used to skip ahead to the live broadcast.",
139
139
  "message": "Skip ahead to live"
140
140
  },
141
+ "STATISTICS": {
142
+ "description": "Label for a button that displays statistics of the video.",
143
+ "message": "Statistics"
144
+ },
141
145
  "SUBTITLE_FORCED": {
142
146
  "description": "Label used to identify a subtitle track that is forced to be shown.",
143
147
  "message": "Forced"
package/ui/loop_button.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  goog.provide('shaka.ui.LoopButton');
9
9
 
10
+ goog.require('shaka.ui.ContextMenu');
10
11
  goog.require('shaka.ui.Controls');
11
12
  goog.require('shaka.ui.Element');
12
13
  goog.require('shaka.ui.Enums');
@@ -35,6 +36,7 @@ shaka.ui.LoopButton = class extends shaka.ui.Element {
35
36
  /** @private {!HTMLButtonElement} */
36
37
  this.button_ = shaka.util.Dom.createButton();
37
38
  this.button_.classList.add('shaka-loop-button');
39
+ this.button_.classList.add('shaka-tooltip');
38
40
 
39
41
  /** @private {!HTMLElement} */
40
42
  this.icon_ = shaka.util.Dom.createHTMLElement('i');
@@ -171,3 +173,6 @@ shaka.ui.OverflowMenu.registerElement(
171
173
 
172
174
  shaka.ui.Controls.registerElement(
173
175
  'loop', new shaka.ui.LoopButton.Factory());
176
+
177
+ shaka.ui.ContextMenu.registerElement(
178
+ 'loop', new shaka.ui.LoopButton.Factory());
package/ui/mute_button.js CHANGED
@@ -33,6 +33,7 @@ shaka.ui.MuteButton = class extends shaka.ui.Element {
33
33
  this.button_ = shaka.util.Dom.createButton();
34
34
  this.button_.classList.add('shaka-mute-button');
35
35
  this.button_.classList.add('material-icons-round');
36
+ this.button_.classList.add('shaka-tooltip');
36
37
  this.parent.appendChild(this.button_);
37
38
  this.updateAriaLabel_();
38
39
  this.updateIcon_();
@@ -48,7 +49,7 @@ shaka.ui.MuteButton = class extends shaka.ui.Element {
48
49
  });
49
50
 
50
51
  this.eventManager.listen(this.button_, 'click', () => {
51
- if (this.ad) {
52
+ if (this.ad && this.ad.isLinear()) {
52
53
  this.ad.setMuted(!this.ad.isMuted());
53
54
  } else {
54
55
  this.video.muted = !this.video.muted;
@@ -48,29 +48,6 @@ shaka.ui.OverflowMenu = class extends shaka.ui.Element {
48
48
 
49
49
  this.createChildren_();
50
50
 
51
-
52
- const backToOverflowMenuButtons =
53
- this.controls.getVideoContainer().getElementsByClassName(
54
- 'shaka-back-to-overflow-button');
55
-
56
- for (const button of backToOverflowMenuButtons) {
57
- this.eventManager.listen(button, 'click', () => {
58
- // Hide the submenus, display the overflow menu
59
- this.controls.hideSettingsMenus();
60
- shaka.ui.Utils.setDisplay(this.overflowMenu_, true);
61
-
62
- // If there are back to overflow menu buttons, there must be
63
- // overflow menu buttons, but oh well
64
- if (this.overflowMenu_.childNodes.length) {
65
- /** @type {!HTMLElement} */ (this.overflowMenu_.childNodes[0])
66
- .focus();
67
- }
68
-
69
- // Make sure controls are displayed
70
- this.controls.computeOpacity();
71
- });
72
- }
73
-
74
51
  this.eventManager.listen(
75
52
  this.localization, shaka.ui.Localization.LOCALE_UPDATED, () => {
76
53
  this.updateAriaLabel_();
@@ -83,7 +60,9 @@ shaka.ui.OverflowMenu = class extends shaka.ui.Element {
83
60
 
84
61
  this.eventManager.listen(
85
62
  this.adManager, shaka.ads.AdManager.AD_STARTED, () => {
86
- shaka.ui.Utils.setDisplay(this.overflowMenuButton_, false);
63
+ if (this.ad && this.ad.isLinear()) {
64
+ shaka.ui.Utils.setDisplay(this.overflowMenuButton_, false);
65
+ }
87
66
  });
88
67
 
89
68
  this.eventManager.listen(
@@ -112,7 +91,7 @@ shaka.ui.OverflowMenu = class extends shaka.ui.Element {
112
91
 
113
92
  this.updateAriaLabel_();
114
93
 
115
- if (this.ad) {
94
+ if (this.ad && this.ad.isLinear()) {
116
95
  // There was already an ad.
117
96
  shaka.ui.Utils.setDisplay(this.overflowMenuButton_, false);
118
97
  }
@@ -163,6 +142,7 @@ shaka.ui.OverflowMenu = class extends shaka.ui.Element {
163
142
  this.overflowMenuButton_.classList.add('shaka-overflow-menu-button');
164
143
  this.overflowMenuButton_.classList.add('shaka-no-propagation');
165
144
  this.overflowMenuButton_.classList.add('material-icons-round');
145
+ this.overflowMenuButton_.classList.add('shaka-tooltip');
166
146
  this.overflowMenuButton_.textContent =
167
147
  shaka.ui.Enums.MaterialDesignIcons.OPEN_OVERFLOW;
168
148
  this.parent.appendChild(this.overflowMenuButton_);
package/ui/pip_button.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  goog.provide('shaka.ui.PipButton');
9
9
 
10
+ goog.require('shaka.ui.ContextMenu');
10
11
  goog.require('shaka.ui.Controls');
11
12
  goog.require('shaka.ui.Element');
12
13
  goog.require('shaka.ui.Enums');
@@ -39,6 +40,7 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
39
40
  /** @private {!HTMLButtonElement} */
40
41
  this.pipButton_ = shaka.util.Dom.createButton();
41
42
  this.pipButton_.classList.add('shaka-pip-button');
43
+ this.pipButton_.classList.add('shaka-tooltip');
42
44
 
43
45
  /** @private {!HTMLElement} */
44
46
  this.pipIcon_ = shaka.util.Dom.createHTMLElement('i');
@@ -237,3 +239,6 @@ shaka.ui.OverflowMenu.registerElement(
237
239
 
238
240
  shaka.ui.Controls.registerElement(
239
241
  'picture_in_picture', new shaka.ui.PipButton.Factory());
242
+
243
+ shaka.ui.ContextMenu.registerElement(
244
+ 'picture_in_picture', new shaka.ui.PipButton.Factory());
package/ui/play_button.js CHANGED
@@ -73,7 +73,7 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
73
73
  });
74
74
 
75
75
  this.eventManager.listen(this.button, 'click', () => {
76
- if (this.ad) {
76
+ if (this.ad && this.ad.isLinear()) {
77
77
  this.controls.playPauseAd();
78
78
  } else {
79
79
  this.controls.playPausePresentation();
@@ -92,7 +92,7 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
92
92
  * @protected
93
93
  */
94
94
  isPaused() {
95
- if (this.ad) {
95
+ if (this.ad && this.ad.isLinear()) {
96
96
  return this.ad.isPaused();
97
97
  }
98
98
 
@@ -7,6 +7,7 @@
7
7
 
8
8
  goog.provide('shaka.ui.PlaybackRateSelection');
9
9
 
10
+ goog.require('shaka.ui.Controls');
10
11
  goog.require('shaka.ui.Enums');
11
12
  goog.require('shaka.ui.Locales');
12
13
  goog.require('shaka.ui.Localization');
@@ -31,6 +32,7 @@ shaka.ui.PlaybackRateSelection = class extends shaka.ui.SettingsMenu {
31
32
 
32
33
  this.button.classList.add('shaka-playbackrate-button');
33
34
  this.menu.classList.add('shaka-playback-rates');
35
+ this.button.classList.add('shaka-tooltip-status');
34
36
 
35
37
  this.eventManager.listen(
36
38
  this.localization, shaka.ui.Localization.LOCALE_UPDATED, () => {
@@ -47,15 +49,8 @@ shaka.ui.PlaybackRateSelection = class extends shaka.ui.SettingsMenu {
47
49
  });
48
50
 
49
51
  /** @type {!Map.<string, number>} */
50
- this.playbackRates_ = new Map([
51
- ['0.5x', 0.5],
52
- ['0.75x', 0.75],
53
- ['1x', 1],
54
- ['1.25x', 1.25],
55
- ['1.5x', 1.5],
56
- ['1.75x', 1.75],
57
- ['2x', 2],
58
- ]);
52
+ this.playbackRates_ = new Map(this.controls.getConfig().playbackRates
53
+ .map((rate) => [rate + 'x', rate]));
59
54
 
60
55
  // Set up all the strings in the user's preferred language.
61
56
  this.updateLocalizedStrings_();
@@ -109,6 +104,7 @@ shaka.ui.PlaybackRateSelection = class extends shaka.ui.SettingsMenu {
109
104
  // Set the label to display the current playback rate in the overflow menu,
110
105
  // in the format of '1x', '1.5x', etc.
111
106
  this.currentSelection.textContent = rate + 'x';
107
+ this.button.setAttribute('shaka-status', rate + 'x');
112
108
  }
113
109
 
114
110
  /** @private */
@@ -143,3 +139,6 @@ shaka.ui.PlaybackRateSelection.Factory = class {
143
139
 
144
140
  shaka.ui.OverflowMenu.registerElement(
145
141
  'playback_rate', new shaka.ui.PlaybackRateSelection.Factory());
142
+
143
+ shaka.ui.Controls.registerElement(
144
+ 'playback_rate', new shaka.ui.PlaybackRateSelection.Factory());
@@ -8,6 +8,7 @@
8
8
  goog.provide('shaka.ui.ResolutionSelection');
9
9
 
10
10
  goog.require('goog.asserts');
11
+ goog.require('shaka.ui.Controls');
11
12
  goog.require('shaka.ui.Enums');
12
13
  goog.require('shaka.ui.Locales');
13
14
  goog.require('shaka.ui.Localization');
@@ -33,6 +34,7 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
33
34
  super(parent, controls, shaka.ui.Enums.MaterialDesignIcons.RESOLUTION);
34
35
 
35
36
  this.button.classList.add('shaka-resolution-button');
37
+ this.button.classList.add('shaka-tooltip-status');
36
38
  this.menu.classList.add('shaka-resolutions');
37
39
 
38
40
  this.eventManager.listen(
@@ -171,6 +173,8 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
171
173
  this.localization.resolve(shaka.ui.Locales.Ids.AUTO_QUALITY);
172
174
  }
173
175
 
176
+ this.button.setAttribute('shaka-status', this.currentSelection.textContent);
177
+
174
178
  this.menu.appendChild(autoButton);
175
179
  shaka.ui.Utils.focusOnTheChosenItem(this.menu);
176
180
  this.controls.dispatchEvent(
@@ -227,3 +231,6 @@ shaka.ui.ResolutionSelection.Factory = class {
227
231
 
228
232
  shaka.ui.OverflowMenu.registerElement(
229
233
  'quality', new shaka.ui.ResolutionSelection.Factory());
234
+
235
+ shaka.ui.Controls.registerElement(
236
+ 'quality', new shaka.ui.ResolutionSelection.Factory());
@@ -32,11 +32,17 @@ shaka.ui.RewindButton = class extends shaka.ui.Element {
32
32
  this.button_ = shaka.util.Dom.createButton();
33
33
  this.button_.classList.add('material-icons-round');
34
34
  this.button_.classList.add('shaka-rewind-button');
35
+ this.button_.classList.add('shaka-tooltip-status');
36
+ this.button_.setAttribute('shaka-status',
37
+ this.localization.resolve(shaka.ui.Locales.Ids.OFF));
35
38
  this.button_.textContent =
36
39
  shaka.ui.Enums.MaterialDesignIcons.REWIND;
37
40
  this.parent.appendChild(this.button_);
38
41
  this.updateAriaLabel_();
39
42
 
43
+ /** @private {!Array.<number>} */
44
+ this.rewindRates_ = this.controls.getConfig().rewindRates;
45
+
40
46
  this.eventManager.listen(
41
47
  this.localization, shaka.ui.Localization.LOCALE_UPDATED, () => {
42
48
  this.updateAriaLabel_();
@@ -61,7 +67,7 @@ shaka.ui.RewindButton = class extends shaka.ui.Element {
61
67
  }
62
68
 
63
69
  /**
64
- * Cycles trick play rate between -1, -2, -4, and -8.
70
+ * Cycles trick play rate between the selected rewind rates.
65
71
  * @private
66
72
  */
67
73
  rewind_() {
@@ -70,12 +76,15 @@ shaka.ui.RewindButton = class extends shaka.ui.Element {
70
76
  }
71
77
 
72
78
  const trickPlayRate = this.player.getPlaybackRate();
73
- // Every time the button is clicked, the rate is multiplied by 2,
74
- // unless the rate is at it's slowest (-8), in which case it is
75
- // dropped back to 1.
76
- const newRate = (trickPlayRate > 0 || trickPlayRate < -4) ?
77
- -1 : trickPlayRate * 2;
79
+ const newRateIndex = this.rewindRates_.indexOf(trickPlayRate) + 1;
80
+
81
+ // When the button is clicked, the next rate in this.rewindRates_ is
82
+ // selected. If no more rates are available, the first one is set.
83
+ const newRate = (newRateIndex != this.rewindRates_.length) ?
84
+ this.rewindRates_[newRateIndex] : this.rewindRates_[0];
78
85
  this.player.trickPlay(newRate);
86
+
87
+ this.button_.setAttribute('shaka-status', newRate + 'x');
79
88
  }
80
89
  };
81
90
 
package/ui/seek_bar.js CHANGED
@@ -95,7 +95,9 @@ shaka.ui.SeekBar = class extends shaka.ui.RangeElement {
95
95
 
96
96
  this.eventManager.listen(
97
97
  this.adManager, shaka.ads.AdManager.AD_STARTED, () => {
98
- shaka.ui.Utils.setDisplay(this.container, false);
98
+ if (!this.shouldBeDisplayed_()) {
99
+ shaka.ui.Utils.setDisplay(this.container, false);
100
+ }
99
101
  });
100
102
 
101
103
  this.eventManager.listen(
@@ -366,7 +368,7 @@ shaka.ui.SeekBar = class extends shaka.ui.RangeElement {
366
368
  return false;
367
369
  }
368
370
 
369
- return this.ad == null;
371
+ return this.ad == null || !this.ad.isLinear();
370
372
  }
371
373
 
372
374
  /** @private */
@@ -33,6 +33,8 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
33
33
 
34
34
  this.addMenu_();
35
35
 
36
+ this.inOverflowMenu_();
37
+
36
38
  this.eventManager.listen(this.button, 'click', () => {
37
39
  this.onButtonClick_();
38
40
  });
@@ -46,6 +48,7 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
46
48
  addButton_(iconText) {
47
49
  /** @protected {!HTMLButtonElement} */
48
50
  this.button = shaka.util.Dom.createButton();
51
+ this.button.classList.add('shaka-overflow-button');
49
52
 
50
53
  /** @protected {!HTMLElement}*/
51
54
  this.icon = shaka.util.Dom.createHTMLElement('i');
@@ -55,6 +58,7 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
55
58
 
56
59
  const label = shaka.util.Dom.createHTMLElement('label');
57
60
  label.classList.add('shaka-overflow-button-label');
61
+ label.classList.add('shaka-overflow-menu-only');
58
62
 
59
63
  /** @protected {!HTMLElement}*/
60
64
  this.nameSpan = shaka.util.Dom.createHTMLElement('span');
@@ -83,10 +87,13 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
83
87
  this.backButton = shaka.util.Dom.createButton();
84
88
  this.backButton.classList.add('shaka-back-to-overflow-button');
85
89
  this.menu.appendChild(this.backButton);
90
+ this.eventManager.listen(this.backButton, 'click', () => {
91
+ this.controls.hideSettingsMenus();
92
+ });
86
93
 
87
94
  const backIcon = shaka.util.Dom.createHTMLElement('i');
88
95
  backIcon.classList.add('material-icons-round');
89
- backIcon.textContent = shaka.ui.Enums.MaterialDesignIcons.BACK;
96
+ backIcon.textContent = shaka.ui.Enums.MaterialDesignIcons.CLOSE;
90
97
  this.backButton.appendChild(backIcon);
91
98
 
92
99
  /** @protected {!HTMLElement}*/
@@ -97,11 +104,36 @@ shaka.ui.SettingsMenu = class extends shaka.ui.Element {
97
104
  controlsContainer.appendChild(this.menu);
98
105
  }
99
106
 
107
+ /** @private */
108
+ inOverflowMenu_() {
109
+ // Initially, submenus are created with a "Close" option. When present
110
+ // inside of the overflow menu, that option must be replaced with a
111
+ // "Back" arrow that returns the user to the main menu.
112
+ if (this.parent.classList.contains('shaka-overflow-menu')) {
113
+ this.backButton.firstChild.textContent =
114
+ shaka.ui.Enums.MaterialDesignIcons.BACK;
115
+
116
+ this.eventManager.listen(this.backButton, 'click', () => {
117
+ shaka.ui.Utils.setDisplay(this.parent, true);
118
+
119
+ /** @type {!HTMLElement} */
120
+ (this.parent.childNodes[0]).focus();
121
+
122
+ // Make sure controls are displayed
123
+ this.controls.computeOpacity();
124
+ });
125
+ }
126
+ }
127
+
100
128
 
101
129
  /** @private */
102
130
  onButtonClick_() {
103
- this.controls.dispatchEvent(new shaka.util.FakeEvent('submenuopen'));
104
- shaka.ui.Utils.setDisplay(this.menu, true);
105
- shaka.ui.Utils.focusOnTheChosenItem(this.menu);
131
+ if (this.menu.classList.contains('shaka-hidden')) {
132
+ this.controls.dispatchEvent(new shaka.util.FakeEvent('submenuopen'));
133
+ shaka.ui.Utils.setDisplay(this.menu, true);
134
+ shaka.ui.Utils.focusOnTheChosenItem(this.menu);
135
+ } else {
136
+ shaka.ui.Utils.setDisplay(this.menu, false);
137
+ }
106
138
  }
107
139
  };
@@ -28,6 +28,7 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
28
28
 
29
29
  this.button.classList.add('shaka-small-play-button');
30
30
  this.button.classList.add('material-icons-round');
31
+ this.button.classList.add('shaka-tooltip');
31
32
 
32
33
  this.updateIcon();
33
34
  this.updateAriaLabel();