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. * @typedef {function():!shaka.extern.TextParser}
  79. * @exportDoc
  80. */
  81. shaka.extern.TextParserPlugin;
  82. /**
  83. * @summary
  84. * An interface for plugins that display text.
  85. *
  86. * @description
  87. * This should handle displaying the text cues on the page. This is given the
  88. * cues to display and told when to start and stop displaying. This should only
  89. * display the cues it is given and remove cues when told to.
  90. *
  91. * <p>
  92. * This should only change whether it is displaying the cues through the
  93. * <code>setTextVisibility</code> function; the app should not change the text
  94. * visibility outside the top-level Player methods. If you really want to
  95. * control text visibility outside the Player methods, you must set the
  96. * <code>streaming.alwaysStreamText</code> Player configuration value to
  97. * <code>true</code>.
  98. *
  99. * @interface
  100. * @extends {shaka.util.IDestroyable}
  101. * @exportDoc
  102. */
  103. shaka.extern.TextDisplayer = class {
  104. /**
  105. * @override
  106. * @exportDoc
  107. */
  108. destroy() {}
  109. /**
  110. * Append given text cues to the list of cues to be displayed.
  111. *
  112. * @param {!Array.<!shaka.text.Cue>} cues
  113. * Text cues to be appended.
  114. *
  115. * @exportDoc
  116. */
  117. append(cues) {}
  118. /**
  119. * Remove all cues that are fully contained by the given time range (relative
  120. * to the presentation). <code>endTime</code> will be greater to equal to
  121. * <code>startTime</code>. <code>remove</code> should only return
  122. * <code>false</code> if the displayer has been destroyed. If the displayer
  123. * has not been destroyed <code>remove</code> should return <code>true</code>.
  124. *
  125. * @param {number} startTime
  126. * @param {number} endTime
  127. *
  128. * @return {boolean}
  129. *
  130. * @exportDoc
  131. */
  132. remove(startTime, endTime) {}
  133. /**
  134. * Returns true if text is currently visible.
  135. *
  136. * @return {boolean}
  137. *
  138. * @exportDoc
  139. */
  140. isTextVisible() {}
  141. /**
  142. * Set text visibility.
  143. *
  144. * @param {boolean} on
  145. *
  146. * @exportDoc
  147. */
  148. setTextVisibility(on) {}
  149. };
  150. /**
  151. * A factory for creating a TextDisplayer.
  152. *
  153. * @typedef {function():!shaka.extern.TextDisplayer}
  154. * @exportDoc
  155. */
  156. shaka.extern.TextDisplayer.Factory;