Source: externs/shaka/text.js

  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. * @externs
  19. */
  20. /**
  21. * @interface
  22. * @exportDoc
  23. */
  24. shaka.extern.CueRegion = function() {};
  25. /**
  26. * Region identifier.
  27. * @type {string}
  28. * @exportDoc
  29. */
  30. shaka.extern.CueRegion.prototype.id;
  31. /**
  32. * The X offset to start the rendering area in viewportAnchorUnits of the video
  33. * width.
  34. * @type {number}
  35. * @exportDoc
  36. */
  37. shaka.extern.CueRegion.prototype.viewportAnchorX;
  38. /**
  39. * The X offset to start the rendering area in viewportAnchorUnits of the video
  40. * height.
  41. * @type {number}
  42. * @exportDoc
  43. */
  44. shaka.extern.CueRegion.prototype.viewportAnchorY;
  45. /**
  46. * The X offset to start the rendering area in percentage (0-100) of
  47. * the region width.
  48. * @type {number}
  49. * @exportDoc
  50. */
  51. shaka.extern.CueRegion.prototype.regionAnchorX;
  52. /**
  53. * The Y offset to start the rendering area in percentage (0-100) of
  54. * the region height.
  55. * @type {number}
  56. * @exportDoc
  57. */
  58. shaka.extern.CueRegion.prototype.regionAnchorY;
  59. /**
  60. * The width of the rendering area in widthUnits.
  61. * @type {number}
  62. * @exportDoc
  63. */
  64. shaka.extern.CueRegion.prototype.width;
  65. /**
  66. * The width of the rendering area in heightUnits.
  67. * @type {number}
  68. * @exportDoc
  69. */
  70. shaka.extern.CueRegion.prototype.height;
  71. /**
  72. * The units (percentage, pixels or lines) the region height is in.
  73. * @type {shaka.text.CueRegion.units}
  74. * @exportDoc
  75. */
  76. shaka.extern.CueRegion.prototype.heightUnits;
  77. /**
  78. * The units (percentage or pixels) the region width is in.
  79. * @type {shaka.text.CueRegion.units}
  80. * @exportDoc
  81. */
  82. shaka.extern.CueRegion.prototype.widthUnits;
  83. /**
  84. * The units (percentage or pixels) the region viewportAnchors are in.
  85. * @type {shaka.text.CueRegion.units}
  86. * @exportDoc
  87. */
  88. shaka.extern.CueRegion.prototype.viewportAnchorUnits;
  89. /**
  90. * If scroll=UP, it means that cues in the region will be added to the bottom of
  91. * the region and will push any already displayed cues in the region up.
  92. * Otherwise (scroll=NONE) cues will stay fixed at the location
  93. * they were first painted in.
  94. * @type {shaka.text.CueRegion.scrollMode}
  95. * @exportDoc
  96. */
  97. shaka.extern.CueRegion.prototype.scroll;
  98. /**
  99. * @interface
  100. * @exportDoc
  101. */
  102. shaka.extern.Cue = function() {};
  103. /**
  104. * The start time of the cue in seconds, relative to the start of the
  105. * presentation.
  106. * @type {number}
  107. * @exportDoc
  108. */
  109. shaka.extern.Cue.prototype.startTime;
  110. /**
  111. * The end time of the cue in seconds, relative to the start of the
  112. * presentation.
  113. * @type {number}
  114. * @exportDoc
  115. */
  116. shaka.extern.Cue.prototype.endTime;
  117. /**
  118. * The text payload of the cue. If nestedCues is non-empty, this should be
  119. * empty. Top-level block containers should have no payload of their own.
  120. * @type {!string}
  121. * @exportDoc
  122. */
  123. shaka.extern.Cue.prototype.payload;
  124. /**
  125. * The region to render the cue into.
  126. * @type {shaka.extern.CueRegion}
  127. * @exportDoc
  128. */
  129. shaka.extern.Cue.prototype.region;
  130. /**
  131. * The indent (in percent) of the cue box in the direction defined by the
  132. * writing direction.
  133. * @type {?number}
  134. * @exportDoc
  135. */
  136. shaka.extern.Cue.prototype.position;
  137. /**
  138. * Position alignment of the cue.
  139. * @type {shaka.text.Cue.positionAlign}
  140. * @exportDoc
  141. */
  142. shaka.extern.Cue.prototype.positionAlign;
  143. /**
  144. * Size of the cue box (in percents), where 0 means "auto".
  145. * @type {number}
  146. * @exportDoc
  147. */
  148. shaka.extern.Cue.prototype.size;
  149. /**
  150. * Alignment of the text inside the cue box.
  151. * @type {shaka.text.Cue.textAlign}
  152. * @exportDoc
  153. */
  154. shaka.extern.Cue.prototype.textAlign;
  155. /**
  156. * Text direction of the cue.
  157. * @type {shaka.text.Cue.direction}
  158. * @exportDoc
  159. */
  160. shaka.extern.Cue.prototype.direction;
  161. /**
  162. * Text writing mode of the cue.
  163. * @type {shaka.text.Cue.writingMode}
  164. * @exportDoc
  165. */
  166. shaka.extern.Cue.prototype.writingMode;
  167. /**
  168. * The way to interpret line field. (Either as an integer line number or
  169. * percentage from the display box).
  170. * @type {shaka.text.Cue.lineInterpretation}
  171. * @exportDoc
  172. */
  173. shaka.extern.Cue.prototype.lineInterpretation;
  174. /**
  175. * The offset from the display box in either number of lines or
  176. * percentage depending on the value of lineInterpretation.
  177. * @type {?number}
  178. * @exportDoc
  179. */
  180. shaka.extern.Cue.prototype.line;
  181. /**
  182. * Separation between line areas inside the cue box in px or em
  183. * (e.g. '100px'/'100em'). If not specified, this should be no less than
  184. * the largest font size applied to the text in the cue.
  185. * @type {string}.
  186. * @exportDoc
  187. */
  188. shaka.extern.Cue.prototype.lineHeight;
  189. /**
  190. * Line alignment of the cue box.
  191. * Start alignment means the cue box’s top side (for horizontal cues), left side
  192. * (for vertical growing right), or right side (for vertical growing left) is
  193. * aligned at the line.
  194. * Center alignment means the cue box is centered at the line.
  195. * End alignment The cue box’s bottom side (for horizontal cues), right side
  196. * (for vertical growing right), or left side (for vertical growing left) is
  197. * aligned at the line.
  198. * @type {shaka.text.Cue.lineAlign}
  199. * @exportDoc
  200. */
  201. shaka.extern.Cue.prototype.lineAlign;
  202. /**
  203. * Vertical alignments of the cues within their extents.
  204. * 'BEFORE' means displaying the captions at the top of the text display
  205. * container box, 'CENTER' means in the middle, 'AFTER' means at the bottom.
  206. * @type {shaka.text.Cue.displayAlign}
  207. * @exportDoc
  208. */
  209. shaka.extern.Cue.prototype.displayAlign;
  210. /**
  211. * Text color represented by any string that would be accepted in CSS.
  212. * E. g. '#FFFFFF' or 'white'.
  213. * @type {!string}
  214. * @exportDoc
  215. */
  216. shaka.extern.Cue.prototype.color;
  217. /**
  218. * Text background color represented by any string that would be
  219. * accepted in CSS.
  220. * E. g. '#FFFFFF' or 'white'.
  221. * @type {!string}
  222. * @exportDoc
  223. */
  224. shaka.extern.Cue.prototype.backgroundColor;
  225. /**
  226. * Image background represented by any string that would be
  227. * accepted in image HTML element.
  228. * E. g. 'data:[mime type];base64,[data]'.
  229. * @type {!string}
  230. * @exportDoc
  231. */
  232. shaka.extern.Cue.prototype.backgroundImage;
  233. /**
  234. * Text font size in px or em (e.g. '100px'/'100em').
  235. * @type {string}
  236. * @exportDoc
  237. */
  238. shaka.extern.Cue.prototype.fontSize;
  239. /**
  240. * Text font weight. Either normal or bold.
  241. * @type {shaka.text.Cue.fontWeight}
  242. * @exportDoc
  243. */
  244. shaka.extern.Cue.prototype.fontWeight;
  245. /**
  246. * Text font style. Normal, italic or oblique.
  247. * @type {shaka.text.Cue.fontStyle}
  248. * @exportDoc
  249. */
  250. shaka.extern.Cue.prototype.fontStyle;
  251. /**
  252. * Text font family.
  253. * @type {!string}
  254. * @exportDoc
  255. */
  256. shaka.extern.Cue.prototype.fontFamily;
  257. /**
  258. * Text decoration. A combination of underline, overline
  259. * and line through. Empty array means no decoration.
  260. * @type {!Array.<!shaka.text.Cue.textDecoration>}
  261. * @exportDoc
  262. */
  263. shaka.extern.Cue.prototype.textDecoration;
  264. /**
  265. * Whether or not line wrapping should be applied to the cue.
  266. * @type {boolean}
  267. * @exportDoc
  268. */
  269. shaka.extern.Cue.prototype.wrapLine;
  270. /**
  271. * Id of the cue.
  272. * @type {!string}
  273. * @exportDoc
  274. */
  275. shaka.extern.Cue.prototype.id;
  276. /**
  277. * Nested cues, which should be laid out horizontally in one block.
  278. * @type {Array.<!shaka.extern.Cue>}
  279. * @exportDoc
  280. */
  281. shaka.extern.Cue.prototype.nestedCues;
  282. /**
  283. * Whether or not the cue only acts as a line break between two nested cues.
  284. * Should only appear in nested cues.
  285. * @type {boolean}
  286. * @exportDoc
  287. */
  288. shaka.extern.Cue.prototype.spacer;
  289. /**
  290. * An interface for plugins that parse text tracks.
  291. *
  292. * @interface
  293. * @exportDoc
  294. */
  295. shaka.extern.TextParser = function() {};
  296. /**
  297. * A collection of time offsets used to adjust text cue times.
  298. *
  299. * @typedef {{
  300. * periodStart: number,
  301. * segmentStart: ?number,
  302. * segmentEnd: number
  303. * }}
  304. *
  305. * @property {number} periodStart
  306. * The absolute start time of the period in seconds.
  307. * @property {?number} segmentStart
  308. * The absolute start time of the segment in seconds.
  309. * Null if the manifest does not provide this information, such as in HLS.
  310. * @property {number} segmentEnd
  311. * The absolute end time of the segment in seconds.
  312. *
  313. * @exportDoc
  314. */
  315. shaka.extern.TextParser.TimeContext;
  316. /**
  317. * Parse an initialization segment. Some formats do not have init
  318. * segments so this won't always be called.
  319. *
  320. * @param {!Uint8Array} data
  321. * The data that makes up the init segment.
  322. *
  323. * @exportDoc
  324. */
  325. shaka.extern.TextParser.prototype.parseInit = function(data) {};
  326. /**
  327. * Parse a media segment and return the cues that make up the segment.
  328. *
  329. * @param {!Uint8Array} data
  330. * The next section of buffer.
  331. * @param {shaka.extern.TextParser.TimeContext} timeContext
  332. * The time information that should be used to adjust the times values
  333. * for each cue.
  334. * @return {!Array.<!shaka.extern.Cue>}
  335. *
  336. * @exportDoc
  337. */
  338. shaka.extern.TextParser.prototype.parseMedia = function(data, timeContext) {};
  339. /**
  340. * @typedef {function(new:shaka.extern.TextParser)}
  341. * @exportDoc
  342. */
  343. shaka.extern.TextParserPlugin;
  344. /**
  345. * An interface for plugins that display text.
  346. *
  347. * @interface
  348. * @extends {shaka.util.IDestroyable}
  349. * @exportDoc
  350. */
  351. shaka.extern.TextDisplayer = function() {};
  352. /**
  353. * @override
  354. * @exportDoc
  355. */
  356. shaka.extern.TextDisplayer.prototype.destroy = function() {};
  357. /**
  358. * Append given text cues to the list of cues to be displayed.
  359. *
  360. * @param {!Array.<!shaka.text.Cue>} cues
  361. * Text cues to be appended.
  362. *
  363. * @exportDoc
  364. */
  365. shaka.extern.TextDisplayer.prototype.append = function(cues) {};
  366. /**
  367. * Remove all cues that are fully contained by the given time range (relative
  368. * to the presentation). |endTime| will be greater to equal to |startTime|.
  369. * |remove| should only return |false| if the displayer has been destroyed. If
  370. * the displayer has not been destroyed |remove| should return |true|.
  371. *
  372. * @param {number} startTime
  373. * @param {number} endTime
  374. *
  375. * @return {boolean}
  376. *
  377. * @exportDoc
  378. */
  379. shaka.extern.TextDisplayer.prototype.remove = function(startTime, endTime) {};
  380. /**
  381. * Returns true if text is currently visible.
  382. *
  383. * @return {boolean}
  384. *
  385. * @exportDoc
  386. */
  387. shaka.extern.TextDisplayer.prototype.isTextVisible = function() {};
  388. /**
  389. * Set text visibility.
  390. *
  391. * @param {boolean} on
  392. *
  393. * @exportDoc
  394. */
  395. shaka.extern.TextDisplayer.prototype.setTextVisibility = function(on) {};
  396. /**
  397. * A factory for creating a TextDisplayer.
  398. *
  399. * @typedef {function(new:shaka.extern.TextDisplayer)}
  400. * @exportDoc
  401. */
  402. shaka.extern.TextDisplayer.Factory;