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. * @return {!Array.<!shaka.text.Cue>}
  37. *
  38. * @exportDoc
  39. */
  40. parseMedia(data, timeContext, uri) {}
  41. /**
  42. * Notifies the stream if the manifest is in sequence mode or not.
  43. *
  44. * @param {boolean} sequenceMode
  45. */
  46. setSequenceMode(sequenceMode) {}
  47. /**
  48. * Notifies the manifest type.
  49. *
  50. * @param {string} manifestType
  51. */
  52. setManifestType(manifestType) {}
  53. };
  54. /**
  55. * A collection of time offsets used to adjust text cue times.
  56. *
  57. * @typedef {{
  58. * periodStart: number,
  59. * segmentStart: number,
  60. * segmentEnd: number,
  61. * vttOffset: number
  62. * }}
  63. *
  64. * @property {number} periodStart
  65. * The absolute start time of the period in seconds.
  66. * @property {number} segmentStart
  67. * The absolute start time of the segment in seconds.
  68. * @property {number} segmentEnd
  69. * The absolute end time of the segment in seconds.
  70. * @property {number} vttOffset
  71. * The start time relative to either segment or period start depending
  72. * on <code>segmentRelativeVttTiming</code> configuration.
  73. *
  74. * @exportDoc
  75. */
  76. shaka.extern.TextParser.TimeContext;
  77. /**
  78. * A callback used for editing cues before appending.
  79. * Provides the cue, the URI of the captions file the cue was parsed from, and
  80. * the time context that was used when generating that cue.
  81. * You can edit the cue object passed in.
  82. * @typedef {function(!shaka.text.Cue, ?string,
  83. * !shaka.extern.TextParser.TimeContext)}
  84. * @exportDoc
  85. */
  86. shaka.extern.TextParser.ModifyCueCallback;
  87. /**
  88. * @typedef {function():!shaka.extern.TextParser}
  89. * @exportDoc
  90. */
  91. shaka.extern.TextParserPlugin;
  92. /**
  93. * @summary
  94. * An interface for plugins that display text.
  95. *
  96. * @description
  97. * This should handle displaying the text cues on the page. This is given the
  98. * cues to display and told when to start and stop displaying. This should only
  99. * display the cues it is given and remove cues when told to.
  100. *
  101. * <p>
  102. * This should only change whether it is displaying the cues through the
  103. * <code>setTextVisibility</code> function; the app should not change the text
  104. * visibility outside the top-level Player methods. If you really want to
  105. * control text visibility outside the Player methods, you must set the
  106. * <code>streaming.alwaysStreamText</code> Player configuration value to
  107. * <code>true</code>.
  108. *
  109. * @interface
  110. * @extends {shaka.util.IDestroyable}
  111. * @exportDoc
  112. */
  113. shaka.extern.TextDisplayer = class {
  114. /**
  115. * @override
  116. * @exportDoc
  117. */
  118. destroy() {}
  119. /**
  120. * Sets the TextDisplayer configuration.
  121. *
  122. * @param {shaka.extern.TextDisplayerConfiguration} config
  123. */
  124. configure(config) {}
  125. /**
  126. * Append given text cues to the list of cues to be displayed.
  127. *
  128. * @param {!Array.<!shaka.text.Cue>} cues
  129. * Text cues to be appended.
  130. *
  131. * @exportDoc
  132. */
  133. append(cues) {}
  134. /**
  135. * Remove all cues that are fully contained by the given time range (relative
  136. * to the presentation). <code>endTime</code> will be greater to equal to
  137. * <code>startTime</code>. <code>remove</code> should only return
  138. * <code>false</code> if the displayer has been destroyed. If the displayer
  139. * has not been destroyed <code>remove</code> should return <code>true</code>.
  140. *
  141. * @param {number} startTime
  142. * @param {number} endTime
  143. *
  144. * @return {boolean}
  145. *
  146. * @exportDoc
  147. */
  148. remove(startTime, endTime) {}
  149. /**
  150. * Returns true if text is currently visible.
  151. *
  152. * @return {boolean}
  153. *
  154. * @exportDoc
  155. */
  156. isTextVisible() {}
  157. /**
  158. * Set text visibility.
  159. *
  160. * @param {boolean} on
  161. *
  162. * @exportDoc
  163. */
  164. setTextVisibility(on) {}
  165. };
  166. /**
  167. * A factory for creating a TextDisplayer.
  168. *
  169. * @typedef {function():!shaka.extern.TextDisplayer}
  170. * @exportDoc
  171. */
  172. shaka.extern.TextDisplayer.Factory;