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