shaka-player 4.4.2 → 4.5.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 (202) hide show
  1. package/.github/workflows/release-please.yaml +2 -27
  2. package/CHANGELOG.md +67 -25
  3. package/README.md +16 -10
  4. package/demo/asset_card.js +18 -21
  5. package/demo/cast_receiver/index.html +0 -1
  6. package/demo/close_button.js +0 -3
  7. package/demo/common/asset.js +27 -5
  8. package/demo/common/assets.js +150 -52
  9. package/demo/config.js +192 -253
  10. package/demo/custom.js +39 -98
  11. package/demo/front.js +7 -10
  12. package/demo/index.html +19 -22
  13. package/demo/input.js +6 -11
  14. package/demo/input_container.js +8 -9
  15. package/demo/main.js +52 -124
  16. package/demo/search.js +23 -35
  17. package/demo/service_worker.js +0 -3
  18. package/demo/tooltip.js +3 -5
  19. package/demo/visualizer.js +3 -5
  20. package/demo/visualizer_button.js +1 -20
  21. package/dist/demo.compiled.debug.js +187 -211
  22. package/dist/demo.compiled.debug.map +4 -4
  23. package/dist/demo.compiled.js +187 -211
  24. package/dist/demo.compiled.map +4 -4
  25. package/dist/deps.js +27 -24
  26. package/dist/locales.js +31 -31
  27. package/dist/receiver.compiled.debug.js +42 -61
  28. package/dist/receiver.compiled.debug.map +4 -4
  29. package/dist/receiver.compiled.js +42 -61
  30. package/dist/receiver.compiled.map +4 -4
  31. package/dist/shaka-player.compiled.d.ts +728 -365
  32. package/dist/shaka-player.compiled.debug.d.ts +728 -365
  33. package/dist/shaka-player.compiled.debug.externs.js +475 -51
  34. package/dist/shaka-player.compiled.debug.js +576 -480
  35. package/dist/shaka-player.compiled.debug.map +4 -4
  36. package/dist/shaka-player.compiled.externs.js +475 -51
  37. package/dist/shaka-player.compiled.js +1117 -1056
  38. package/dist/shaka-player.compiled.map +4 -4
  39. package/dist/shaka-player.ui.d.ts +783 -410
  40. package/dist/shaka-player.ui.debug.d.ts +783 -410
  41. package/dist/shaka-player.ui.debug.externs.js +496 -51
  42. package/dist/shaka-player.ui.debug.js +647 -542
  43. package/dist/shaka-player.ui.debug.map +4 -4
  44. package/dist/shaka-player.ui.externs.js +496 -51
  45. package/dist/shaka-player.ui.js +1260 -1194
  46. package/dist/shaka-player.ui.map +4 -4
  47. package/docs/design/lcevc-integration.md +14 -14
  48. package/docs/tutorials/faq.md +27 -55
  49. package/docs/tutorials/index.json +2 -1
  50. package/docs/tutorials/lcevc.md +118 -0
  51. package/docs/tutorials/offline.md +1 -1
  52. package/docs/tutorials/ui-customization.md +4 -0
  53. package/externs/css_style_declaration.js +19 -0
  54. package/externs/lcevc.js +37 -13
  55. package/externs/media_remote.js +68 -0
  56. package/externs/mediatailor.js +193 -0
  57. package/externs/pictureinpicture.js +11 -0
  58. package/externs/shaka/ads.js +27 -0
  59. package/externs/shaka/manifest.js +10 -5
  60. package/externs/shaka/manifest_parser.js +7 -1
  61. package/externs/shaka/offline.js +4 -0
  62. package/externs/shaka/player.js +12 -1
  63. package/karma.conf.js +7 -3
  64. package/lib/abr/simple_abr_manager.js +43 -3
  65. package/lib/ads/ad_manager.js +104 -50
  66. package/lib/ads/media_tailor_ad.js +297 -0
  67. package/lib/ads/media_tailor_ad_manager.js +828 -0
  68. package/lib/cea/ts_cea_parser.js +15 -2
  69. package/lib/config/codec_switching_strategy.js +24 -0
  70. package/lib/dash/content_protection.js +120 -2
  71. package/lib/dash/dash_parser.js +79 -13
  72. package/lib/dash/mpd_utils.js +10 -6
  73. package/lib/dash/segment_base.js +13 -5
  74. package/lib/dash/segment_list.js +13 -5
  75. package/lib/dash/segment_template.js +43 -85
  76. package/lib/dependencies/all.js +8 -7
  77. package/lib/hls/hls_parser.js +101 -37
  78. package/lib/lcevc/lcevc_dec.js +220 -0
  79. package/lib/media/adaptation_set.js +22 -11
  80. package/lib/media/adaptation_set_criteria.js +25 -7
  81. package/lib/media/media_source_engine.js +215 -27
  82. package/lib/media/segment_index.js +5 -5
  83. package/lib/media/segment_reference.js +10 -5
  84. package/lib/media/streaming_engine.js +44 -39
  85. package/lib/mss/mss_parser.js +1 -0
  86. package/lib/net/networking_engine.js +1 -0
  87. package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
  88. package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
  89. package/lib/offline/manifest_converter.js +1 -0
  90. package/lib/offline/storage.js +3 -0
  91. package/lib/player.js +142 -72
  92. package/lib/routing/payload.js +5 -1
  93. package/lib/text/cue.js +62 -47
  94. package/lib/text/ttml_text_parser.js +17 -0
  95. package/lib/text/ui_text_displayer.js +4 -0
  96. package/lib/text/vtt_text_parser.js +35 -22
  97. package/lib/transmuxer/h265.js +862 -0
  98. package/lib/transmuxer/mpeg_ts_transmuxer.js +3 -2
  99. package/lib/transmuxer/ts_transmuxer.js +160 -15
  100. package/lib/util/cmcd_manager.js +6 -1
  101. package/lib/util/error.js +28 -9
  102. package/lib/util/exp_golomb.js +30 -2
  103. package/lib/util/fake_event.js +3 -0
  104. package/lib/util/manifest_parser_utils.js +10 -4
  105. package/lib/util/mp4_generator.js +4 -4
  106. package/lib/util/periods.js +2 -0
  107. package/lib/util/platform.js +54 -0
  108. package/lib/util/player_configuration.js +8 -0
  109. package/lib/util/state_history.js +6 -2
  110. package/lib/util/stream_utils.js +133 -217
  111. package/lib/util/ts_parser.js +229 -43
  112. package/maintained-branches.md +3 -2
  113. package/package.json +4 -6
  114. package/roadmap.md +15 -5
  115. package/shaka-player.uncompiled.js +2 -1
  116. package/support.html +0 -1
  117. package/test/cast/cast_receiver_integration.js +47 -0
  118. package/test/codec_switching/codec_switching_integration.js +181 -0
  119. package/test/dash/dash_parser_content_protection_unit.js +2 -0
  120. package/test/dash/dash_parser_integration.js +73 -0
  121. package/test/dash/dash_parser_live_unit.js +2 -0
  122. package/test/dash/dash_parser_manifest_unit.js +47 -0
  123. package/test/dash/dash_parser_segment_base_unit.js +7 -0
  124. package/test/dash/dash_parser_segment_list_unit.js +23 -17
  125. package/test/dash/dash_parser_segment_template_unit.js +49 -0
  126. package/test/demo/demo_unit.js +0 -16
  127. package/test/hls/hls_live_unit.js +35 -0
  128. package/test/hls/hls_parser_unit.js +8 -61
  129. package/test/media/adaptation_set_criteria_unit.js +118 -0
  130. package/test/media/adaptation_set_unit.js +1 -0
  131. package/test/media/media_source_engine_unit.js +165 -1
  132. package/test/media/segment_index_unit.js +4 -4
  133. package/test/media/segment_prefetch_unit.js +1 -1
  134. package/test/media/streaming_engine_unit.js +17 -17
  135. package/test/mss/mss_parser_unit.js +2 -0
  136. package/test/offline/manifest_convert_unit.js +5 -0
  137. package/test/offline/storage_integration.js +1 -4
  138. package/test/player_unit.js +102 -131
  139. package/test/routing/walker_unit.js +1 -0
  140. package/test/test/assets/dash-aes-128/Fragments(video=0,format=mpd-time-csf) +0 -0
  141. package/test/test/assets/dash-aes-128/Fragments(video=20000000,format=mpd-time-csf) +0 -0
  142. package/test/test/assets/dash-aes-128/Fragments(video=40000000,format=mpd-time-csf) +0 -0
  143. package/test/test/assets/dash-aes-128/Fragments(video=60000000,format=mpd-time-csf) +0 -0
  144. package/test/test/assets/dash-aes-128/Fragments(video=i,format=mpd-time-csf) +0 -0
  145. package/test/test/assets/dash-aes-128/dash.mpd +18 -0
  146. package/test/test/assets/dash-aes-128/license +1 -0
  147. package/test/test/assets/dash-multi-codec/audio_en_2c_128k_aac.mp4 +0 -0
  148. package/test/test/assets/dash-multi-codec/audio_es_2c_64k_opus.webm +0 -0
  149. package/test/test/assets/dash-multi-codec/dash.mpd +32 -0
  150. package/test/test/assets/dash-multi-codec/video_144p_108k_h264.mp4 +0 -0
  151. package/test/test/assets/hls-ts-h265/0.ts +0 -0
  152. package/test/test/assets/hls-ts-h265/hevc.m3u8 +6 -0
  153. package/test/test/assets/hls-ts-h265/index.m3u8 +7 -0
  154. package/test/test/assets/hls-ts-muxed-aac-h265/0.ts +0 -0
  155. package/test/test/assets/hls-ts-muxed-aac-h265/1.ts +0 -0
  156. package/test/test/assets/hls-ts-muxed-aac-h265/media.m3u8 +9 -0
  157. package/test/test/assets/hls-ts-muxed-ac3-h264/media.m3u8 +24 -0
  158. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00000.ts +0 -0
  159. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00001.ts +0 -0
  160. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00002.ts +0 -0
  161. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00003.ts +0 -0
  162. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00004.ts +0 -0
  163. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00005.ts +0 -0
  164. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0000.ts +0 -0
  165. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0001.ts +0 -0
  166. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0002.ts +0 -0
  167. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0003.ts +0 -0
  168. package/test/test/assets/hls-ts-muxed-ec3-h264/prog_index.m3u8 +14 -0
  169. package/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8 +23 -0
  170. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-1-v1-a1.ts +0 -0
  171. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-2-v1-a1.ts +0 -0
  172. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-3-v1-a1.ts +0 -0
  173. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-4-v1-a1.ts +0 -0
  174. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-5-v1-a1.ts +0 -0
  175. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-6-v1-a1.ts +0 -0
  176. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-7-v1-a1.ts +0 -0
  177. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-8-v1-a1.ts +0 -0
  178. package/test/test/util/dash_parser_util.js +20 -7
  179. package/test/test/util/fake_ad_manager.js +20 -0
  180. package/test/test/util/fake_media_source_engine.js +8 -2
  181. package/test/test/util/manifest_generator.js +7 -3
  182. package/test/test/util/mss_parser_util.js +4 -0
  183. package/test/test/util/offline_utils.js +1 -0
  184. package/test/test/util/streaming_engine_util.js +7 -4
  185. package/test/text/ttml_text_parser_unit.js +52 -0
  186. package/test/text/vtt_text_parser_unit.js +105 -48
  187. package/test/transmuxer/transmuxer_integration.js +121 -4
  188. package/test/ui/ui_unit.js +3 -10
  189. package/test/util/stream_utils_unit.js +208 -74
  190. package/test/util/ts_parser_unit.js +1 -1
  191. package/ui/controls.js +125 -0
  192. package/ui/externs/ui.js +8 -1
  193. package/ui/pip_button.js +22 -120
  194. package/ui/remote_button.js +201 -0
  195. package/ui/ui.js +5 -2
  196. package/demo/common/message_ids.js +0 -309
  197. package/demo/locales/en.json +0 -287
  198. package/demo/locales/source.json +0 -1142
  199. package/externs/mux.js +0 -69
  200. package/lib/lcevc/lcevc_dil.js +0 -152
  201. package/lib/transmuxer/muxjs_transmuxer.js +0 -242
  202. package/test/transmuxer/muxjs_transmuxer_integration.js +0 -177
