shaka-player 2.5.4 → 2.5.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 (102) hide show
  1. package/.csslintrc +13 -0
  2. package/CHANGELOG.md +56 -0
  3. package/build/build.py +4 -1
  4. package/build/check.py +17 -0
  5. package/build/compiler.py +40 -0
  6. package/build/types/core +1 -0
  7. package/build/types/ui +4 -1
  8. package/demo/asset_card.js +41 -11
  9. package/demo/cast_receiver/receiver_app.css +19 -13
  10. package/demo/close_button.js +0 -6
  11. package/demo/common/asset.js +6 -1
  12. package/demo/common/assets.js +72 -14
  13. package/demo/demo.less +105 -16
  14. package/demo/index.html +8 -5
  15. package/demo/load.js +5 -7
  16. package/demo/main.js +81 -16
  17. package/dist/.csslintstamp +0 -0
  18. package/dist/controls.css +1 -1
  19. package/dist/controls.css.map +1 -1
  20. package/dist/demo.compiled.debug.js +46 -39
  21. package/dist/demo.compiled.debug.map +3 -3
  22. package/dist/demo.compiled.js +46 -39
  23. package/dist/demo.compiled.map +3 -3
  24. package/dist/demo.css +1 -1
  25. package/dist/demo.css.map +1 -1
  26. package/dist/deps.js +11 -7
  27. package/dist/receiver.compiled.debug.js +10 -6
  28. package/dist/receiver.compiled.debug.map +3 -3
  29. package/dist/receiver.compiled.js +10 -6
  30. package/dist/receiver.compiled.map +3 -3
  31. package/dist/shaka-player.compiled.debug.externs.js +123 -92
  32. package/dist/shaka-player.compiled.debug.js +113 -105
  33. package/dist/shaka-player.compiled.debug.map +4 -4
  34. package/dist/shaka-player.compiled.externs.js +123 -92
  35. package/dist/shaka-player.compiled.js +551 -548
  36. package/dist/shaka-player.compiled.map +4 -4
  37. package/dist/shaka-player.ui.debug.externs.js +170 -101
  38. package/dist/shaka-player.ui.debug.js +187 -188
  39. package/dist/shaka-player.ui.debug.map +4 -4
  40. package/dist/shaka-player.ui.externs.js +170 -101
  41. package/dist/shaka-player.ui.js +651 -651
  42. package/dist/shaka-player.ui.map +3 -3
  43. package/docs/tutorials/drm-config.md +1 -0
  44. package/docs/tutorials/fairplay.md +77 -0
  45. package/docs/tutorials/index.json +1 -0
  46. package/docs/tutorials/ui-customization.md +3 -0
  47. package/docs/tutorials/ui.md +3 -1
  48. package/externs/mediasession.js +16 -1
  49. package/externs/shaka/net.js +5 -1
  50. package/externs/shaka/player.js +136 -90
  51. package/externs/webkitmediakeys.js +4 -0
  52. package/lib/dash/content_protection.js +33 -1
  53. package/lib/dash/dash_parser.js +12 -4
  54. package/lib/hls/hls_parser.js +20 -4
  55. package/lib/media/drm_engine.js +29 -2
  56. package/lib/media/media_source_engine.js +7 -3
  57. package/lib/media/playhead.js +8 -3
  58. package/lib/media/streaming_engine.js +24 -8
  59. package/lib/media/video_wrapper.js +8 -3
  60. package/lib/net/networking_engine.js +1 -0
  61. package/lib/player.js +3 -2
  62. package/lib/polyfill/patchedmediakeys_apple.js +2 -72
  63. package/lib/util/error.js +12 -0
  64. package/lib/util/fairplay_utils.js +122 -0
  65. package/lib/util/player_configuration.js +5 -0
  66. package/lib/util/pssh.js +41 -0
  67. package/package.json +4 -3
  68. package/shaka-player.uncompiled.js +5 -1
  69. package/test/dash/dash_parser_content_protection_unit.js +35 -1
  70. package/test/dash/dash_parser_manifest_unit.js +31 -0
  71. package/test/hls/hls_live_unit.js +7 -1
  72. package/test/hls/hls_parser_unit.js +50 -0
  73. package/test/media/media_source_engine_integration.js +12 -0
  74. package/test/media/playhead_unit.js +2 -0
  75. package/test/player_external.js +3 -2
  76. package/test/player_integration.js +75 -0
  77. package/test/test/externs/jasmine.js +6 -0
  78. package/test/test/util/test_scheme.js +32 -1
  79. package/test/test/util/ui_utils.js +41 -0
  80. package/test/ui/ui_unit.js +129 -3
  81. package/ui/audio_language_selection.js +17 -96
  82. package/ui/big_play_button.js +61 -0
  83. package/ui/controls.js +111 -86
  84. package/ui/controls.less +3 -5
  85. package/ui/externs/ui.js +14 -2
  86. package/ui/fullscreen_button.js +2 -52
  87. package/ui/less/buttons.less +8 -8
  88. package/ui/less/containers.less +21 -21
  89. package/ui/less/general.less +11 -0
  90. package/ui/less/other_elements.less +2 -1
  91. package/ui/less/overflow_menu.less +11 -10
  92. package/ui/less/range_elements.less +6 -0
  93. package/ui/less/spinner.less +2 -0
  94. package/ui/pip_button.js +1 -1
  95. package/ui/{play_pause_button.js → play_button.js} +17 -47
  96. package/ui/resolution_selection.js +41 -104
  97. package/ui/seek_bar.js +15 -17
  98. package/ui/settings_menu.js +113 -0
  99. package/ui/small_play_button.js +73 -0
  100. package/ui/text_displayer.js +2 -2
  101. package/ui/text_selection.js +39 -105
  102. package/ui/ui.js +12 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2016 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+
