Source: externs/shaka/text.js

  1. /*! @license
  2. * Shaka Player
  3. * Copyright 2016 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @externs
  8. */
  9. /**
  10. * An interface for plugins that parse text tracks.
  11. *
  12. * @interface
  13. * @exportDoc
  14. */
  15. shaka.extern.TextParser = class {
  16. /**
  17. * Parse an initialization segment. Some formats do not have init
  18. * segments so this won't always be called.
  19. *
  20. * @param {!Uint8Array} data
  21. * The data that makes up the init segment.
  22. *
  23. * @exportDoc
  24. */
  25. parseInit(data) {}
  26. /**
  27. * Parse a media segment and return the cues that make up the segment.
  28. *
  29. * @param {!Uint8Array} data
  30. * The next section of buffer.
  31. * @param {shaka.extern.TextParser.TimeContext} timeContext
  32. * The time information that should be used to adjust the times values
  33. * for each cue.
  34. * @param {?(string|undefined)} uri
  35. * The media uri.
  36. * @param {!Array<string>} images
  37. * @return {!Array<!shaka.text.Cue>}
  38. *
  39. * @exportDoc
  40. */
  41. parseMedia(data, timeContext, uri, images) {}
  42. /**
  43. * Notifies the stream if the manifest is in sequence mode or not.
  44. *
  45. * @param {boolean} sequenceMode
  46. */
  47. setSequenceMode(sequenceMode) {}
  48. /**
  49. * Notifies the manifest type.
  50. *
  51. * @param {string} manifestType
  52. */
  53. setManifestType(manifestType) {}
  54. };
  55. /**
  56. * A collection of time offsets used to adjust text cue times.
  57. *
  58. * @typedef {{
  59. * periodStart: number,
  60. * segmentStart: number,
  61. * segmentEnd: number,
  62. * vttOffset: number
  63. * }}
  64. *
  65. * @property {number} periodStart
  66. * The absolute start time of the period in seconds.
  67. * @property {number} segmentStart
  68. * The absolute start time of the segment in seconds.
  69. * @property {number} segmentEnd
  70. * The absolute end time of the segment in seconds.
  71. * @property {number} vttOffset
  72. * The start time relative to either segment or period start depending
  73. * on <code>segmentRelativeVttTiming</code> configuration.
  74. *
  75. * @exportDoc
  76. */
  77. shaka.extern.TextParser.TimeContext;
  78. /**
  79. * A callback used for editing cues before appending.
  80. * Provides the cue, the URI of the captions file the cue was parsed from, and
  81. * the time context that was used when generating that cue.
  82. * You can edit the cue object passed in.
  83. * @typedef {function(!shaka.text.Cue, ?string,
  84. * !shaka.extern.TextParser.TimeContext)}
  85. * @exportDoc
  86. */
  87. shaka.extern.TextParser.ModifyCueCallback;
  88. /**
  89. * @typedef {function():!shaka.extern.TextParser}
  90. * @exportDoc
  91. */
  92. shaka.extern.TextParserPlugin;
  93. /**
  94. * @summary
  95. * An interface for plugins that display text.
  96. *
  97. * @description
  98. * This should handle displaying the text cues on the page. This is given the
  99. * cues to display and told when to start and stop displaying. This should only
  100. * display the cues it is given and remove cues when told to.
  101. *
  102. * <p>
  103. * This should only change whether it is displaying the cues through the
  104. * <code>setTextVisibility</code> function; the app should not change the text
  105. * visibility outside the top-level Player methods. If you really want to
  106. * control text visibility outside the Player methods, you must set the
  107. * <code>streaming.alwaysStreamText</code> Player configuration value to
  108. * <code>true</code>.
  109. *
  110. * @interface
  111. * @extends {shaka.util.IDestroyable}
  112. * @exportDoc
  113. */
  114. shaka.extern.TextDisplayer = class {
  115. /**
  116. * @override
  117. * @exportDoc
  118. */
  119. destroy() {}
  120. /**
  121. * Sets the TextDisplayer configuration.
  122. *
  123. * @param {shaka.extern.TextDisplayerConfiguration} config
  124. */
  125. configure(config) {}
  126. /**
  127. * Append given text cues to the list of cues to be displayed.
  128. *
  129. * @param {!Array<!shaka.text.Cue>} cues
  130. * Text cues to be appended.
  131. *
  132. * @exportDoc
  133. */
  134. append(cues) {}
  135. /**
  136. * Remove all cues that are fully contained by the given time range (relative
  137. * to the presentation). <code>endTime</code> will be greater to equal to
  138. * <code>startTime</code>. <code>remove</code> should only return
  139. * <code>false</code> if the displayer has been destroyed. If the displayer
  140. * has not been destroyed <code>remove</code> should return <code>true</code>.
  141. *
  142. * @param {number} startTime
  143. * @param {number} endTime
  144. *
  145. * @return {boolean}
  146. *
  147. * @exportDoc
  148. */
  149. remove(startTime, endTime) {}
  150. /**
  151. * Returns true if text is currently visible.
  152. *
  153. * @return {boolean}
  154. *
  155. * @exportDoc
  156. */
  157. isTextVisible() {}
  158. /**
  159. * Set text visibility.
  160. *
  161. * @param {boolean} on
  162. *
  163. * @exportDoc
  164. */
  165. setTextVisibility(on) {}
  166. /**
  167. * Set the current language.
  168. *
  169. * @param {string} language
  170. *
  171. * @exportDoc
  172. */
  173. setTextLanguage(language) {}
  174. /**
  175. * Enable the current text displayer.
  176. *
  177. * @exportDoc
  178. */
  179. enableTextDisplayer() {}
  180. };
  181. /**
  182. * A factory for creating a TextDisplayer.
  183. *
  184. * @typedef {function():!shaka.extern.TextDisplayer}
  185. * @exportDoc
  186. */
  187. shaka.extern.TextDisplayer.Factory;