package/lib/text/cue.js CHANGED
@@ -26,7 +26,7 @@ shaka.text.Cue = class {
26
26
  * The start time of the cue in seconds, relative to the start of the
27
27
  * presentation.
28
28
  * @type {number}
29
- * @exportDoc
29
+ * @export
30
30
  */
31
31
  this.startTime = startTime;
32
32
 
@@ -34,7 +34,7 @@ shaka.text.Cue = class {
34
34
  * The end time of the cue in seconds, relative to the start of the
35
35
  * presentation.
36
36
  * @type {number}
37
- * @exportDoc
37
+ * @export
38
38
  */
39
39
  this.endTime = endTime;
40
40
 
@@ -42,7 +42,7 @@ shaka.text.Cue = class {
42
42
  * The text payload of the cue. If nestedCues is non-empty, this should be
43
43
  * empty. Top-level block containers should have no payload of their own.
44
44
  * @type {string}
45
- * @exportDoc
45
+ * @export
46
46
  */
47
47
  this.payload = payload;
48
48
 
@@ -50,7 +50,7 @@ shaka.text.Cue = class {
50
50
  * The region to render the cue into. Only supported on top-level cues,
51
51
  * because nested cues are inline elements.
52
52
  * @type {shaka.text.CueRegion}
53
- * @exportDoc
53
+ * @export
54
54
  */
55
55
  this.region = new shaka.text.CueRegion();
56
56
 
@@ -58,42 +58,42 @@ shaka.text.Cue = class {
58
58
  * The indent (in percent) of the cue box in the direction defined by the
59
59
  * writing direction.
60
60
  * @type {?number}
61
- * @exportDoc
61
+ * @export
62
62
  */
63
63
  this.position = null;
64
64
 
65
65
  /**
66
66
  * Position alignment of the cue.
67
67
  * @type {shaka.text.Cue.positionAlign}
68
- * @exportDoc
68
+ * @export
69
69
  */
70
70
  this.positionAlign = Cue.positionAlign.AUTO;
71
71
 
72
72
  /**
73
73
  * Size of the cue box (in percents), where 0 means "auto".
74
74
  * @type {number}
75
- * @exportDoc
75
+ * @export
76
76
  */
77
77
  this.size = 0;
78
78
 
79
79
  /**
80
80
  * Alignment of the text inside the cue box.
81
81
  * @type {shaka.text.Cue.textAlign}
82
- * @exportDoc
82
+ * @export
83
83
  */
84
84
  this.textAlign = Cue.textAlign.CENTER;
85
85
 
86
86
  /**
87
87
  * Text direction of the cue.
88
88
  * @type {shaka.text.Cue.direction}
89
- * @exportDoc
89
+ * @export
90
90
  */
91
91
  this.direction = Cue.direction.HORIZONTAL_LEFT_TO_RIGHT;
92
92
 
93
93
  /**
94
94
  * Text writing mode of the cue.
95
95
  * @type {shaka.text.Cue.writingMode}
96
- * @exportDoc
96
+ * @export
97
97
  */
98
98
  this.writingMode = Cue.writingMode.HORIZONTAL_TOP_TO_BOTTOM;
99
99
 
@@ -101,7 +101,7 @@ shaka.text.Cue = class {
101
101
  * The way to interpret line field. (Either as an integer line number or
102
102
  * percentage from the display box).
103
103
  * @type {shaka.text.Cue.lineInterpretation}
104
- * @exportDoc
104
+ * @export
105
105
  */
106
106
  this.lineInterpretation = Cue.lineInterpretation.LINE_NUMBER;
107
107
 
@@ -109,7 +109,7 @@ shaka.text.Cue = class {
109
109
  * The offset from the display box in either number of lines or
110
110
  * percentage depending on the value of lineInterpretation.
111
111
  * @type {?number}
112
- * @exportDoc
112
+ * @export
113
113
  */
114
114
  this.line = null;
115
115
 
@@ -118,7 +118,7 @@ shaka.text.Cue = class {
118
118
  * (e.g. '100px'/'100em'). If not specified, this should be no less than
119
119
  * the largest font size applied to the text in the cue.
120
120
  * @type {string}.
121
- * @exportDoc
121
+ * @export
122
122
  */
123
123
  this.lineHeight = '';
124
124
 
@@ -132,7 +132,7 @@ shaka.text.Cue = class {
132
132
  * (for vertical growing right), or left side (for vertical growing left) is
133
133
  * aligned at the line.
134
134
  * @type {shaka.text.Cue.lineAlign}
135
- * @exportDoc
135
+ * @export
136
136
  */
137
137
  this.lineAlign = Cue.lineAlign.START;
138
138
 
@@ -141,127 +141,134 @@ shaka.text.Cue = class {
141
141
  * 'BEFORE' means displaying the captions at the top of the text display
142
142
  * container box, 'CENTER' means in the middle, 'AFTER' means at the bottom.
143
143
  * @type {shaka.text.Cue.displayAlign}
144
- * @exportDoc
144
+ * @export
145
145
  */
146
146
  this.displayAlign = Cue.displayAlign.AFTER;
147
147
 
148
148
  /**
149
149
  * Text color as a CSS color, e.g. "#FFFFFF" or "white".
150
150
  * @type {string}
151
- * @exportDoc
151
+ * @export
152
152
  */
153
153
  this.color = '';
154
154
 
155
155
  /**
156
156
  * Text background color as a CSS color, e.g. "#FFFFFF" or "white".
157
157
  * @type {string}
158
- * @exportDoc
158
+ * @export
159
159
  */
160
160
  this.backgroundColor = '';
161
161
 
162
162
  /**
163
163
  * The URL of the background image, e.g. "data:[mime type];base64,[data]".
164
164
  * @type {string}
165
- * @exportDoc
165
+ * @export
166
166
  */
167
167
  this.backgroundImage = '';
168
168
 
169
169
  /**
170
170
  * The border around this cue as a CSS border.
171
171
  * @type {string}
172
- * @exportDoc
172
+ * @export
173
173
  */
174
174
  this.border = '';
175
175
 
176
176
  /**
177
177
  * Text font size in px or em (e.g. '100px'/'100em').
178
178
  * @type {string}
179
- * @exportDoc
179
+ * @export
180
180
  */
181
181
  this.fontSize = '';
182
182
 
183
183
  /**
184
184
  * Text font weight. Either normal or bold.
185
185
  * @type {shaka.text.Cue.fontWeight}
186
- * @exportDoc
186
+ * @export
187
187
  */
188
188
  this.fontWeight = Cue.fontWeight.NORMAL;
189
189
 
190
190
  /**
191
191
  * Text font style. Normal, italic or oblique.
192
192
  * @type {shaka.text.Cue.fontStyle}
193
- * @exportDoc
193
+ * @export
194
194
  */
195
195
  this.fontStyle = Cue.fontStyle.NORMAL;
196
196
 
197
197
  /**
198
198
  * Text font family.
199
199
  * @type {string}
200
- * @exportDoc
200
+ * @export
201
201
  */
202
202
  this.fontFamily = '';
203
203
 
204
204
  /**
205
205
  * Text letter spacing as a CSS letter-spacing value.
206
206
  * @type {string}
207
- * @exportDoc
207
+ * @export
208
208
  */
209
209
  this.letterSpacing = '';
210
210
 
211
211
  /**
212
212
  * Text line padding as a CSS line-padding value.
213
213
  * @type {string}
214
- * @exportDoc
214
+ * @export
215
215
  */
216
216
  this.linePadding = '';
217
217
 
218
218
  /**
219
219
  * Opacity of the cue element, from 0-1.
220
220
  * @type {number}
221
- * @exportDoc
221
+ * @export
222
222
  */
223
223
  this.opacity = 1;
224
224
 
225
+ /**
226
+ * Text combine upright as a CSS text-combine-upright value.
227
+ * @type {string}
228
+ * @export
229
+ */
230
+ this.textCombineUpright = '';
231
+
225
232
  /**
226
233
  * Text decoration. A combination of underline, overline
227
234
  * and line through. Empty array means no decoration.
228
235
  * @type {!Array.<!shaka.text.Cue.textDecoration>}
229
- * @exportDoc
236
+ * @export
230
237
  */
231
238
  this.textDecoration = [];
232
239
 
233
240
  /**
234
241
  * Text shadow color as a CSS text-shadow value.
235
242
  * @type {string}
236
- * @exportDoc
243
+ * @export
237
244
  */
238
245
  this.textShadow = '';
239
246
 
240
247
  /**
241
248
  * Text stroke color as a CSS color, e.g. "#FFFFFF" or "white".
242
249
  * @type {string}
243
- * @exportDoc
250
+ * @export
244
251
  */
245
252
  this.textStrokeColor = '';
246
253
 
247
254
  /**
248
255
  * Text stroke width as a CSS stroke-width value.
249
256
  * @type {string}
250
- * @exportDoc
257
+ * @export
251
258
  */
252
259
  this.textStrokeWidth = '';
253
260
 
254
261
  /**
255
262
  * Whether or not line wrapping should be applied to the cue.
256
263
  * @type {boolean}
257
- * @exportDoc
264
+ * @export
258
265
  */
259
266
  this.wrapLine = true;
260
267
 
261
268
  /**
262
269
  * Id of the cue.
263
270
  * @type {string}
264
- * @exportDoc
271
+ * @export
265
272
  */
266
273
  this.id = '';
267
274
 
@@ -270,7 +277,7 @@ shaka.text.Cue = class {
270
277
  * Top-level cues are blocks, and nested cues are inline elements.
271
278
  * Cues can be nested arbitrarily deeply.
272
279
  * @type {!Array.<!shaka.text.Cue>}
273
- * @exportDoc
280
+ * @export
274
281
  */
275
282
  this.nestedCues = [];
276
283
 
@@ -280,7 +287,7 @@ shaka.text.Cue = class {
280
287
  * in a TTML file. This controls the flow of the final cues; any nested cues
281
288
  * within an "isContainer" cue will be laid out as separate lines.
282
289
  * @type {boolean}
283
- * @exportDoc
290
+ * @export
284
291
  */
285
292
  this.isContainer = false;
286
293
 
@@ -288,16 +295,24 @@ shaka.text.Cue = class {
288
295
  * Whether or not the cue only acts as a line break between two nested cues.
289
296
  * Should only appear in nested cues.
290
297
  * @type {boolean}
291
- * @exportDoc
298
+ * @export
292
299
  */
293
300
  this.lineBreak = false;
294
301
 
302
+ /**
303
+ * Used to indicate the type of ruby tag that should be used when rendering
304
+ * the cue. Valid values: ruby, rp, rt.
305
+ * @type {?string}
306
+ * @export
307
+ */
308
+ this.rubyTag = null;
309
+
295
310
  /**
296
311
  * The number of horizontal and vertical cells into which the Root Container
297
312
  * Region area is divided.
298
313
  *
299
314
  * @type {{ columns: number, rows: number }}
300
- * @exportDoc
315
+ * @export
301
316
  */
302
317
  this.cellResolution = {
303
318
  columns: 32,
@@ -551,7 +566,7 @@ shaka.text.CueRegion = class {
551
566
  /**
552
567
  * Region identifier.
553
568
  * @type {string}
554
- * @exportDoc
569
+ * @export
555
570
  */
556
571
  this.id = '';
557
572
 
@@ -559,7 +574,7 @@ shaka.text.CueRegion = class {
559
574
  * The X offset to start the rendering area in viewportAnchorUnits of the
560
575
  * video width.
561
576
  * @type {number}
562
- * @exportDoc
577
+ * @export
563
578
  */
564
579
  this.viewportAnchorX = 0;
565
580
 
@@ -567,7 +582,7 @@ shaka.text.CueRegion = class {
567
582
  * The X offset to start the rendering area in viewportAnchorUnits of the
568
583
  * video height.
569
584
  * @type {number}
570
- * @exportDoc
585
+ * @export
571
586
  */
572
587
  this.viewportAnchorY = 0;
573
588
 
@@ -575,7 +590,7 @@ shaka.text.CueRegion = class {
575
590
  * The X offset to start the rendering area in percentage (0-100) of this
576
591
  * region width.
577
592
  * @type {number}
578
- * @exportDoc
593
+ * @export
579
594
  */
580
595
  this.regionAnchorX = 0;
581
596
 
@@ -583,42 +598,42 @@ shaka.text.CueRegion = class {
583
598
  * The Y offset to start the rendering area in percentage (0-100) of the
584
599
  * region height.
585
600
  * @type {number}
586
- * @exportDoc
601
+ * @export
587
602
  */
588
603
  this.regionAnchorY = 0;
589
604
 
590
605
  /**
591
606
  * The width of the rendering area in widthUnits.
592
607
  * @type {number}
593
- * @exportDoc
608
+ * @export
594
609
  */
595
610
  this.width = 100;
596
611
 
597
612
  /**
598
613
  * The width of the rendering area in heightUnits.
599
614
  * @type {number}
600
- * @exportDoc
615
+ * @export
601
616
  */
602
617
  this.height = 100;
603
618
 
604
619
  /**
605
620
  * The units (percentage, pixels or lines) the region height is in.
606
621
  * @type {shaka.text.CueRegion.units}
607
- * @exportDoc
622
+ * @export
608
623
  */
609
624
  this.heightUnits = CueRegion.units.PERCENTAGE;
610
625
 
611
626
  /**
612
627
  * The units (percentage or pixels) the region width is in.
613
628
  * @type {shaka.text.CueRegion.units}
614
- * @exportDoc
629
+ * @export
615
630
  */
616
631
  this.widthUnits = CueRegion.units.PERCENTAGE;
617
632
 
618
633
  /**
619
634
  * The units (percentage or pixels) the region viewportAnchors are in.
620
635
  * @type {shaka.text.CueRegion.units}
621
- * @exportDoc
636
+ * @export
622
637
  */
623
638
  this.viewportAnchorUnits = CueRegion.units.PERCENTAGE;
624
639
 
@@ -628,7 +643,7 @@ shaka.text.CueRegion = class {
628
643
  * region up. Otherwise (scroll=NONE) cues will stay fixed at the location
629
644
  * they were first painted in.
630
645
  * @type {shaka.text.CueRegion.scrollMode}
631
- * @exportDoc
646
+ * @export
632
647
  */
633
648
  this.scroll = CueRegion.scrollMode.NONE;
634
649
  }
@@ -724,6 +724,23 @@ shaka.text.TtmlTextParser = class {
724
724
  if (textDecorationElement) {
725
725
  TtmlTextParser.addTextDecoration_(cue, textDecorationElement);
726
726
  }
727
+
728
+ const textCombine = TtmlTextParser.getStyleAttribute_(
729
+ cueElement, region, styles, 'textCombine', shouldInheritRegionStyles);
730
+ if (textCombine) {
731
+ cue.textCombineUpright = textCombine;
732
+ }
733
+
734
+ const ruby = TtmlTextParser.getStyleAttribute_(
735
+ cueElement, region, styles, 'ruby', shouldInheritRegionStyles);
736
+ switch (ruby) {
737
+ case 'container':
738
+ cue.rubyTag = 'ruby';
739
+ break;
740
+ case 'text':
741
+ cue.rubyTag = 'rt';
742
+ break;
743
+ }
727
744
  }
728
745
 
729
746
  /**
@@ -452,6 +452,9 @@ shaka.text.UITextDisplayer = class {
452
452
  if (cue.lineBreak) {
453
453
  type = 'br';
454
454
  }
455
+ if (cue.rubyTag) {
456
+ type = cue.rubyTag;
457
+ }
455
458
 
456
459
  const needWrapper = !isNested && cue.nestedCues.length > 0;
457
460
 
@@ -561,6 +564,7 @@ shaka.text.UITextDisplayer = class {
561
564
  style.paddingRight =
562
565
  shaka.text.UITextDisplayer.convertLengthValue_(
563
566
  cue.linePadding, cue, this.videoContainer_);
567
+ style.textCombineUpright = cue.textCombineUpright;
564
568
  style.textShadow = cue.textShadow;
565
569
 
566
570
  if (cue.backgroundImage) {
@@ -333,6 +333,10 @@ shaka.text.VttTextParser = class {
333
333
  validStyle = true;
334
334
  cue.opacity = parseFloat(value);
335
335
  break;
336
+ case 'text-combine-upright':
337
+ validStyle = true;
338
+ cue.textCombineUpright = value;
339
+ break;
336
340
  case 'text-shadow':
337
341
  validStyle = true;
338
342
  cue.textShadow = value;
@@ -417,6 +421,8 @@ shaka.text.VttTextParser = class {
417
421
  cue = new shaka.text.Cue(start, end, '');
418
422
  }
419
423
 
424
+ VttTextParser.parseCueStyles(payload, cue, styles);
425
+
420
426
  // Parse optional settings.
421
427
  parser.skipWhitespace();
422
428
  let word = parser.readWord();
@@ -430,8 +436,6 @@ shaka.text.VttTextParser = class {
430
436
  word = parser.readWord();
431
437
  }
432
438
 
433
- VttTextParser.parseCueStyles(payload, cue, styles);
434
-
435
439
  if (id != null) {
436
440
  cue.id = id;
437
441
  }
@@ -456,8 +460,6 @@ shaka.text.VttTextParser = class {
456
460
  const xmlPayload = '<span>' + payload + '</span>';
457
461
  const element = shaka.util.XmlUtils.parseXmlString(xmlPayload, 'span');
458
462
  if (element) {
459
- /** @type {!Array.<!shaka.text.Cue>} */
460
- const cues = [];
461
463
  const childNodes = element.childNodes;
462
464
  if (childNodes.length == 1) {
463
465
  const childNode = childNodes[0];
@@ -468,10 +470,8 @@ shaka.text.VttTextParser = class {
468
470
  }
469
471
  }
470
472
  for (const childNode of childNodes) {
471
- VttTextParser.generateCueFromElement_(
472
- childNode, rootCue, cues, styles);
473
+ VttTextParser.generateCueFromElement_(childNode, rootCue, styles);
473
474
  }
474
- rootCue.nestedCues = cues;
475
475
  } else {
476
476
  shaka.log.warning('The cue\'s markup could not be parsed: ', payload);
477
477
  rootCue.payload = VttTextParser.htmlUnescape_(payload);
@@ -688,6 +688,8 @@ shaka.text.VttTextParser = class {
688
688
  cue.fontWeight = refCue.fontWeight;
689
689
  cue.fontStyle = refCue.fontStyle;
690
690
  cue.opacity = refCue.opacity;
691
+ cue.rubyTag = refCue.rubyTag;
692
+ cue.textCombineUpright = refCue.textCombineUpright;
691
693
  cue.textShadow = refCue.textShadow;
692
694
  cue.wrapLine = refCue.wrapLine;
693
695
  }
@@ -695,13 +697,16 @@ shaka.text.VttTextParser = class {
695
697
  /**
696
698
  * @param {!Node} element
697
699
  * @param {!shaka.text.Cue} rootCue
698
- * @param {Array.<!shaka.text.Cue>} cues
699
700
  * @param {!Map.<string, shaka.text.Cue>} styles
700
701
  * @private
701
702
  */
702
- static generateCueFromElement_(element, rootCue, cues, styles) {
703
+ static generateCueFromElement_(element, rootCue, styles) {
703
704
  const VttTextParser = shaka.text.VttTextParser;
704
705
  const nestedCue = rootCue.clone();
706
+ // We don't want propagate some properties.
707
+ nestedCue.nestedCues = [];
708
+ nestedCue.payload = '';
709
+ nestedCue.rubyTag = '';
705
710
  if (element.nodeType === Node.ELEMENT_NODE && element.nodeName) {
706
711
  const bold = shaka.text.Cue.fontWeight.BOLD;
707
712
  const italic = shaka.text.Cue.fontStyle.ITALIC;
@@ -724,10 +729,10 @@ shaka.text.VttTextParser = class {
724
729
  }
725
730
  switch (tag) {
726
731
  case 'br': {
727
- const lineBreakCue = rootCue.clone();
728
- lineBreakCue.lineBreak = true;
729
- cues.push(lineBreakCue);
730
- break;
732
+ const lineBreakCue = shaka.text.Cue.lineBreak(
733
+ nestedCue.startTime, nestedCue.endTime);
734
+ rootCue.nestedCues.push(lineBreakCue);
735
+ return;
731
736
  }
732
737
  case 'b':
733
738
  nestedCue.fontWeight = bold;
@@ -758,34 +763,42 @@ shaka.text.VttTextParser = class {
758
763
  }
759
764
  break;
760
765
  }
766
+ case 'ruby':
767
+ case 'rp':
768
+ case 'rt':
769
+ nestedCue.rubyTag = tag;
770
+ break;
761
771
  default:
762
772
  break;
763
773
  }
764
774
  }
765
775
  }
766
- const isTextNode = shaka.util.XmlUtils.isText(element);
767
- if (isTextNode) {
776
+
777
+ const isTextNode = (item) => shaka.util.XmlUtils.isText(item);
778
+ const childNodes = element.childNodes;
779
+ if (isTextNode(element) ||
780
+ (childNodes.length == 1 && isTextNode(childNodes[0]))) {
768
781
  // Trailing line breaks may lost when convert cue to HTML tag
769
782
  // Need to insert line break cue to preserve line breaks
770
783
  const textArr = element.textContent.split('\n');
771
784
  let isFirst = true;
772
785
  for (const text of textArr) {
773
786
  if (!isFirst) {
774
- const lineBreakCue = rootCue.clone();
775
- lineBreakCue.lineBreak = true;
776
- cues.push(lineBreakCue);
787
+ const lineBreakCue = shaka.text.Cue.lineBreak(
788
+ nestedCue.startTime, nestedCue.endTime);
789
+ rootCue.nestedCues.push(lineBreakCue);
777
790
  }
778
791
  if (text.length > 0) {
779
792
  const textCue = nestedCue.clone();
780
793
  textCue.payload = VttTextParser.htmlUnescape_(text);
781
- cues.push(textCue);
794
+ rootCue.nestedCues.push(textCue);
782
795
  }
783
796
  isFirst = false;
784
797
  }
785
798
  } else {
786
- for (const childNode of element.childNodes) {
787
- VttTextParser.generateCueFromElement_(
788
- childNode, nestedCue, cues, styles);
799
+ rootCue.nestedCues.push(nestedCue);
800
+ for (const childNode of childNodes) {
801
+ VttTextParser.generateCueFromElement_(childNode, nestedCue, styles);
789
802
  }
790
803
  }
791
804
  }