19
+ goog.provide('shaka.ui.SmallPlayButton');
20
+
21
+ goog.require('shaka.ui.PlayButton');
22
+
23
+
24
+ /**
25
+ * @extends {shaka.ui.PlayButton}
26
+ * @final
27
+ * @export
28
+ */
29
+ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
30
+ /**
31
+ * @param {!HTMLElement} parent
32
+ * @param {!shaka.ui.Controls} controls
33
+ */
34
+ constructor(parent, controls) {
35
+ super(parent, controls);
36
+
37
+ this.button.classList.add('shaka-small-play-button');
38
+ this.button.classList.add('material-icons');
39
+
40
+ this.updateIcon_();
41
+ this.updateAriaLabel();
42
+
43
+ this.eventManager.listen(this.video, 'play', () => {
44
+ this.updateIcon_();
45
+ });
46
+
47
+ this.eventManager.listen(this.video, 'pause', () => {
48
+ this.updateIcon_();
49
+ });
50
+ }
51
+
52
+
53
+ /** @private */
54
+ updateIcon_() {
55
+ const Icons = shaka.ui.Enums.MaterialDesignIcons;
56
+ this.button.textContent = this.isPaused() ? Icons.PLAY : Icons.PAUSE;
57
+ }
58
+ };
59
+
60
+
61
+ /**
62
+ * @implements {shaka.extern.IUIElement.Factory}
63
+ * @final
64
+ */
65
+ shaka.ui.SmallPlayButton.Factory = class {
66
+ /** @override */
67
+ create(rootElement, controls) {
68
+ return new shaka.ui.SmallPlayButton(rootElement, controls);
69
+ }
70
+ };
71
+
72
+ shaka.ui.Controls.registerElement(
73
+ 'play_pause', new shaka.ui.SmallPlayButton.Factory());
@@ -198,8 +198,8 @@ shaka.ui.TextDisplayer = class {
198
198
  const captionsStyle = captions.style;
199
199
  const panelStyle = this.textContainer_.style;
200
200
 
201
- // Set white-space to 'pre' to enable showing line breaks in the text.
202
- captionsStyle.whiteSpace = 'pre';
201
+ // Set white-space to 'pre-line' to enable showing line breaks in the text.
202
+ captionsStyle.whiteSpace = 'pre-line';
203
203
  captions.textContent = cue.payload;
204
204
  captionsStyle.backgroundColor = cue.backgroundColor;
205
205
  captionsStyle.color = cue.color;
@@ -18,31 +18,39 @@
18
18
 
19
19
  goog.provide('shaka.ui.TextSelection');
20
20
 
21
- goog.require('shaka.ui.Element');
22
21
  goog.require('shaka.ui.Enums');
23
22
  goog.require('shaka.ui.LanguageUtils');
24
23
  goog.require('shaka.ui.Locales');
25
24
  goog.require('shaka.ui.Localization');
26
25
  goog.require('shaka.ui.OverflowMenu');
26
+ goog.require('shaka.ui.SettingsMenu');
27
27
  goog.require('shaka.util.Dom');
28
28
 
29
29
 
30
30
  /**
31
- * @extends {shaka.ui.Element}
31
+ * @extends {shaka.ui.SettingsMenu}
32
32
  * @final
33
33
  * @export
34
34
  */
35
- shaka.ui.TextSelection = class extends shaka.ui.Element {
35
+ shaka.ui.TextSelection = class extends shaka.ui.SettingsMenu {
36
36
  /**
37
37
  * @param {!HTMLElement} parent
38
38
  * @param {!shaka.ui.Controls} controls
39
39
  */
40
40
  constructor(parent, controls) {
41
- super(parent, controls);
41
+ super(parent,
42
+ controls, shaka.ui.Enums.MaterialDesignIcons.CLOSED_CAPTIONS);
42
43
 
43
- this.addCaptionButton_();
44
+ this.button.classList.add('shaka-caption-button');
45
+ this.menu.classList.add('shaka-text-languages');
44
46
 
45
- this.addTextLangMenu_();
47
+ if (this.player && this.player.isTextTrackVisible()) {
48
+ this.button.setAttribute('aria-pressed', 'true');
49
+ } else {
50
+ this.button.setAttribute('aria-pressed', 'false');
51
+ }
52
+
53
+ this.addOffOption_();
46
54
 
47
55
  this.eventManager.listen(
48
56
  this.localization, shaka.ui.Localization.LOCALE_UPDATED, () => {
@@ -66,10 +74,6 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
66
74
  this.onCaptionStateChange_();
67
75
  });
68
76
 
69
- this.eventManager.listen(this.captionButton_, 'click', () => {
70
- this.onCaptionClick_();
71
- });
72
-
73
77
  this.eventManager.listen(this.player, 'textchanged', () => {
74
78
  this.updateTextLanguages_();
75
79
  });
@@ -91,70 +95,10 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
91
95
  /**
92
96
  * @private
93
97
  */
94
- addCaptionButton_() {
95
- /** @private {!HTMLElement} */
96
- this.captionButton_ = shaka.util.Dom.createHTMLElement('button');
97
- this.captionButton_.classList.add('shaka-caption-button');
98
-
99
- /** @private {!HTMLElement} */
100
- this.captionIcon_ = shaka.util.Dom.createHTMLElement('i');
101
- this.captionIcon_.classList.add('material-icons');
102
- this.captionIcon_.textContent =
103
- shaka.ui.Enums.MaterialDesignIcons.CLOSED_CAPTIONS;
104
-
105
- if (this.player && this.player.isTextTrackVisible()) {
106
- this.captionButton_.setAttribute('aria-pressed', 'true');
107
- } else {
108
- this.captionButton_.setAttribute('aria-pressed', 'false');
109
- }
110
- this.captionButton_.appendChild(this.captionIcon_);
111
-
112
- const label = shaka.util.Dom.createHTMLElement('label');
113
- label.classList.add('shaka-overflow-button-label');
114
-
115
- /** @private {!HTMLElement} */
116
- this.captionsNameSpan_ = shaka.util.Dom.createHTMLElement('span');
117
-
118
- label.appendChild(this.captionsNameSpan_);
119
-
120
- /** @private {!HTMLElement} */
121
- this.currentCaptions_ = shaka.util.Dom.createHTMLElement('span');
122
- this.currentCaptions_.classList.add('shaka-current-selection-span');
123
- label.appendChild(this.currentCaptions_);
124
- this.captionButton_.appendChild(label);
125
- this.parent.appendChild(this.captionButton_);
126
- }
127
-
128
-
129
- /**
130
- * @private
131
- */
132
- addTextLangMenu_() {
133
- /** @private {!HTMLElement} */
134
- this.textLangMenu_ = shaka.util.Dom.createHTMLElement('div');
135
- this.textLangMenu_.classList.add('shaka-text-languages');
136
- this.textLangMenu_.classList.add('shaka-no-propagation');
137
- this.textLangMenu_.classList.add('shaka-show-controls-on-mouse-over');
138
- this.textLangMenu_.classList.add('shaka-settings-menu');
139
-
140
- /** @private {!HTMLElement} */
141
- this.backFromCaptionsButton_ = shaka.util.Dom.createHTMLElement('button');
142
- this.backFromCaptionsButton_.classList.add('shaka-back-to-overflow-button');
143
- this.textLangMenu_.appendChild(this.backFromCaptionsButton_);
144
-
145
- const backIcon = shaka.util.Dom.createHTMLElement('i');
146
- backIcon.classList.add('material-icons');
147
- backIcon.textContent = shaka.ui.Enums.MaterialDesignIcons.BACK;
148
- this.backFromCaptionsButton_.appendChild(backIcon);
149
-
150
- /** @private {!HTMLElement} */
151
- this.backFromCaptionsSpan_ = shaka.util.Dom.createHTMLElement('span');
152
- this.backFromCaptionsButton_.appendChild(this.backFromCaptionsSpan_);
153
-
154
- // Add the off option
98
+ addOffOption_() {
155
99
  const off = shaka.util.Dom.createHTMLElement('button');
156
100
  off.setAttribute('aria-selected', 'true');
157
- this.textLangMenu_.appendChild(off);
101
+ this.menu.appendChild(off);
158
102
 
159
103
  off.appendChild(shaka.ui.Utils.checkmarkIcon());
160
104
 
@@ -163,31 +107,19 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
163
107
 
164
108
  this.captionsOffSpan_.classList.add('shaka-auto-span');
165
109
  off.appendChild(this.captionsOffSpan_);
166
-
167
- const controlsContainer = this.controls.getControlsContainer();
168
- controlsContainer.appendChild(this.textLangMenu_);
169
- }
170
-
171
-
172
- /** @private */
173
- onCaptionClick_() {
174
- this.controls.dispatchEvent(new shaka.util.FakeEvent('submenuopen'));
175
- shaka.ui.Utils.setDisplay(this.textLangMenu_, true);
176
- // Focus on the currently selected language button.
177
- shaka.ui.Utils.focusOnTheChosenItem(this.textLangMenu_);
178
110
  }
179
111
 
180
112
 
181
113
  /** @private */
182
114
  onCaptionStateChange_() {
183
115
  if (this.player.isTextTrackVisible()) {
184
- this.captionIcon_.classList.add('shaka-captions-on');
185
- this.captionIcon_.classList.remove('shaka-captions-off');
186
- this.captionButton_.setAttribute('aria-pressed', 'true');
116
+ this.icon.classList.add('shaka-captions-on');
117
+ this.icon.classList.remove('shaka-captions-off');
118
+ this.button.setAttribute('aria-pressed', 'true');
187
119
  } else {
188
- this.captionIcon_.classList.add('shaka-captions-off');
189
- this.captionIcon_.classList.remove('shaka-captions-on');
190
- this.captionButton_.setAttribute('aria-pressed', 'false');
120
+ this.icon.classList.add('shaka-captions-off');
121
+ this.icon.classList.remove('shaka-captions-on');
122
+ this.button.setAttribute('aria-pressed', 'false');
191
123
  }
192
124
 
193
125
  // TODO: document this event
@@ -204,13 +136,15 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
204
136
  return langAndRole.language;
205
137
  });
206
138
 
207
- shaka.ui.LanguageUtils.updateLanguages(tracks, this.textLangMenu_,
208
- languages,
209
- this.onTextLanguageSelected_.bind(this),
210
- // Don't mark current text language as chosen unless captions are enabled
211
- this.player.isTextTrackVisible(),
212
- this.currentCaptions_,
213
- this.localization);
139
+ shaka.ui.LanguageUtils.updateLanguages(tracks, this.menu,
140
+ languages,
141
+ (lang) => this.onTextLanguageSelected_(lang),
142
+
143
+ // Don't mark current text language as chosen unless captions are
144
+ // enabled
145
+ this.player.isTextTrackVisible(),
146
+ this.currentSelection,
147
+ this.localization);
214
148
 
215
149
  // Add the Off button
216
150
  const offButton = shaka.util.Dom.createHTMLElement('button');
@@ -223,17 +157,17 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
223
157
 
224
158
  offButton.appendChild(this.captionsOffSpan_);
225
159
 
226
- this.textLangMenu_.appendChild(offButton);
160
+ this.menu.appendChild(offButton);
227
161
 
228
162
  if (!this.player.isTextTrackVisible()) {
229
163
  offButton.setAttribute('aria-selected', 'true');
230
164
  offButton.appendChild(shaka.ui.Utils.checkmarkIcon());
231
165
  this.captionsOffSpan_.classList.add('shaka-chosen-item');
232
- this.currentCaptions_.textContent =
166
+ this.currentSelection.textContent =
233
167
  this.localization.resolve(shaka.ui.Locales.Ids.OFF);
234
168
  }
235
169
 
236
- shaka.ui.Utils.focusOnTheChosenItem(this.textLangMenu_);
170
+ shaka.ui.Utils.focusOnTheChosenItem(this.menu);
237
171
 
238
172
  // TODO: document this event
239
173
  this.controls.dispatchEvent(
@@ -260,13 +194,13 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
260
194
  updateLocalizedStrings_() {
261
195
  const LocIds = shaka.ui.Locales.Ids;
262
196
 
263
- this.captionButton_.setAttribute(shaka.ui.Constants.ARIA_LABEL,
197
+ this.button.setAttribute(shaka.ui.Constants.ARIA_LABEL,
264
198
  this.localization.resolve(LocIds.CAPTIONS));
265
- this.backFromCaptionsButton_.setAttribute(shaka.ui.Constants.ARIA_LABEL,
199
+ this.backButton.setAttribute(shaka.ui.Constants.ARIA_LABEL,
266
200
  this.localization.resolve(LocIds.BACK));
267
- this.captionsNameSpan_.textContent =
201
+ this.nameSpan.textContent =
268
202
  this.localization.resolve(LocIds.CAPTIONS);
269
- this.backFromCaptionsSpan_.textContent =
203
+ this.backSpan.textContent =
270
204
  this.localization.resolve(LocIds.CAPTIONS);
271
205
  this.captionsOffSpan_.textContent =
272
206
  this.localization.resolve(LocIds.OFF);
@@ -276,7 +210,7 @@ shaka.ui.TextSelection = class extends shaka.ui.Element {
276
210
  /** @private */
277
211
  onTracksChanged_() {
278
212
  const hasText = this.player.getTextTracks().length > 0;
279
- shaka.ui.Utils.setDisplay(this.captionButton_, hasText);
213
+ shaka.ui.Utils.setDisplay(this.button, hasText);
280
214
  this.updateTextLanguages_();
281
215
  }
282
216
  };
package/ui/ui.js CHANGED
@@ -193,7 +193,9 @@ shaka.ui.Overlay.prototype.defaultConfig_ = function() {
193
193
  'cast',
194
194
  ],
195
195
  addSeekBar: true,
196
+ addBigPlayButton: true,
196
197
  castReceiverAppId: '',
198
+ clearBufferOnQualityChange: true,
197
199
  };
198
200
  };
199
201
 
@@ -234,6 +236,11 @@ shaka.ui.Overlay.scanPageForShakaElements_ = function() {
234
236
  // Just the video elements were provided.
235
237
  for (let i = 0; i < videos.length; i++) {
236
238
  const video = videos[i];
239
+ // If the app has already manually created a UI for this element,
240
+ // don't create another one.
241
+ if (video['ui']) {
242
+ continue;
243
+ }
237
244
  goog.asserts.assert(video.tagName.toLowerCase() == 'video',
238
245
  'Should be a video element!');
239
246
 
@@ -263,6 +270,11 @@ shaka.ui.Overlay.scanPageForShakaElements_ = function() {
263
270
  } else {
264
271
  for (let i = 0; i < containers.length; i++) {
265
272
  const container = containers[i];
273
+ // If the app has already manually created a UI for this element,
274
+ // don't create another one.
275
+ if (container['ui']) {
276
+ continue;
277
+ }
266
278
  goog.asserts.assert(container.tagName.toLowerCase() == 'div',
267
279
  'Container should be a div!');
268
280