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